Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/src/records/loadmeter.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ A note re default values: if lmtSubmeterMults is omitted, all multipliers are de
legal_range: "",
default: "1",
required: "No",
variability: "constant") %>
variability: "subhourly") %>


**endLOADMETER**
Expand Down
7 changes: 5 additions & 2 deletions doc/src/records/meter.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ A comma-separate list of METERs that are accumulated into this METER with option

**mtrSubmeterMults=*list of up to 50 floats***

Submeter multipliers.
Submeter multipliers. Use cases for multipliers include --

- Scaling results from portions of a model to approximate the behavior of multiple similar aspects (e.g. multiple floors in a high-rise building)
- Tracking energy use during selected time intervals; for example, peak-period energy use could be metered for certain hours via scheduled multipliers of 0 or 1.

A note re default values: if mtrSubmeterMults is omitted, all multipliers are defaulted to 1. However, when mtrSubmeterMults is included, a multiplier value should be provided for each METER listed in mtrSubmeters since unspecified values are set to 0.

Expand All @@ -86,7 +89,7 @@ A note re default values: if mtrSubmeterMults is omitted, all multipliers are de
legal_range: "",
default: "1",
required: "No",
variability: "constant") %>
variability: "hourly") %>

**endMeter**

Expand Down
6 changes: 3 additions & 3 deletions src/CNRECS.DEF
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ RECORD TOPRAT "top" *RAT /* top level RAT: contains control info and all once-on
//TOP: runtime: simulation date/time variables
*m CULSTR monStr // Month being simulated
// autoSizing: "heating design day", or month for cooling.
*d CULSTR dateStr // Date being simulated as heap string
*d CULSTR dateStr // Date being simulated as string
// autoSizing: eg "heating design day" or "Jul cooling design day".
*d IDATE tp_date // Date: .month is 1-12, .mday 1-31, .wday 0-6. set/used: cnguts. used:cuparse;cgsolar;cgresult;cgenbal.
// autoSizing: cool: near-mid-month day as used for solar calcs; heat: Dec 21. jDay ditto.
Expand Down Expand Up @@ -4009,7 +4009,7 @@ RECORD LOADMTR "LOADMETER" *RAT // LOADMETER: general way to track loads
*declare "void lmt_AccumFromSubmeters();"

*r *array DIM_SUBMETERLIST TI lmt_subMtri; // submeters
*r *array DIM_SUBMETERLIST FLOAT lmt_subMtrMult // submeter multipliers
*s *array DIM_SUBMETERLIST FLOAT lmt_subMtrMult // submeter multipliers

// accumulated values for each interval
// CAUTION: ordered for subscripting by IVLCH-1
Expand Down Expand Up @@ -5543,7 +5543,7 @@ RECORD MTR "meter" *RAT // Meter input/runtime: energy use by meter, interval,
*i float rate // cost per Btu of use
*i float dmdRate // dmdCost per Btu of demand, for a month
*r *array DIM_SUBMETERLIST TI mtr_subMtri; // submeters
*r *array DIM_SUBMETERLIST FLOAT mtr_subMtrMult // submeter multipliers
*h *array DIM_SUBMETERLIST FLOAT mtr_subMtrMult // submeter multipliers

//results: accumulated useage and cost for this meter (record subscript),
// for each interval (member here), usage by end use (substruct member):
Expand Down
4 changes: 2 additions & 2 deletions src/cncult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ CULT("*", STAR, 0, 0, 0, 0, 0, 0,
CULT( "mtrRate", DAT, MTR_RATE, 0, 0, VHRLY, TYFL, 0, N, 0.f, N, N),
CULT( "mtrDemandRate", DAT, MTR_DMDRATE, 0, 0, VHRLY, TYFL, 0, N, 0.f, N, N),
CULT( "mtrSubMeters", DAT, MTR_SUBMTRI, ARRAY, 0, VEOI, TYREF, &MtriB, N, 0.f, v DIM_SUBMETERLIST, N),
CULT( "mtrSubMeterMults",DAT, MTR_SUBMTRMULT, ARRAY, 0, VEOI, TYFL, 0, N, 1.f, v DIM_SUBMETERLIST, N),
CULT( "mtrSubMeterMults",DAT, MTR_SUBMTRMULT, ARRAY, 0, VHRLY, TYFL, 0, N, 1.f, v DIM_SUBMETERLIST, N),
CULT( "endMeter", ENDER, 0, 0, 0, 0, 0, 0, N, 0.f, N, N),
CULT()
}; // mtrT
Expand Down Expand Up @@ -1757,7 +1757,7 @@ static CULT ldMeterT[] = //------ LOADMETER cmd RAT Entry table
//----------------- ----- ----------------- ------- -- ------ ----- ------ ------ ---- ----
CULT("*", STAR, 0, 0, 0, 0, 0, 0, 0.f, N, lmtStarCkf),
CULT("lmtSubMeters", DAT, LOADMTR_SUBMTRI, ARRAY, 0, VEOI, TYREF, &LdMtriB,N, 0.f, v DIM_SUBMETERLIST, N),
CULT("lmtSubMeterMults",DAT, LOADMTR_SUBMTRMULT,ARRAY, 0, VEOI, TYFL, 0, N, 1.f, v DIM_SUBMETERLIST, N),
CULT("lmtSubMeterMults",DAT, LOADMTR_SUBMTRMULT,ARRAY, 0, VSUBHRLY,TYFL, 0, N, 1.f, v DIM_SUBMETERLIST, N),
CULT("endLOADMETER", ENDER, 0, 0, 0, 0, 0, 0, 0.f, N, N),
CULT()
}; // ldMeterT
Expand Down
79 changes: 47 additions & 32 deletions src/cnguts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1451,6 +1451,30 @@ void ZNRES::zr_InitCurr() // initialize curr mbrs
curr.Y.zr_Init1();
} // ZNRES::zr_InitCurr
//=============================================================================

// struct SUBMETERSEQ: retains accumulation order for submeters
// Why: Submeters must be accumulated "bottom up".
// Order is derived in sortSubMeterList and retained here.
struct SUBMETERSEQ
{
void smsq_Clear()
{
smsq_MTR.clear();
smsq_LOADMTR.clear();
}

RC smsq_Setup();
void smsq_AccumSubhr() const;
void smsq_AccumHour() const;

private:
std::vector< TI> smsq_MTR; // MTR submeter accum order
std::vector< TI> smsq_LOADMTR; // LOADMTR submeter accum order
}; // SUBMETERSEQ
//-----------------------------------------------------------------------------
static SUBMETERSEQ SubMeterSeq;


#define ZRi1 nHrHeat // 1st SI member
#define ZRnI ((oRes(nHrCeilFan) - oRes(nHrHeat))/sizeof(SI) + 1) // # SI members.
// SIs: # hours
Expand Down Expand Up @@ -1578,6 +1602,12 @@ LOCAL void FC doIvlAccum()
pAM->amt_Accum(C_IVLCH_H, Top.isBegHour, Top.isEndHour);
}

// Submeter accumulation for subhr interval
// (currently only LOADMTR, 8-23)
SubMeterSeq.smsq_AccumSubhr();


// LOADMTRs: subhr -> hour
LOADMTR* pLMSum = LdMtrR.p + LdMtrR.n;
LOADMTR* pLM;
RLUP(LdMtrR, pLM) // loop LOADMTRs
Expand Down Expand Up @@ -2199,27 +2229,6 @@ static RC sortSubMeterList( // sort and check re submeters
}
return rc;
} // sortSubMeterList
//-----------------------------------------------------------------------------
// struct SUBMETERSEQ: retains accumulation order for submeters
// Why: Submeters must be accumulated "bottom up".
// Order is derived in sortSubMeterList and retained here.
struct SUBMETERSEQ
{
void smsq_Clear()
{
smsq_MTR.clear();
smsq_LOADMTR.clear();
}

RC smsq_Setup();
void smsq_Accum();

private:
std::vector< TI> smsq_MTR; // MTR submeter accum order
std::vector< TI> smsq_LOADMTR; // LOADMTR submeter accum order
}; // SUBMETERSEQ
//-----------------------------------------------------------------------------
static SUBMETERSEQ SubMeterSeq;
//=============================================================================
RC cgSubMeterSetup() // public access to SUBMETER::smsq_Setup
{
Expand Down Expand Up @@ -2257,20 +2266,25 @@ RC SUBMETERSEQ::smsq_Setup() // derive submeter sequences

} // SUBMETERSEQ::smsq_Setup
//-----------------------------------------------------------------------------
void SUBMETERSEQ::smsq_Accum() // METER and LOADMETER submeter accumulation
void SUBMETERSEQ::smsq_AccumSubhr() const // submeter accum for meters with subhr resolution
{
for (TI ti : smsq_LOADMTR)
{
LOADMTR* lmt;
if (LdMtrR.GetAtGud(ti, lmt))
lmt->lmt_AccumFromSubmeters();
}
} // SUBMETERSEQ::smsq_AccumSubhr
//-----------------------------------------------------------------------------
void SUBMETERSEQ::smsq_AccumHour() const // submeter accum for meters with hour resolution
{
for (TI ti : smsq_MTR)
{ MTR* mtr;
if (MtrB.GetAtGud(ti, mtr))
mtr->mtr_AccumFromSubmeters();
}

for (TI ti : smsq_LOADMTR)
{ LOADMTR* lmt;
if (LdMtrR.GetAtGud(ti, lmt))
lmt->lmt_AccumFromSubmeters();
}
} // SUBMETERSEQ::smsq_Accum
} // SUBMETERSEQ::smsq_AccumHour
//=============================================================================
LOCAL void FC mtrsAccum( // Accumulate metered results: add interval to next, + tot and sum.
// acts on METERs, DHWMTRs, LOADMTRs, and AFMTRs
Expand All @@ -2282,9 +2296,10 @@ LOCAL void FC mtrsAccum( // Accumulate metered results: add interval to next, +
// Not called with ivl = C_IVLCH_H
{
if (ivl == C_IVLCH_D) // if accumulating hour -> day
SubMeterSeq.smsq_Accum(); // accumulate hour ivl from submeter(s) with possible multipliers
// Submeters defined for METER and LOADMETER (4-17-2023)
// Done only for hour
SubMeterSeq.smsq_AccumHour(); // accumulate hour ivl from submeter(s) with possible multipliers
// Hourly-interval submeters defined for METER (8-23)
// Done only for hour.
// See also smsq_AccumSubhr() re subhr-interval meters.

// METERs
MTR* mtr;
Expand Down Expand Up @@ -2665,7 +2680,7 @@ void LOADMTR::lmt_AccumFromSubmeters() // accumulate submeters into this LOADME
// loop submeters
for (int iSM = 0; lmt_subMtri[iSM] > 0; iSM++)
{ const LOADMTR* pSM = LdMtrR.GetAt(lmt_subMtri[iSM]);
VAccum(&H.qHtg, LOADMTR_IVL::lmt_NFLOAT, &pSM->H.qHtg, lmt_subMtrMult[iSM]);
VAccum(&S.qHtg, LOADMTR_IVL::lmt_NFLOAT, &pSM->S.qHtg, lmt_subMtrMult[iSM]);
// lmt_count not maintained
}
} // LOADMTR::lmt_AccumFromSubmeters
Expand Down
16 changes: 8 additions & 8 deletions test/ref/ASHPPKGROOM.REP
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,7 @@ loadmeter Parent: Top
-------------------- -- --- ----- -- ---- ----- --------------- -------- ---------- -------- --------
* 3 0 8192 0 0 0 0 0 0 nz
lmtSubMeters 6 2 128 0 1 8192 LOADMETER 0 0 nz 0
lmtSubMeterMults 6 53 128 0 1 2 0 1 nz 0
lmtSubMeterMults 6 53 128 0 1763 2 0 1 nz 0
endLOADMETER 13 0 0 0 0 0 0 0 0 0


Expand Down Expand Up @@ -1701,7 +1701,7 @@ meter Parent: Top
mtrRate 6 2 0 0 739 2 0 0 0 0
mtrDemandRate 6 3 0 0 739 2 0 0 0 0
mtrSubMeters 6 4 128 0 1 8192 meter 0 0 nz 0
mtrSubMeterMults 6 55 128 0 1 2 0 1 nz 0
mtrSubMeterMults 6 55 128 0 739 2 0 1 nz 0
endMeter 13 0 0 0 0 0 0 0 0 0


Expand Down Expand Up @@ -1989,7 +1989,7 @@ inverse Parent: Top
ivX 6 6 8 0 1771 2 0 0 0 0
ivY 6 7 8 0 1771 2 0 0 0 0
endInverse 13 0 0 0 0 0 0 0 0 0
! CSE 0.918.0+alt-string-ptrs.3cd2999d.33 for Win32 console
! CSE 0.918.0+submeter-variable-multiplier.72cfdd7b.48.dirty for Win32 console



Expand Down Expand Up @@ -3552,18 +3552,18 @@ Input for Run 001:



! CSE 0.918.0+alt-string-ptrs.3cd2999d.33 for Win32 console run(s) done: Wed 12-Jul-23 2:59:57 pm
! CSE 0.918.0+submeter-variable-multiplier.72cfdd7b.48.dirty for Win32 console run(s) done: Mon 07-Aug-23 11:53:30 am

! Executable: d:\cse\msvc\cse.exe
! 12-Jul-23 2:54 pm (VS 14.29 2779136 bytes) (HPWH 1.22.0)
! 07-Aug-23 11:53 am (VS 14.29 2775552 bytes) (HPWH 1.22.0)
! Command line: -x! -t1 ashppkgroom
! Input file: D:\cse\test\ashppkgroom.cse
! Report file: D:\CSE\TEST\ASHPPKGROOM.REP

! Timing info --

! Input: Time = 0.10 Calls = 2 T/C = 0.0480
! Input: Time = 0.10 Calls = 2 T/C = 0.0495
! AutoSizing: Time = 0.30 Calls = 1 T/C = 0.2960
! Simulation: Time = 6.67 Calls = 1 T/C = 6.6670
! Simulation: Time = 6.67 Calls = 1 T/C = 6.6720
! Reports: Time = 0.00 Calls = 1 T/C = 0.0020
! Total: Time = 7.07 Calls = 1 T/C = 7.0680
! Total: Time = 7.08 Calls = 1 T/C = 7.0770
Loading