lbl-srg / modelica-buildings

Modelica Buildings library
258 stars 160 forks source link

Add example models of full 5GDHC systems #1769

Closed AntoineGautier closed 3 years ago

AntoineGautier commented 4 years ago

This issue is related to:

Example models of 5th generation DHC systems are generated in Buildings.Experimental.DHC.Examples to illustrate:

The development branch is issue1769_examples5GDHC.

The examples are still under development. TO DO:

AntoineGautier commented 4 years ago

@amyeallen1 @khinkelman @nllong @YanfeiNREL You can checkout this branch to see whole DHC system example models. As discussed this is still under development.

AntoineGautier commented 3 years ago

EDIT (2/16/21): TODO

Comparison of annual electricity use (in e+12 Wh) between

Branch Etot EHeaPum EPum CPU-time (CVode 1e-6)
issue1613_rnbnComparison 4.0 2.5 1.5 21
issue1769_examples5GDHC 3.5 2.2 1.3 182

As mentioned in https://github.com/lbl-srg/modelica-buildings/issues/1769#issuecomment-780937436 the increase in simulation time is mostly due to the building mechanical system model. An alternative approach for coupling time series will be developed in #2302.

Comparison of annual electricity use (in e+12 Wh) between

Branch Etot EHeaPum EPum CPU-time (CVode 1e-6)
issue1613_rnbnComparison 2.7 2.5 0.2 54
issue1769_examples5GDHC 2.5 2.3 0.3 248

[EDIT] (4/12/21): Impact of corrected borehole characteristics

See https://github.com/lbl-srg/modelica-buildings/pull/2373#discussion_r607348601

On Buildings.Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Examples.SeriesConstantFlow commit 97561a13c87fe3e862c61ee372783835bca631b4

Branch Etot EHeaPum EPum CPU-time (CVode 1e-6)
issue1613_rnbnComparison 4.0 2.5 1.5 21
issue1769_examples5GDHC 3.5 2.2 1.3 220

On Buildings.Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Examples.SeriesVariableFlow commit 97561a13c87fe3e862c61ee372783835bca631b4

Branch Etot EHeaPum EPum CPU-time (CVode 1e-6)
issue1613_rnbnComparison 2.7 2.5 0.2 54
issue1769_examples5GDHC 2.5 2.3 0.3 307
AntoineGautier commented 3 years ago

Parameters influencing simulation time

Summary of the main modifications with potential impact

The refactoring of the original models from issue1613_rnbnComparison includes the following modifications that may impact the simulation time.

Fan dynamics in terminal unit model

This is related to the fan component in Buildings.Experimental.DHC.Loads.Validation.BaseClasses.FanCoil2PipeCooling Buildings.Experimental.DHC.Loads.Validation.BaseClasses.FanCoil2PipeHeating

The model simulated has 3 buildings * 2 FCU / building = 6 instances.

simulateModel("Buildings.Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Examples.SeriesConstantFlow",
    method="cvode",
    tolerance=1e-6,
    startTime=0,
    stopTime=6048000);

With energy and mass dynamics (fixed initial)

Integration terminated successfully at T = 6.048e+06
   CPU-time for integration                  : 19.895 seconds
   CPU-time for initialization               : 0.731633 seconds
   Number of result points                   : 4317
   Number of grid points                     : 501
   Number of accepted steps                  : 91400
   Number of rejected steps                  : 5262
   Number of f-evaluations (dynamics)        : 143274
   Number of non-linear iteration            : 135901
   Number of non-linear convergence failures : 245
   Number of Jacobian-evaluations            : 3702
   Number of crossing function evaluations   : 93369
   Number of model time events               : 1759
   Number of state events                    : 159
   Number of step events                     : 0

In steady-state

Integration terminated successfully at T = 6.048e+06
   CPU-time for integration                  : 16.8291 seconds
   CPU-time for initialization               : 0.724413 seconds
   Number of result points                   : 4317
   Number of grid points                     : 501
   Number of accepted steps                  : 71511
   Number of rejected steps                  : 3664
   Number of f-evaluations (dynamics)        : 105427
   Number of non-linear iteration            : 97862
   Number of non-linear convergence failures : 32
   Number of Jacobian-evaluations            : 2647
   Number of crossing function evaluations   : 73463
   Number of model time events               : 1759
   Number of state events                    : 159
   Number of step events                     : 0

So a gain of nearly 30% in the number of non-linear iterations, and about 15% in CPU-time for integration. However, the steady-state model yields this warning in Dymola.

Some variables are iteration variables of the initialization problem:
but they are not given any explicit start values. Zero will be used.

Iteration variables:
bui[1].bui.terUniCoo.fan.heaDis.WHyd
...

And heaDis is a protected component that prevents modifying the start attribute of WHyd. So currently the fan is modeled with a state.

Simulating the model with DASSL shows that most of the states that dominate the error correspond to the terminal unit model. The feature enhancement in #2302 should address this.

Screen Shot 2021-02-17 at 4 15 26 PM

Time constant of control volume in junctions

This is related to the control volume in the fluid junction components, especially before and after each connection to an agent (ETS, plant or storage). The effect is highly tangible with closed loop control of the distribution system (as opposed to constant flow rate).

simulateModel("Buildings.Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Examples.SeriesVariableFlow",
    method="cvode",
    tolerance=1e-6,
    startTime=0,
    stopTime=6048000);

tau=5*60 (setting from original models in issue1613_rnbnComparison)

