Name | Description |
---|---|
interactiveModel | Interactive model |
physicalModel | Physical model |
setParamVar | Model including the when required to change the value of the interactive parameters and input variables |
StateSelection1 | State variables: liquid level |
StateSelection2 | State variables: liquid volume |
model interactiveModel "Interactive model" input Real Iparam[25] "New value of the interactive parameters"; input Real Ivar[2] "New value of the interactive variables"; input Real Istate[8] "New value of the state variables"; input Real CKparam[2] "Trigger the when that reinitializes the value of the interactive parameters"; input Real CKvar[2] "Trigger the when that reinitializes the value of the interactive variables"; input Real CKstate[2] "Trigger the when that reinitializes the value of the state variables"; input Real Enabled[2]; output Real O[16] "Ouput variable"; output Real Release[1] "Release signal"; StateSelection1 SS1( CKparam = CKparam[1], CKvar = CKvar[1], CKstate = CKstate[1]); StateSelection2 SS2( CKparam = CKparam[2], CKvar = CKvar[2], CKstate = CKstate[2]); equation Iparam = SS1.Iparam; Istate = SS1.Istate; Ivar = SS1.Ivar; Iparam = SS2.Iparam; Istate = SS2.Istate; Ivar = SS2.Ivar; Release = {9.0}; O = if Enabled[1] > 0.5 then SS1.O else if Enabled[2] > 0.5 then SS2.O else zeros(size(O, 1)); end interactiveModel;
Type | Name | Default | Description |
---|---|---|---|
Boolean | isState[8] | Vector controlling the state selection |
partial model physicalModel "Physical model" input Real Iparam[25] "New value of the interactive parameters"; input Real Ivar[2] "New value of the interactive variables"; input Real Istate[8] "New value of the state variables"; output Real O[16] "Output vector"; parameter Boolean[8] isState "Vector controlling the state selection"; componentsLIB.tank tank1(hIsState=isState[1], volumeIsState=isState[5]); componentsLIB.tank tank2(hIsState=isState[2], volumeIsState=isState[6]); componentsLIB.tank tank3(hIsState=isState[3], volumeIsState=isState[7]); componentsLIB.tank tank4(hIsState=isState[4], volumeIsState=isState[8]); componentsLIB.sink sink; componentsLIB.pipe pipeT3T1(FIsState=false); componentsLIB.pipe pipeT1Sink(FIsState=false); componentsLIB.pipe pipeT4T2(FIsState=false); componentsLIB.pipe pipeT2Sink(FIsState=false); componentsLIB.pumpTwoWayValve pumpValve1; componentsLIB.pumpTwoWayValve pumpValve2; equation connect(tank1.portBottom, pipeT1Sink.portP); connect(pipeT1Sink.portN, sink.port); connect(tank1.portTop, pumpValve1.port1); connect(tank1.portTop, pipeT3T1.portN); connect(tank2.portBottom, pipeT2Sink.portP); connect(pipeT2Sink.portN, sink.port); connect(tank2.portTop, pumpValve2.port1); connect(tank2.portTop, pipeT4T2.portN); connect(tank3.portBottom, pipeT3T1.portP); connect(tank3.portTop, pumpValve2.port2); connect(tank4.portBottom, pipeT4T2.portP); connect(tank4.portTop, pumpValve1.port2); O = {tank1.h,tank2.h,tank3.h,tank4.h,pipeT3T1.F,pipeT1Sink.F,pipeT4T2. F,pipeT2Sink.F,tank1.volume,tank2.volume,tank3.volume,tank4.volume, -pumpValve1.port1.volFlow, -pumpValve2.port1.volFlow, -pumpValve2.port2.volFlow, -pumpValve1.port2.volFlow}; end physicalModel;
Type | Name | Default | Description |
---|---|---|---|
Boolean | isState[8] | Vector controlling the state selection |
model setParamVar "Model including the when required to change the value of the interactive parameters and input variables" extends physicalModel; Real CKparam "Trigger the when that reinitializes the value of the interactive parameters"; Real CKvar "Trigger the when that reinitializes the value of the interactive variables"; protected Boolean CKparamIs0( start = true, fixed=true); Boolean CKvarIs0( start = true, fixed=true); equation when CKparam > 0.5 and pre(CKparamIs0) or CKparam < 0.5 and not pre(CKparamIs0) then CKparamIs0 = CKparam < 0.5; reinit(pumpValve1.gamma, Iparam[1]); reinit(pumpValve1.k, Iparam[2]); reinit(pumpValve2.gamma, Iparam[3]); reinit(pumpValve2.k, Iparam[4]); reinit(tank1.tankSection, Iparam[5]); reinit(tank2.tankSection, Iparam[6]); reinit(tank3.tankSection, Iparam[7]); reinit(tank4.tankSection, Iparam[8]); reinit(pipeT3T1.a, Iparam[9]); reinit(pipeT1Sink.a, Iparam[10]); reinit(pipeT4T2.a, Iparam[11]); reinit(pipeT2Sink.a, Iparam[12]); reinit(tank1.alfa1, Iparam[13]); reinit(tank2.alfa1, Iparam[14]); reinit(tank3.alfa1, Iparam[15]); reinit(tank4.alfa1, Iparam[16]); reinit(tank1.alfa2, Iparam[17]); reinit(tank2.alfa2, Iparam[18]); reinit(tank3.alfa2, Iparam[19]); reinit(tank4.alfa2, Iparam[20]); reinit(tank1.beta, Iparam[21]); reinit(tank2.beta, Iparam[22]); reinit(tank3.beta, Iparam[23]); reinit(tank4.beta, Iparam[24]); tank1.generateEvents = Iparam[25] > 0.5; tank2.generateEvents = Iparam[25] > 0.5; tank3.generateEvents = Iparam[25] > 0.5; tank4.generateEvents = Iparam[25] > 0.5; end when; when CKvar > 0.5 and pre(CKvarIs0) or CKvar < 0.5 and not pre(CKvarIs0) then CKvarIs0 = CKvar < 0.5; reinit(pumpValve1.v, Ivar[1]); reinit(pumpValve2.v, Ivar[2]); end when; end setParamVar;
Type | Name | Default | Description |
---|---|---|---|
Boolean | isState[8] | Vector controlling the state selection |
model StateSelection1 "State variables: liquid level" extends setParamVar(isState={true,true,true,true,false,false,false,false}); Real CKstate "Trigger the when that reinitializes the value of the state variables"; protected Boolean CKstateIs0( start = true, fixed=true); equation when CKstate > 0.5 and pre(CKstateIs0) or CKstate < 0.5 and not pre(CKstateIs0) then CKstateIs0 = CKstate < 0.5; reinit(tank1.h, Istate[1]); reinit(tank2.h, Istate[2]); reinit(tank3.h, Istate[3]); reinit(tank4.h, Istate[4]); end when; end StateSelection1;
Type | Name | Default | Description |
---|---|---|---|
Boolean | isState[8] | Vector controlling the state selection |
model StateSelection2 "State variables: liquid volume" extends setParamVar(isState={false,false,false,false,true,true,true,true}); Real CKstate; protected Boolean CKstateIs0( start = true, fixed=true); equation when CKstate > 0.5 and pre(CKstateIs0) or CKstate < 0.5 and not pre(CKstateIs0) then CKstateIs0 = CKstate < 0.5; reinit(tank1.volume, Istate[5]); reinit(tank2.volume, Istate[6]); reinit(tank3.volume, Istate[7]); reinit(tank4.volume, Istate[8]); end when; end StateSelection2;