I
I
Igor2015-11-21 21:41:08
Python
Igor, 2015-11-21 21:41:08

Is it possible to vary constants in integration?

I have a small program that integrates an equation:
Is it possible to set a condition so that when a certain value is exceeded, the constants in the equation change?

from scipy.integrate import odeint
from numpy import linspace
from matplotlib import pyplot
def epid(y, t):
    k = 0.00003
    if y >= 100:
        L = 5
    L = 250000
    return k*y*(L-y)
t = linspace(0, 12, 61)
y = odeint(epid, 250, t)
pyplot.plot(t, y)
pyplot.show()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
GavriKos, 2015-11-21
@ElMigele

Is it possible to set such a condition that when a certain value is exceeded, the constants in the equation change

You seem to have such code, only it is written incorrectly. Move L = 250000 above if, or place it below else. And that turns out your if does nothing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question