Integration terminated successfully at T = 6.048e+06
   CPU-time for integration                  : 26.3316 seconds
   CPU-time for initialization               : 0.807683 seconds
   Number of result points                   : 4319
   Number of grid points                     : 501
   Number of accepted steps                  : 118454
   Number of rejected steps                  : 6985
   Number of f-evaluations (dynamics)        : 186083
   Number of non-linear iteration            : 178706
   Number of non-linear convergence failures : 299
   Number of Jacobian-evaluations            : 4409
   Number of crossing function evaluations   : 120433
   Number of model time events               : 1759
   Number of state events                    : 160
   Number of step events                     : 0

tau=10 (default setting for the base classes in Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Networks)

Integration terminated successfully at T = 6.048e+06
   CPU-time for integration                  : 47.0535 seconds
   CPU-time for initialization               : 0.75922 seconds
   Number of result points                   : 4319
   Number of grid points                     : 501
   Number of accepted steps                  : 252732
   Number of rejected steps                  : 18448
   Number of f-evaluations (dynamics)        : 368372
   Number of non-linear iteration            : 360288
   Number of non-linear convergence failures : 291
   Number of Jacobian-evaluations            : 7193
   Number of crossing function evaluations   : 254736
   Number of model time events               : 1759
   Number of state events                    : 160
   Number of step events                     : 0

CPU-time for integration is nearly doubled. The whole-year simulation will eventually stall. However, 5' transport delay at each junction seems also unrealistic. A plug flow pipe model will probably be better suited to include temperature dynamics.

Solver tolerance

simulateModel("Buildings.Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Examples.SeriesVariableFlow",
    method="cvode",
    tolerance=1e-6,    // Default setting.
    startTime=0,
    stopTime=6048000);
Integration terminated successfully at T = 6.048e+06
   CPU-time for integration                  : 26.3316 seconds
   CPU-time for initialization               : 0.807683 seconds
   Number of result points                   : 4319
   Number of grid points                     : 501
   Number of accepted steps                  : 118454
   Number of rejected steps                  : 6985
   Number of f-evaluations (dynamics)        : 186083
   Number of non-linear iteration            : 178706
   Number of non-linear convergence failures : 299
   Number of Jacobian-evaluations            : 4409
   Number of crossing function evaluations   : 120433
   Number of model time events               : 1759
   Number of state events                    : 160
   Number of step events                     : 0
simulateModel("Buildings.Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Examples.SeriesVariableFlow",
    method="cvode",
    tolerance=1e-4,     // Change in tolerance.
    startTime=0,
    stopTime=6048000);
Integration terminated successfully at T = 6.048e+06
   CPU-time for integration                  : 20.6832 seconds
   CPU-time for initialization               : 0.771738 seconds
   Number of result points                   : 4339
   Number of grid points                     : 501
   Number of accepted steps                  : 79861
   Number of rejected steps                  : 1004
   Number of f-evaluations (dynamics)        : 119938
   Number of non-linear iteration            : 112354
   Number of non-linear convergence failures : 1319
   Number of Jacobian-evaluations            : 5526
   Number of crossing function evaluations   : 82065
   Number of model time events               : 1759
   Number of state events                    : 170
   Number of step events                     : 0

So a gain of nearly 20% in CPU-time for integration. However, this comes with a high number of

cvode: CVODE CVode At t = 165552, mxstep steps taken before reaching tout.

The conclusion differs with DASSL solver, with a gain closer to 50%. The log also shows that the integration order may effectively be reduced from 5 to 4 with the relaxed tolerance.

simulateModel("Buildings.Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Examples.SeriesVariableFlow",
    method="dassl",
    tolerance=1e-6,    // Default setting.
    startTime=0,
    stopTime=6048000);
Integration terminated successfully at T = 6048000
   CPU-time for integration                : 41.2 seconds
   CPU-time for one grid interval          : 82.4 milliseconds
   CPU-time for initialization             : 0.81 seconds
   Number of result points                 : 4317
   Number of grid points                   : 501
   Number of accepted steps                : 83111
   Number of f-evaluations (dynamics)      : 175368
   Number of crossing function evaluations : 86702
   Number of Jacobian-evaluations          : 26127
   Number of model time events             : 1759
   Number of input time events             : 0
   Number of state events                  : 159
   Number of step events                   : 0
   Minimum integration stepsize            : 1.48e-10
   Maximum integration stepsize            : 796
   Maximum integration order               : 5
simulateModel("Buildings.Experimental.DHC.Examples.Combined.Generation5.Unidirectional.Examples.SeriesVariableFlow",
    method="dassl",
    tolerance=1e-4,    // Default setting.
    startTime=0,
    stopTime=6048000);
Integration terminated successfully at T = 6048000
   CPU-time for integration                : 22.7 seconds
   CPU-time for one grid interval          : 45.4 milliseconds
   CPU-time for initialization             : 0.776 seconds
   Number of result points                 : 4317
   Number of grid points                   : 501
   Number of accepted steps                : 37070
   Number of f-evaluations (dynamics)      : 77966
   Number of crossing function evaluations : 40845
   Number of Jacobian-evaluations          : 16863
   Number of model time events             : 1759
   Number of input time events             : 0
   Number of state events                  : 159
   Number of step events                   : 0
   Minimum integration stepsize            : 1.48e-08
   Maximum integration stepsize            : 1.77e+03
   Maximum integration order               : 4