Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor VRF static timing variables #7729

Closed
3 tasks
mjwitte opened this issue Jan 29, 2020 · 1 comment · Fixed by #8345
Closed
3 tasks

Refactor VRF static timing variables #7729

mjwitte opened this issue Jan 29, 2020 · 1 comment · Fixed by #8345

Comments

@mjwitte
Copy link
Contributor

mjwitte commented Jan 29, 2020

Issue overview

The VRF models have several troublesome static local variables in InitVRF, CalcVRFCondenser and CalcVRFCondenser_FluidTCtrl which can cause problems with serial unit tests. Seems they should either be part of the component structs or should be module level variables. Also, at first glance, if there's more than one VRF condenser these variables will be wrong, because CurrentEndTimeLast will get updated for the first component and then it will be wrong for the next component? Also, some of these variables are beings stored in ...HRTimer and ...HRTime.

Suggest refactoring the VRF models to use a different approach to track timing for control decisions that does not rely on local statics.

Details

Some additional details for this issue (if relevant):

Checklist

Add to this list or remove from it as applicable. This is a simple templated set of guidelines.

  • Defect file added (list location of defect file here)
  • Ticket added to Pivotal for defect (development team task)
  • Pull request created (the pull request will have additional tasks related to reviewing changes that fix this defect)
@mjwitte mjwitte mentioned this issue Jan 29, 2020
20 tasks
@rraustad
Copy link
Contributor

rraustad commented Jan 30, 2020

CurrentEndTime and CurrentEndTimeLast are only used to determine the progression of time and when down-shifting of the HVAC time step occurs. These variables are the same for all VRF systems (i.e., this time step has a time and last time step has a time). Yes these should probably be moved to the module level for unit testing. And if there is a better way to track time then that is preferred. Regarding the location of CurrentEndTime and CurrentEndTimeLast in the CalcVRFCondenser function, these variables should be moved up and down, respectively, outside the IF block where currently set. Also, TimeStepSysLast is not used in this function.

i.e, outside (above and below) this IF block

if (!DoingSizing && !WarmupFlag) {
    // lots of code //
    // calculate end time of current time step to determine if max capacity reset is required
    CurrentEndTime = double((DayOfSim - 1) * 24) + CurrentTime - TimeStepZone + DataHVACGlobals::SysTimeElapsed;
    // more code //
    TimeStepSysLast = DataHVACGlobals::TimeStepSys; <- not used in this function
    CurrentEndTimeLast = CurrentEndTime;
    // more code //
}

jmythms added a commit that referenced this issue Oct 12, 2020
mitchute pushed a commit that referenced this issue Nov 4, 2020
* Changing static variables to namesake variables

Partial fix to #7729

* Hotfix #7723 revert + Add flag to reset CurrentEndTimeLast when InitVRF is not called

The unit test will work without Hotfix #7723.

Not sure if multiple condensors will work.
The HRTime, HRTimer variables still exist.

* Revert "Hotfix #7723 revert + Add flag to reset CurrentEndTimeLast when InitVRF is not called"

This reverts commit 469d49d.

* Revert "Changing static variables to namesake variables"

This reverts commit 67f7d23.

* Removed static for CurrentEndTime + Removed TimeStepSysLast

* Changed TimeStepSysLast to non-static

* moved Real64 TimeStepSysLast; to namespace

To try to get rid of build errors

* Changed two of the CurrentEndTimeLast to non-static

* trying to fix the condensor function

* Change Final static variable to namespace

Fingers crossed

* Moving  namespace variables to module level

* Initialized variables

Got build errors from uninitialized variables. Static variables are automatically zero initialized.  Why were there no errors when they were in the namespace?

* Removed and combine the three CurrentEndTimeLast

Test if everything else working.

* Resolve Conflict

* Fixed license...

* Split the InitVRF and CalcVRFCond CurrentEndTimeLast variables + code cleanup

* Missed this variable rename.

* Update clear_state()

* Temp check

* Code cleanup

removed helper variables...

* Comment + whitespace.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants