Re: [Pyarie-users] simultaneous solutions
Status: Pre-Alpha
Brought to you by:
kuthu
|
From: Nicolas P. <nic...@ya...> - 2005-10-13 00:46:55
|
Hello John,
I seems that I haven't made myself clear( I told you that my english
was not so good ;-) ).
My concern was that I was looking for a convenient way for our future
users to design the system.
In a procedural world, users have to take care and be careful of how
they place their function calls : C depends of A and B, so I have to
call C _after_ calling A and B, and so on... It leads to many hassles...
In the system you sent, on line 44 ("# MUST BE IN PROPER ORDER"), it
appears that you also have to design it while having in mind who has to
be called first.
In theory, I think that you can deduce the correct tree call if you know
on which systems each system has influence.
If I give you A,B and C and told you that :
1) A had effect on C
2) B had effect on C
You'll deduce that you have to call A and B, before C (I implicitly
assume that every system has access to every state variables from
previous step).
So if they have a complex model, users only have to concentrate on local
actions, and let the program compute if they made an error and got an
algebraical loop :
1) A had effet on C
2) B had effet on C
3) C had effect on A
It seems that SimPy has somehow this kind of algorithm to deduce a tree
call from such informations, or am I mistaken ?
For instance, we can have a cannon ball simulation with only at first
the earth system (gravity) and the ball.
Then come another user, who want to add atmosphere friction to this
model without having to modify too much the model. All he had to do is
to declare that its Atmosphere system has effect on the ball.
Hope that you will understand what I'm trying to say...
Regards,
*********** REPLY SEPARATOR ***********
On Wed, 12 Oct 2005 10:01:53 -0700, John Pennington Metta
<pen...@en...> wrote :
> Nicolas,
>
> This is already functional, it's just not "hooked up" in the model you
> have.
>
> I'll try to explain and you tell me if this is not what you are
> seeking. Note: I've renamed the methods, so instead of
> nitrogenBacteria() and nitrogenCycling() in testmodel.py, think of
> them as System() (as in the system of equations) and Model() (as in
> what might hold multiple systems).
>
> The simple case is that at a given timestep, the SimPy iterate()
> (within the model class) function calls the step() method of the
> chosen integrator (runge-kutta, adaptive, etc). The step method
> requires 4 arguments: an array of the governing system (the
> equations), array of the current state variable values, the time
> (SimPy.now()) and the timestep.
>
> The step() method then calls each function in a FOR loop and
> calculates a new state variable value at t given the array of state
> variables that has been calculated at time t-1 (which was passed to
> it as stated above). Since the governing equations can be anything,
> and have access to the entire array of state variables, any equation
> has full access to the values calculated at the previous timestep.
> This means, using your example that stateC could be calculated for
> time t with values for stateA and stateB that were calculated at time
> t-1.
>
> Now, as I understand it, you wish to calculate stateC at time t with
> values from stateA and stateB that were calculated at time t. This, or
>
> you wish to mix, using some values from the previous timestep and some
>
> from the current calculations. Is this correct?
>
> I've attached a new testmodel.py file to illustrate this. It's a real
> simple concept in theory. Basically, you create a list within System
> (cur_state) which holds the values at time t. You can access these
> values from within each function as you see fit (see example state
> functions). The list is empty in Model because it is populated in
> System by copying in the initial conditions. It's important to use
> Python's copy module, so you copy the VALUES and not the REFERENCES
> into the cur_state list.
>
> I don't know if this model will run as is, but it should be a good
> enough example to illustrate how to do what you need, assuming I
> understand correctly.
>
> Your English is perfectly fine. I didn't realize you were a
> francophone until you said that and I looked at your email.
>
> Cheers,
> -J
>
> Nicolas Pernetty wrote:
>
> > For instance, let's say we have a closed system : A and B have
> > effects on C and C has effects on B.
> > In a procedural language, I'll do the loop like this :
> >
> > 10:
> > computeA(stateA, outA)
> > computeB(stateB, outC, outB)
> > computeC(stateC, outA, outB, outC)
> > goto 10
> >
> > In reality we can have a much more complex tree, so do we have to
> > somehow design a solver which deduce the tree call from the
> > informations or do we have to input the tree as well ? I think that
> > somehow it is already solved in SimPy...
>
|