import math
import numpy as np
from pylab import plot, show
def model():
Dt = 1
time_step = 50
#initializing the connection weights
w1 = 1
#initializing parameter values for the alogistic function
steepness_SS_a=1
speed_SS_a=1
threshold_SS_a=1
WS_a=1
SS_a=0
new_SS_a=np.array([SS_a])
t=0.0
timesteps=[t]
while t<30.0:
new = SS_a + speed_SS_a * (
(
(1/(1+math.exp(steepness_SS_a * (w1 * WS_a  threshold_SS_a))))

(1/(1+math.exp(steepness_SS_a *threshold_SS_a)))
)
*
(1+math.exp(steepness_SS_a*threshold_SS_a))

SS_a
)
new_SS_a = np.append(new_SS_a,new)
SS_a=new
t = t + Dt
timesteps.append(t)
print( timesteps )
plot(new_SS_a)
show()
model()
for i in range (30)
SS_a[i+1] = SS_a[i]+ speedfactor*(…..  SS_a(i))*Dt
as you want to put in a list a new value that depend in the previous value put there, you can do it like in this example
result=[0] #we put the initial value in the list
for _ in range(30): # the _ is to signal that we don use that value
result.append( 10 + result[1] ) # negative indices access the element in reverse order, 1 is the last, 2 is the previous to that etc
print(result)
with append we add a element to the end of the list
so in your code that is
...
def model():
...
SS_a = [0]
for _ in range(30):
SS_a.append( SS_a[1]+ speedfactor*(...  SS_a[1])*Dt )
...
plot(SS_a)
show()
you can even make your model more flexible by using arguments and default values, that way if you want to make some change just change how you call the model and not your code, for example like this
import math
#import numpy as np
from pylab import plot, show
def model(Dt=1, time_step = 50, w1 = 1, steepness_SS_a=1,
speed_SS_a=1, threshold_SS_a=1, WS_a=1, SS_a=0,
t=0, t_final=30):
result = [SS_a]
timesteps =[]
for ti in range(t,t_final+1,Dt):
result.append( ... ) #< put here your complicate formula
timesteps.append(ti)
print( timesteps )
plot(result)
show()
#return result
model()
with all those default values we preserve the original behavior, and if we want to do only a minor change like run that model until time 40 instead of 30 we simple call it as model(t_final=40)
, you can also put a return of result
so you can do some other manipulation later on, and we can also put a doct text to remember what each thing is in a easy way, like this
def model(Dt=1, time_step = 50, w1 = 1, steepness_SS_a=1,
speed_SS_a=1, threshold_SS_a=1, WS_a=1, SS_a=0,
t=0, t_final=30):
"""This is my model of ...
where
Dt: ...
time_step: ...
w1: ...
steepness_SS_a: ...
speed_SS_a: ...
threshold_SS_a: ...
WS_a: ...
SS_a: ...
t: initial time
t_final: final time
"""
...
and that we tell you a nice message that explain the model and how to used it is you call help on it help(model)