Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: LS 30B-2 S19
Views: 260

Dictionary

When we want to save multiple variables, we use "List"

[variable_1, variable_2,........,variable_k]

Problem: We need to know the "Index" of the data

Can we storage the data with some description?

# this is an example for midterm score midDic = {'John':100,'Jack':70,'Peter':88,'Jane':66} midDic['John']
100

Delay Differential Equations

Recall Homework Exercise 4.2.4

What does this mean?

If I want to know Y'(10), by given you the Y's history.

Now let's solve it

Function we are going to use!!

sol=dde_solve(equation, statevar,delayedvars, history, tmax, timestep)
Y = var('Y') Y_d = var('Y_d') Y_2d = var('Y_2d') t = var('t') delayvar_dic = {'Y_2d':2,'Y_d':1} time = srange(0,5,0.01) sol = dde_solve(2*Y_2d^3+2*Y_d^2-8*Y,statevar=Y,delayedvars=delayvar_dic,history=1,tmax=5,timestep=0.01) fig = list_plot(zip(time,sol),plotjoined=True) show(fig)

Steps to run simulation with time-delay

  • Generate individual symbolic variables for state and delay

  • Use a dictionary to connect delay time with time-delay state variables

  • Give a function describes the states before t = 0

  • Give total simulation time and time step

Oscillation

Sigmoid Function

G = var('G') fig1 = plot(1/(1+G^10),(G,0.001,5),legend_label='Negative Sigmoid') fig2 = plot(G^10/(1+G^10),(G,0.001,5),color='red',legend_label='Positive Sigmoid') show(fig1+fig2)

How to cause oscillation?

  • Too small-> Increase, Too big -> Decrease

  • Will not reach stable equilibrium points on the limit cycle

What will happen if Mackey-Glass model has no delay?

Vmax = 80 L = 6 a = 0.2 n = 8 h = 400 x = var('x') t = srange(0,2,0.01) sol = desolve_odeint(L-Vmax*x^n/(h+x^n)*a*x,ics = 0.5,dvars = x,times=t) fig1 = list_plot(zip(t,sol),plotjoined = True,color = 'red') sol = desolve_odeint(L-Vmax*x^n/(h+x^n)*a*x,ics = 5,dvars = x,times=t) fig2 = list_plot(zip(t,sol),plotjoined = True,color = 'blue') fig1+fig2