Re: [daetools-users] Howto: discrete signal?
Object-oriented equation-based modelling and optimisation software
Brought to you by:
ciroki
|
From: StUstD <st...@gm...> - 2018-03-09 09:52:05
|
Hi Dragan: Thanks, that works! 'itau' is discretely incremented event with ON_CONDITION( Time()==itau, ..., eventTolerance=0.0 ). However, 1) I've not been able to eliminate a second equation: DAETools wants (understandably) an equal number of equations as variables... 2) Expanding the problem, I have no success in trying to discretely update 'tau' at the condition with a daeParameter. See file attached. Regards, Henk On Thu, Mar 8, 2018 at 5:19 PM, Dragan Nikolic <dra...@gm...> wrote: > Hi Henk, > > It's just a typo, the argument of ON_CONDITION function should be > switchToStates not switchToState. It works well.then. > > Also, you do not need to add a separate differential equation. You can > just set: > > def SetUpVariables(self): > self.m.itau.AssignValue(0.0) > as it is in the attached file. But, it depends what do you need itau for. > > Cheers > Dragan > > > On 08/03/18 14:34, StUstD wrote: > >> Hi Dragan: >> >> Please find attached the modified "whats_the_time.py" example that >> includes and tests the discrete-time conditional you suggested. >> >> Find below the simulation error message I obtain. Anything wrong in my >> specification? >> >> Regards, >> -- Henk >> >> *********************************************************************** >> >> Version: 1.8.0 >> >> Copyright: Dragan Nikolic, 2017 >> >> Homepage: http://www.daetools.com >> >> @ @ >> >> @ @@@@@ @@@@@ @@@@@ @@@@@ @@@@@ @ @@@@@ >> >> @@@@@@ @ @ @ @ @ @ @ @ @ @ >> >> @ @ @@@@@@ @@@@@@ @ @ @ @ @ @ @@@@@ >> >> @ @ @ @ @ @ @ @ @ @ @ @ >> >> @@@@@@ @@@@@@ @@@@@ @@@ @@@@@ @@@@@ @@@@ @@@@@ >> >> *********************************************************************** >> >> DAE Tools is free software: you can redistribute it and/or modify >> >> it under the terms of the GNU General Public License version 3 >> >> as published by the Free Software Foundation. >> >> DAE Tools is distributed in the hope that it will be useful, >> >> but WITHOUT ANY WARRANTY; without even the implied warranty of >> >> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU >> >> General Public License for more details. >> >> You should have received a copy of the GNU General Public License >> >> along with this program. If not, see <http://www.gnu.org/licenses>. >> >> *********************************************************************** >> >> Creating the system... >> >> File "/home/hjansen/workspace/gitspace/Contryx/projects/enterpris >> e/CxSim/inst/python/3/lib/python3.6/site-packages/daetoo >> ls-1.8.0-py3.6-linux-x86_64.egg/daetools/dae_simulator/simulator.py", >> line 276, in run >> >> self.simulation.Initialize(self.daesolver, self.datareporter, self.log) >> >> File "/home/hjansen/workspace/gitspace/Contryx/projects/explorati >> on/00-TaE-Python/src/simulation/daetools/discrete_signal_trial/discrete_signal_01.py", >> line 146, in DeclareEquations >> >> eventTolerance = 0.00001) >> >> Python argument types in >> >> daeModel.ON_CONDITION(modTutorial, daeCondition) >> >> did not match C++ signature: >> >> ON_CONDITION(dae::core::daeModel {lvalue} self, dae::core::daeCondition >> condition, boost::python::list switchToStates=[], boost::python::list >> setVariableValues=[], boost::python::list triggerEvents=[], >> boost::python::list userDefinedActions=[], double eventTolerance=0.0) >> >> >> >> On Wed, Mar 7, 2018 at 2:49 PM, Dragan Nikolic <dra...@gm... >> <mailto:dra...@gm...>> wrote: >> >> Hi, >> >> Well, it is a bit difficult because of the way the equation-based >> systems are solved numerically but it might work. >> >> If you wish to change a model variable you can use >> daeModel.ON_CONDITION function (have a look on tutorials 5, 14). >> If iT is a model variable, you can put the following in the >> function DeclareEquations: >> >> self.ON_CONDITION(Time() > iT, switchToStates = [], >> setVariableValues = [iT, iT+1], # >> here you may need to use self.iT() >> triggerEvents = [], >> userDefinedActions = []) >> >> But, you need to be careful here: your condition Time() > iT will >> be triggered EVERY time step once the simulation time becomes >> greater than iT. However, you change it each time the condition is >> satisfied, so it might work. Please check and let me know, I am >> curious if it works or not. >> >> Cheers >> Dragan >> >> >> >> On 07/03/18 11:45, StUstD wrote: >> >> How is it possible to create a discrete-time signal, e.g. a >> counter (in pseudo code): >> >> initial Time = 0 >> iT = 1 # counter >> >> if Time() > iT: >> iT += 1 >> endif >> >> Thanks. >> >> >> >> ------------------------------------------------------------ >> ------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> >> >> _______________________________________________ >> daetools-users mailing list >> dae...@li... >> <mailto:dae...@li...> >> https://lists.sourceforge.net/lists/listinfo/daetools-users >> <https://lists.sourceforge.net/lists/listinfo/daetools-users> >> >> >> >> > |