open-ideas / IDEAS

Modelica library allowing simultaneous transient simulation of thermal and electrical systems at both building and feeder level.
131 stars 56 forks source link

Stack effect airflow #1296

Closed Mathadon closed 10 months ago

Mathadon commented 2 years ago

For #1244

Mathadon commented 1 year ago

I tested IDEAS.Examples.Tutorial.Example5 with sim(interZonalAirFlowType=IDEAS.BoundaryConditions.Types.InterZonalAirFlow.TwoPorts) and that seems to compile.

The simulation however results in

Integration started at T = 10000000 using integration method LSODAR
(Multi-step solver for stiff and non-stiff ODE's with root finder (lsodar of ODEPACK))

Integration terminated before reaching "StopTime" at T = 1.03e+07

...

... Error message from dymosim

ERROR: The simulation of IDEAS.Examples.Tutorial.Example5 FAILED

However with dassl:


Integration terminated successfully at T = 11000000
   CPU-time for integration                : 2.09 seconds
   CPU-time for one grid interval          : 0.418 milliseconds
   CPU-time for initialization             : 0.0396 seconds
   Number of result points                 : 5002
   Number of grid points                   : 5001
   Number of accepted steps                : 8251
   Number of f-evaluations (dynamics)      : 18407
   Number of crossing function evaluations : 13251
   Number of Jacobian-evaluations          : 1512
   Number of model time events             : 0
   Number of input time events             : 0
   Number of state events                  : 0
   Number of step events                   : 0
   Minimum integration stepsize            : 0.0214
   Maximum integration stepsize            : 810
   Maximum integration order               : 5
Calling terminal section
... "dsfinal.txt" creating (final states)

SUCCESSFUL simulation of IDEAS.Examples.Tutorial.Example5

Example9:


Integration started at T = 10000000 using integration method LSODAR
(Multi-step solver for stiff and non-stiff ODE's with root finder (lsodar of ODEPACK))
Error: The following error was detected at time: 10008200
  Pressure (= -2.85222e+06 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.305 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10008050
  Pressure (= -325089 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.298 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10011800
  Pressure (= -2.07699e+07 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.502 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10011650
  Pressure (= -798532 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.431 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10011612.5
  Pressure (= -478971 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.429 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10015250
  Pressure (= -519918 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.458 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)

Integration terminated before reaching "StopTime" at T = 1e+07

@kldjonge were it these kinds of errors that you experienced? For what model did you have problems?

Mathadon commented 1 year ago

CVode solves example 9 with steady state fans. So it seems to be an integrator issue.

kldjonge commented 1 year ago

I will check in detail soon, but most of the time I just got: “the model is singular”

kldjonge commented 1 year ago

This model:

model StructureExt_2Port "Extended the structure but with 2-port option ON"
  extends IDEAS.Examples.PPD12.Structure(sim(interZonalAirFlowType=IDEAS.BoundaryConditions.Types.InterZonalAirFlow.TwoPorts,
        n50=3));
end StructureExt_2Port;

Gives this:

image

And I also often het this error for other models when the two-port flow is activated, typically when a big cavity is in place.

kldjonge commented 1 year ago

I tested IDEAS.Examples.Tutorial.Example5 with sim(interZonalAirFlowType=IDEAS.BoundaryConditions.Types.InterZonalAirFlow.TwoPorts) and that seems to compile.

The simulation however results in

Integration started at T = 10000000 using integration method LSODAR
(Multi-step solver for stiff and non-stiff ODE's with root finder (lsodar of ODEPACK))

Integration terminated before reaching "StopTime" at T = 1.03e+07

...

... Error message from dymosim

ERROR: The simulation of IDEAS.Examples.Tutorial.Example5 FAILED

However with dassl:


Integration terminated successfully at T = 11000000
   CPU-time for integration                : 2.09 seconds
   CPU-time for one grid interval          : 0.418 milliseconds
   CPU-time for initialization             : 0.0396 seconds
   Number of result points                 : 5002
   Number of grid points                   : 5001
   Number of accepted steps                : 8251
   Number of f-evaluations (dynamics)      : 18407
   Number of crossing function evaluations : 13251
   Number of Jacobian-evaluations          : 1512
   Number of model time events             : 0
   Number of input time events             : 0
   Number of state events                  : 0
   Number of step events                   : 0
   Minimum integration stepsize            : 0.0214
   Maximum integration stepsize            : 810
   Maximum integration order               : 5
Calling terminal section
... "dsfinal.txt" creating (final states)

SUCCESSFUL simulation of IDEAS.Examples.Tutorial.Example5

Example9:


Integration started at T = 10000000 using integration method LSODAR
(Multi-step solver for stiff and non-stiff ODE's with root finder (lsodar of ODEPACK))
Error: The following error was detected at time: 10008200
  Pressure (= -2.85222e+06 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.305 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10008050
  Pressure (= -325089 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.298 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10011800
  Pressure (= -2.07699e+07 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.502 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10011650
  Pressure (= -798532 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.431 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10011612.5
  Pressure (= -478971 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.429 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)
Solver will attempt to handle this problem.

Error: The following error was detected at time: 10015250
  Pressure (= -519918 Pa) of medium "IDEAS.Media.Air" is negative
(Temperature = 293.458 K)
  Failed condition: noEvent(rectangularZoneTemplate1.port_b.p >= 0.0)

Integration terminated before reaching "StopTime" at T = 1e+07

@kldjonge were it these kinds of errors that you experienced? For what model did you have problems?

@Mathadon, for example 5 and 9, did you add a large opening in the internal wall before testing it?

Mathadon commented 1 year ago

@kldjonge cd1d89e seems to fix Example5 when using TwoPort and hasCavityC=true in OpenModelica. Can you verify that this solves the problem?

kldjonge commented 1 year ago

@Mathadon, Example5 runs indeed. But it doesn't solve the problems across the board: IDEAS.Examples.PPD12.StructureExt_2Port is stil singular.

Mathadon commented 1 year ago

@kldjonge I have reviewed the model and couldn't find the problem yet. It is singular with and without cavities in the wall when using TwoPort. I ruled out a few possible causes but didn't figure it out yet.

Mathadon commented 1 year ago

OM reports the following error (only) when using TwoPorts:

Internal error NFConnection.split got unbalanced connection connect(cei3.propsBus_b, stairWay.proBusCei[1]):
  lhs: {cei3.propsBus_b.v50, cei3.propsBus_b.use_port_2, cei3.propsBus_b.use_port_1, cei3.propsBus_b.use_custom_q50, cei3.propsBus_b.use_custom_n50, cei3.propsBus_b.surfRad.Q_flow, cei3.propsBus_b.surfRad.T, cei3.propsBus_b.surfCon.Q_flow, cei3.propsBus_b.surfCon.T, cei3.propsBus_b.q50_zone, cei3.propsBus_b.port_2.h_outflow, cei3.propsBus_b.port_2.m_flow, cei3.propsBus_b.port_2.p, cei3.propsBus_b.port_1.h_outflow, cei3.propsBus_b.port_1.m_flow, cei3.propsBus_b.port_1.p, cei3.propsBus_b.outputAngles, cei3.propsBus_b.numIncAndAziInBus, cei3.propsBus_b.inc, cei3.propsBus_b.iSolDir.Q_flow, cei3.propsBus_b.iSolDir.T, cei3.propsBus_b.iSolDif.Q_flow, cei3.propsBus_b.iSolDif.T, cei3.propsBus_b.epsSw, cei3.propsBus_b.epsLw, cei3.propsBus_b.azi, cei3.propsBus_b.area, cei3.propsBus_b.Qgai.Q_flow, cei3.propsBus_b.Qgai.T, cei3.propsBus_b.QTra_design, cei3.propsBus_b.E.E, cei3.propsBus_b.E.Etot}
  rhs: {stairWay.proBusCei[1].v50, stairWay.proBusCei[1].use_port_2, stairWay.proBusCei[1].use_port_1, stairWay.proBusCei[1].use_custom_q50, stairWay.proBusCei[1].use_custom_n50, stairWay.proBusCei[1].surfRad.Q_flow, stairWay.proBusCei[1].surfRad.T, stairWay.proBusCei[1].surfCon.Q_flow, stairWay.proBusCei[1].surfCon.T, stairWay.proBusCei[1].q50_zone, stairWay.proBusCei[1].port_2.h_outflow, stairWay.proBusCei[1].port_2.Xi_outflow[1], stairWay.proBusCei[1].port_2.m_flow, stairWay.proBusCei[1].port_2.p, stairWay.proBusCei[1].port_1.h_outflow, stairWay.proBusCei[1].port_1.Xi_outflow[1], stairWay.proBusCei[1].port_1.m_flow, stairWay.proBusCei[1].port_1.p, stairWay.proBusCei[1].outputAngles, stairWay.proBusCei[1].numIncAndAziInBus, stairWay.proBusCei[1].inc, stairWay.proBusCei[1].iSolDir.Q_flow, stairWay.proBusCei[1].iSolDir.T, stairWay.proBusCei[1].iSolDif.Q_flow, stairWay.proBusCei[1].iSolDif.T, stairWay.proBusCei[1].epsSw, stairWay.proBusCei[1].epsLw, stairWay.proBusCei[1].azi, stairWay.proBusCei[1].area, stairWay.proBusCei[1].Qgai.Q_flow, stairWay.proBusCei[1].Qgai.T, stairWay.proBusCei[1].QTra_design, stairWay.proBusCei[1].E.E, stairWay.proBusCei[1].E.Etot}
image

It seems that the Xi connections are missing. Possibly the used media are inconsistent. It's not clear to me why this would not result in a problem when using OnePort, nor why the translation does not report an unequal number of equations and variables.

Edit: I could not find incorrect Media and it seems like the equations for Xi are set correctly.

Mathadon commented 1 year ago

propsBus_b correctly has final use_port_2=sim.interZonalAirFlowType == IDEAS.BoundaryConditions.Types.InterZonalAirFlow.TwoPorts and redeclare final package Medium = Medium.

kldjonge commented 1 year ago

Some information I got from claytex:

What could be occurring in your case is that one variable is being set twice (has two equations that define it) and another variable is not being set at all. Unfortunately it is not easy to figure out the problem in Dymola unless this is occurring in the Bus connectors as the debugging for that is well logged (I will ask the developers to improve the debugging information to assist the user more in this case)

kldjonge commented 1 year ago

Spotted some issues:

As I don't have write acces to this branch so my adaptation will be here: https://github.com/kldjonge/IDEAS/tree/StackEffectAirflow

On first glance, things (heights of density columns ect.) seem to work as intended.

Mathadon commented 1 year ago

@jelgerjansen can we discuss on how to proceed with this PR?

Mathadon commented 1 year ago

@jelgerjansen I'd like to refactor this code a bit. Can you check whether all unit tests pass before that I start changing things?

Mathadon commented 1 year ago

For the record, the major bug in this PR was fixed by 83f1f21

jelgerjansen commented 1 year ago

@Mathadon

Mathadon commented 1 year ago

Yup

jelgerjansen commented 1 year ago

Merging the master branch into this branch did not lead to conflicts. I will now run the UnitTests per package to check the differences

jelgerjansen commented 1 year ago

IDEAS.Buildings.Components

jelgerjansen commented 1 year ago

IDEAS.Buildings.Examples image image

jelgerjansen commented 1 year ago

IDEAS.Examples.TwinHouses image image

jelgerjansen commented 1 year ago

IDEAS.Examples.PPD12 image

jelgerjansen commented 1 year ago

IDEAS.Examples.Tutorial

jelgerjansen commented 1 year ago

@Mathadon @kldjonge I just pushed the latest reference results to this branch. I reported all differences above. The most significant changes are in the PPD12 model. This can be due to the stack airflow effect, but I also noticed some minor changes in the building envelope model itself.

kldjonge commented 1 year ago

@jelgerjansen, If I recall correctly I made changes to accommodate the airflows indeed. Most notably the opening in the floor (internal wall) to represent the staircase. The verification model in CONTAM is almost ready, so then the final debugging/verification data will be available.

kldjonge commented 1 year ago

I must correct myself, I don't believe the changes I mentioned are allready in this branch. I've send you an e-mail @jelgerjansen.

Mathadon commented 1 year ago

Based upon discussion:

jelgerjansen commented 1 year ago

@Mathadon @kldjonge I ran IDEAS.Examples.TwinHouses.BuildingO5_Exp1_1Port.mo again. The results are already better, but still errors compared to the CONTAM model in the order of 1e-2. Could this be due to the default wind pressure computation? image image

Furthermore, the newly add unit test for BuildingO5_Exp1_2Port throws an error due to the absence of resDoor (which is needed to calculate comparison_W40): in this wall, useDooOpe is true, due to which useResDoor is false (see InternalWall model implementation)

Mathadon commented 1 year ago

Ah, now I remember something else: the 1 port door configuration contains a medium column, which I have removed in my pull request. This indeed seems wrong and was not included in the contam reference results either. So it should probably be removed before rerunning the reference results. @kldjonge ?

kldjonge commented 1 year ago

True. For this branch/unit test it should not be included. (We can discuss maybe adding density columns in a later stage just for the larger openings, but not for now)

jelgerjansen commented 1 year ago

@Mathadon @kldjonge could you explicitly tell me what I should remove in which models? Then I can rerun the unit tests after applying the changes (and such that we can hopefully move on to the other PRs after that ;) )

kldjonge commented 1 year ago

@jelgerjansen, apparently having branches/pull request with exactly the same name causes issues. At least in the tool I use, I can't load this pull request so being very specific is hard. If I recall correctly, the column we are talking about is in the internal wall component and was added between the door component and the connectors.

jelgerjansen commented 1 year ago

@Mathadon @kldjonge removing the density columns between the door, i.e. going from this: image to this: image gives the same results as plotted here: https://github.com/open-ideas/IDEAS/pull/1296#issuecomment-1710181734...

Removing the density columns therefore didn't affect any of the reference results...

jelgerjansen commented 1 year ago

Thank you @kldjonge, this indeed fixes the problem; the reference results are now exactly the same as those of the master branch: image image

@Mathadon can you comment on the specific implementation of Cs as noted by Klaas above?

Furthermore, before pushing the new changes, I would like to know what to do with the unit test for IDEAS.Examples.TwinHouses.Building05_Exp1_2Port, which threw an error (see https://github.com/open-ideas/IDEAS/pull/1296#issuecomment-1710181734)

Mathadon commented 1 year ago

@jelgerjansen no, I'm not too familiar with that model.

With respect to the error, I'd remove the offending variables in the .mos file for now :)

jelgerjansen commented 1 year ago

Due to the change in calculation of Cs, all previously changed reference results are also different of course. Give me some time to reset the reference results again to the 'original' ones, such that we can compare again with those instead of the reference results with the 'wrong' Cs values.

Mathadon commented 1 year ago

okay, sounds like a good extra check!

jelgerjansen commented 1 year ago

Running the unit tests using the updated Cs calculation and comparing to the 'original' reference results leads to lower deviations between the new and old reference results. An overview of the changes can be found below: IDEAS Buildings Examples ScreenComparison IDEAS Buildings Examples ZoneExample IDEAS_Examples_PPD12_VentilationRBC

I think we can therefore continue and merge these changes in #1322?

The reference results of TwinHouses are, in contrast to the first unit test that I ran, not changed.

kldjonge commented 1 year ago

I think we can move on to the next branch indeed. Great!

jelgerjansen commented 10 months ago

The changes of this PR are included in #1327. Further development of the stack airflow effect will take place in that PR.