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

rewrite code for optical model that triggers events #18

Closed
mwetter opened this issue Mar 3, 2013 · 1 comment
Closed

rewrite code for optical model that triggers events #18

mwetter opened this issue Mar 3, 2013 · 1 comment

Comments

@mwetter
Copy link
Member

mwetter commented Mar 3, 2013

Buildings.HeatTransfer.WindowsBeta.BaseClasses.AbsorbedRadiation and TransmittedRadiation trigger many state events:

The events are caused by the "if" statement and the "integer(x)". This causes about 10 event iterations for each day of simulation, which limits the integration step size (and is expensive).

As a work-around, the "integer(x)" may be avoided if another interpolation is used than the cubicHermite function, or if the whole section between integer(x) and cubicHermite(...)" is put into a function and the smooth annotation is used.

As a test case, enable event logging during simulation and run Buildings.RoomsBeta.Examples.MixedAirFreeResponse

The problematic section is:
{{{
if incAng < 0.5_Modelica.Constants.pi then
x := 2_(NDIR - 1)_abs(incAng)/Modelica.Constants.pi
"x=(index-1)_incAng/(0.5pi), 0<=x<=NDIR";
x := x + 2;
k1 := integer(x) "2<=k<=NDIR+2=HEM+1";
k2 := k1 + 1 "3<=k2<=NDIR+3=HEM+2";

for i in 1:N loop
  // Glass without shading: Add absorbed direct radiation
  y1d := (coeAbsEx[NoShade, i, k1 + 1] - coeAbsEx[NoShade, i, k1 - 1])/2;
  y2d := (coeAbsEx[NoShade, i, k2 + 1] - coeAbsEx[NoShade, i, k2 - 1])/2;
  tmpNoSha := Modelica.Fluid.Utilities.cubicHermite(...

}}}

@mwetter
Copy link
Member Author

mwetter commented Mar 3, 2013

[wzuo] Add a smoothInterpolation function to avoid the event. Problem is fixed.

@mwetter mwetter closed this as completed Mar 3, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant