Q:

Loop over time and over list elements with python -- one-dimensional lake temperature model simulation

I want to build a one-dimensional model simulation of water temperature in a lake. 
The lake is divided into layers, each layer temperature value is stored as an element of a list.  The simulation is performed over time.  I have to change each element of the list, or certain sequences of the list using functions and algorithms in each time step.  
I can´t find the best way to do the main loop :
Loop over time and over list elements and be able to use the value of a particular element of the list obtained in the previous time step. 
This is just an example:
Time step 0: list”0”=[10,10,10]

Time step 1: list”1”=[  list”0”[0]+def change(n) ,  list”0”[1]+ 1   , list”0”[2]+3  ]

Time step 2: list”2” ”=[  list”1”[0]+ def change(t),  list”1”[1]+ 2   , list”1”[2]+2  ]

Time step 3: list”3=[  list”2”[0]+ def change(r),  list”2”[1]+ 1   , list”2”[2]+4  ]

Initially I thought in a list of lists:
Each list element corresponds to a time step, this way I can access the previous time step and use the previous value (Is this a good approach?): 
Time step 0 Time step 1 Time step 2 Time step 3 
List=[[10,10,10],[ 12,13,14],[ 12,14,12],[ 11,13,11]] 

Where can I read something to help me or some script examples?  Thank you. 

A:

The list of lists is ok.  You only need to access the last element each time (easy with negative indexing) and you keep an ordered sequence of steps.  You can do the following.  For example:
values = [[10, 10, 10]]
# condition would be the one that makes the simulation stop (number of steps, time...)
while condition:
   prev = values[-1]
   values.append([function1(prev[0]),
                  function2(prev[1]),
                  function3(prev[2]))
   # update the condition, if needed

A:

Let me first try to rephrase your problem statement
Listn = [x+f(x):x ∈ Listn-1 , f ∈ fnlist]
where
fnlist=[f,g,h]
so in python terms that boils down to
funclist = [f,g,h]
somelist+=[[x+f(x) for x,f in zip(somelist[-1],funclist)]]

on the other hand, if the same function is applied to all the values of the list like
Listn = [x+f(x):x ∈ Listn-1]
somelist+=[[x+f(x) for x in somelist[-1]]]

finally if a singleton  function is dependent on time slice, at a certain increment timedelta 
Listn =  [x+f(t):x ∈ Listn-1 , t ∈ T]
where
 T = [t,t+∆t,t+2∆t,......]
then first you need to generate the time sequence and you can use itertools.count for that purpose like
itertools.count(someStartTime,delta)

then
somelist+=[[x+f(t) for x,t in zip(somelist[-1],itertools.count(someStartTime,delta))]]

Note: f,g,h are python functions which can be defined as
def f(n):
    ........
    return .....

