python - FMU FMI simulation, no modification of results when setting certain type of parameter -



python - FMU FMI simulation, no modification of results when setting certain type of parameter -

i developed illustration simple modelica model based on fluid library of msl. connected massflowsource pipe , boundary_pt sink function in image below:

http://www.casimages.com/img.php?i=14061806120359130.png

i generate fmu bundle openmodelica (in mode model-exchange). manage fmu bundle python code below:

import pyfmi, os pyfmi import load_fmu mymodel = load_fmu('pathtofolder\\test3.fmu') res1 = mymodel.simulate() # first simulation m_flow in source set [1] kg/s x = mymodel.get('boundary1.m_flow') # mass flow rate of source y = mymodel.get('pipe.port_a.m_flow') # mass flow rate in pipe print x, y mymodel.set('boundary1.m_flow', 2) alternative = mymodel.simulate_options() option['initialize'] = false # need initialize simulation res2 = mymodel.simulate(options = option) # sec simulation m_flow in source set [2] kg/s x = mymodel.get('boundary1.m_flow') # mass flow rate of source y = mymodel.get('pipe.port_a.m_flow') # mass flow rate in pipe print x, y os.system('pause')

the objective show problem when alter parameter in model, here "m_flow" variable in source component. new set "2" should alter "m_flow" in pipe not. results: in first simulation both "m_flow" gotten "1" , it's normal because model set this. in sec simulation, set parameter "2" in source pipe "m_flow" remain "1" (it should "2"). http://www.casimages.com/img.php?i=140618060905759619.png

the model of fluid source in modelica 1 (only our interesting part):

equation if not use_m_flow_in m_flow_in_internal = m_flow; end if; connect(m_flow_in, m_flow_in_internal);

i think fmu don't consider parameter when in if-condition. me it's problem because need manage fmu , sure if set parameter, simulation utilize new set. how sure fmu/fmi works well? exhaustive list type of parameters can't manage in fmu?

i know parameters alter number of equations can't consider in fmu management (idem variables alter index of daes).

note openmodelica has concept of structural parameters , evaluate=true annotation. example, if parameter used array dimension, might evaluated integer value. uses of parameter utilize evaluated value, if constant.

rather including image of diagram, modelica source code have been easier @ in order find out openmodelica did system.

i suspect parameter evaluated. if generate non-fmu code, inspect modelname_init.xml generated openmodelica , find entry parameter , property isvaluechangeable.

you utilize omedit debug scheme , view initial equation (generate executable including debug information). file->open transformations file, select modelname_info.xml file. search variable tried alter , go initial equation defined it. start-value (set pyfmi) ignored because not needed produce solution.

python modelica openmodelica fmi

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -