ibpsa / modelica-ibpsa

Modelica library for building and district energy systems developed within IBPSA Project 1
https://ibpsa.github.io/project1
145 stars 84 forks source link

Get flat model without constants #1809

Open weberscode opened 1 year ago

weberscode commented 1 year ago

Hi all,

i would like to externally optimize or vary parameters. For i export the model as fmu and optimize it. To externally call and set a model parameter this must be a parameter and not a constant within the flat model. So here is the question?

When i use the thermal zone model and set any of the following parameter

to a value of my record, then the record value and some on its dependant values change to constant during the flattening process. A i said, i need them as a parameter to be externally optimized.

How could i solve this problem?

kr Simon

weberscode commented 1 year ago

I additionally tried it with model SimpleRoomFourElements and now think different. I think the problem is not that I overwrite the variables from the record to VAir, but that generally in RC.FourElements VAir is converted from a parameter type to the constant type after flattening. Why could that happen? What can i do to write on VAir without change to constant type.

weberscode commented 1 year ago

A final before doesn't fix either:

ThermalZones.ReducedOrder.RC.FourElements thermalZoneFourElements( final VAir=VAir,

weberscode commented 1 year ago

When i try a simple capacity the flattening doesn't change the type to constant.

parameter Real sysParam.VAir = 52.5; parameter Real sysParam.hConExt = 3; parameter Real VAir = 52.5; parameter Real hConExt = 3; parameter Modelica.Units.SI.HeatCapacity heatCapacitor.C = 1000.0*VAir

weberscode commented 1 year ago

I all,

i made my own ThermalZones.RC.FourElements according to yours and then removed the ThermSplitter model for solarGain and internalGain. Then it flattened without changing the type to constant. Perhaps the problem is with the function splitFacVal

weberscode commented 1 year ago

now i tried it with splitFactor={{AArray[1]},{AArray[2]},{AArray[3]}} ./ sum(AArray) and removed only the ThermSplitterSolRad --> still the change from parameter to constant --> i think its only cause of the ThermSplitter model that the compiler thinks this matrix would change the number of states and not only the value so it changes it to constant and with it all the areas and parameters depending on AArray --> thats my final result. What do you think?

weberscode commented 1 year ago

so, ... i think i got the villain ...

dimension must be declared as: final parameter Integer dimension = size(AArray,1)

instead of

final parameter Integer dimension = sum({if A>0 then 1 else 0 for A in AArray})

mlauster commented 1 year ago

I wouldn't wonder, it contains some matrix calculations with the dimensions depending on the size of the inputs vectors.Von meinem/meiner Galaxy gesendet -------- Ursprüngliche Nachricht --------Von: weberscode @.> Datum: 27.10.23 15:20 (GMT+01:00) An: ibpsa/modelica-ibpsa @.> Cc: Subscribed @.***> Betreff: Re: [ibpsa/modelica-ibpsa] Get flat model without constants (Issue #1809) I all, i made my own ThermalZones.RC.FourElements according to yours and then removed the ThermSplitter model for solarGain and internalGain. Then it flattened without changing the type to constant. Perhaps the problem is with the function splitFacVal

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>

mlauster commented 1 year ago

Did you check if it still works for all model variants? The ThermSplitter is also used in the other variants with three, two and maybe even one wall element. I don't recall where the declaration of done, in the zone model or the ThermSplitter.Anyhow, thanks for improving the model! Let me know if I can support with my five year old knowledge.Von meinem/meiner Galaxy gesendet -------- Ursprüngliche Nachricht --------Von: weberscode @.> Datum: 27.10.23 16:13 (GMT+01:00) An: ibpsa/modelica-ibpsa @.> Cc: Subscribed @.***> Betreff: Re: [ibpsa/modelica-ibpsa] Get flat model without constants (Issue #1809) so, ... i think i got the villain ... dimension must be declared as: final parameter Integer dimension = size(AArray,1) instead of final parameter Integer dimension = sum({if A>0 then 1 else 0 for A in AArray})

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>