Adrian Pop <[EMAIL PROTECTED]> writes: > Hi Dieter, > > To ensure that we catch all the events at startup > the solver takes a very tiny step. We also save the > values of variables at time 0 to have them for pre(v). > I think this is the cause for double zero time, but > I'm not 100% sure.
Neither am I 8-), the only thing I know is that in the case below it happens only when there is an if statement in the equation section, when you replace this line with the line below the fact does not happen. ------------------------------------------------------------ connector Port Real pressure; flow Real flowrate; end Port; partial model TwoPorts Port inPort, outPort; equation inPort.flowrate + outPort.flowrate = 0; end TwoPorts; model Pipe extends TwoPorts; parameter Real a = .5; equation inPort.pressure = inPort.flowrate * a; end Pipe; model Pump extends TwoPorts; Real q; Real n( start=0); equation der( n) = 1; q = n - outPort.pressure; inPort.flowrate = if q > 0 then q else 0; // inPort.flowrate = q; end Pump; model Ambience Port port; equation port.pressure = 0; end Ambience; model Test Pump pu; Pipe pi; Ambience am1, am2; equation connect( am1.port, pu.inPort); connect( pu.outPort, pi.inPort); connect( pi.outPort, am2.port); end Test; // simulate( Test) > > Cheers, > Adrian Pop/ > > dieter wrote: >> Hi, >> >> when I'm using the "time" variable with an "if" clause I'm getting >> strange date sets. All sets have two rows with zero time, as in the >> following: >> >> DataSet: time >> 0, 0 >> 0, 0 >> 2.220446049250313e-13, 2.220446049250313e-13 >> 0.002, 0.002 >> 0.004, 0.004 >> 0.006, 0.006 >> 0.008, 0.008 >> 0.01, 0.01 >> 0.012, 0.012 >> ... >> >> DataSet: pi.inPort.pressure >> 0, 8.987170080912859e-71 >> 0, 1.407479094429326e-112 >> 2.220446049250313e-13, -1.002262231102861e-165 >> 0.002, -3.504384971839359e-176 >> 0.004, -5.630042739254032e-176 >> 0.006, -7.755700506668704e-176 >> ... >> >> it looks as if the *input* variable time has changed somehow! >> (I'm using svn:3603) >> >> Dieter >> >> ------------------------------------------------------------ >> >> connector Port >> Real pressure; >> flow Real flowrate; >> end Port; >> >> // // record with innner/outer not possible // class Fluid >> "Water is the default" // parameter Real density = 1; >> // parameter Real viscosity = 1; >> // end Fluid; >> >> partial model TwoPorts >> // outer parameter Fluid fluid; >> Port inPort, outPort; >> equation >> inPort.flowrate + outPort.flowrate = 0; >> end TwoPorts; >> >> model Pipe >> extends TwoPorts; >> parameter Real a = .5; >> equation >> inPort.pressure = inPort.flowrate * a; >> end Pipe; >> >> model Pump >> extends TwoPorts; >> Real q; >> equation >> q = time - outPort.pressure - .1; >> inPort.flowrate = if q > 0 then q else 0; >> end Pump; >> >> model Ambience >> Port port; >> equation >> port.pressure = 0; >> end Ambience; >> >> model Test >> // inner parameter Fluid fluid; >> Pump pu; >> Pipe pi; >> Ambience am1, am2; >> equation >> connect( am1.port, pu.inPort); >> connect( pu.outPort, pi.inPort); >> connect( pi.outPort, am2.port); >> end Test; >> >> // simulate( Test)
