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

Duplicate code calculating surface reference air temperature #8945

Closed
3 tasks
matthew-larson opened this issue Aug 3, 2021 · 3 comments · Fixed by #8944
Closed
3 tasks

Duplicate code calculating surface reference air temperature #8945

matthew-larson opened this issue Aug 3, 2021 · 3 comments · Fixed by #8944
Assignees
Labels
Defect Includes code to repair a defect in EnergyPlus

Comments

@matthew-larson
Copy link
Contributor

Issue overview

The same surface reference air temperature calculation was found to be done in multiple locations (WindowManager.cc, WindowComplexManager.cc, WindowEquivalentLayer.cc, and ZoneTempPredictorCorrector.cc) after the initial calculation in HeatBalanceSurfaceManager.cc. The results from HeatBalanceSurfaceManager.cc (state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) and state.dataHeatBal->SurfTempEffBulkAir(SurfNum)) should be able to be referenced and used in the other locations without having to redo the calculation over again.

        {
            auto const SELECT_CASE_var(state.dataSurface->SurfTAirRef(SurfNum));
            if (SELECT_CASE_var == ZoneMeanAirTemp) {
                state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum);
                state.dataHeatBal->SurfTempEffBulkAir(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum); // for reporting surf adjacent air temp
            } else if (SELECT_CASE_var == AdjacentAirTemp) {
                state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = state.dataHeatBal->SurfTempEffBulkAir(SurfNum);
            } else if (SELECT_CASE_var == ZoneSupplyAirTemp) {
                // determine ZoneEquipConfigNum for this zone
                int ZoneEquipConfigNum = ZoneNum;
                // check whether this zone is a controlled zone or not
                if (!state.dataHeatBal->Zone(ZoneNum).IsControlled) {
                    ShowFatalError(state,
                                   "Zones must be controlled for Ceiling-Diffuser Convection model. No system serves zone " +
                                       state.dataHeatBal->Zone(ZoneNum).Name);
                    return;
                }
                // determine supply air conditions
                Real64 SumSysMCp = 0.0;
                Real64 SumSysMCpT = 0.0;
                Real64 const CpAir = Psychrometrics::PsyCpAirFnW(state.dataHeatBalFanSys->ZoneAirHumRat(ZoneNum));
                for (int NodeNum = 1; NodeNum <= state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).NumInletNodes; ++NodeNum) {
                    Real64 NodeTemp = state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).Temp;
                    Real64 MassFlowRate =
                        state.dataLoopNodes->Node(state.dataZoneEquip->ZoneEquipConfig(ZoneEquipConfigNum).InletNode(NodeNum)).MassFlowRate;
                    // Real64 CpAir2 = PsyCpAirFnW(ZoneAirHumRat(ZoneNum), NodeTemp);
                    SumSysMCp += MassFlowRate * CpAir;
                    SumSysMCpT += MassFlowRate * CpAir * NodeTemp;
                }
                // a weighted average of the inlet temperatures.
                if (SumSysMCp > 0.0) {                                                      // protect div by zero
                    state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = SumSysMCpT / SumSysMCp; // BG changed 02-16-2005 to add index (SurfNum)
                } else {
                    state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum);
                }
                state.dataHeatBal->SurfTempEffBulkAir(SurfNum) =
                    state.dataHeatBalSurfMgr->RefAirTemp(SurfNum); // for reporting surf adjacent air temp
            } else {
                // currently set to mean air temp but should add error warning here
                state.dataHeatBalSurfMgr->RefAirTemp(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum);
                state.dataHeatBal->SurfTempEffBulkAir(SurfNum) = state.dataHeatBalFanSys->MAT(ZoneNum); // for reporting surf adjacent air temp
            }
        }

Details

Some additional details for this issue (if relevant):

  • EnergyPlus v9.5

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)
@matthew-larson matthew-larson added the Defect Includes code to repair a defect in EnergyPlus label Aug 3, 2021
@matthew-larson matthew-larson added this to the EnergyPlus 9.6 BugFix Freeze milestone Aug 3, 2021
@matthew-larson matthew-larson self-assigned this Aug 3, 2021
@matthew-larson matthew-larson linked a pull request Aug 3, 2021 that will close this issue
12 tasks
@mjwitte
Copy link
Contributor

mjwitte commented Aug 3, 2021

There may be a reason for some of these to recalc with updated air temperatures during the system timesteps, just guessing.
For sure the blocks of code for this in CalcHeatBalanceInsideSurf2 and CalcHeatBalanceInsideSurf2CTFOnly can be pulled out into a common function.

@matthew-larson
Copy link
Contributor Author

That was my thought too so I'll double check for necessary recalcs.

@amirroth
Copy link
Collaborator

amirroth commented Aug 3, 2021

This was put in as part of the EnergyPlus 0.01X project.

@Myoldmopar Myoldmopar modified the milestones: EnergyPlus 9.6 BugFix Freeze, EnergyPlus 9.6 Release Aug 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Defect Includes code to repair a defect in EnergyPlus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants