Пример #1
0
def solver_scaled(beta, T, dt, theta=0.5):
    """
    Solve u'=-u+1, u(0)=beta for (0,T]
    with step dt and theta method.
    """
    print 'Computing the numerical solution'
    return solver_unscaled(
        I=beta, a=lambda t: 1, b=lambda t: 1,
        T=T, dt=dt, theta=theta)
Пример #2
0
def solver_scaled(gamma, T, dt, theta=0.5):
    """
    Solve u'=-a*u, u(0)=1 for (0,T] with step dt and theta method.
    a=1 for t < gamma and 2 for t > gamma.
    """
    print 'Computing the numerical solution'
    return solver_unscaled(
        I=1, a=lambda t: 1 if t < gamma else 5,
        b=lambda t: 0, T=T, dt=dt, theta=theta)
Пример #3
0
def solver_scaled(alpha, beta, t_stop, dt, theta=0.5):
    """
    Solve T' = -T + 1 + alha*sin(beta*t), T(0)=0
    for (0,T] with step dt and theta method.
    """
    print 'Computing the numerical solution'
    return solver_unscaled(
        I=0, a=lambda t: 1,
        b=lambda t: 1 + alpha*np.sin(beta*t),
        T=t_stop, dt=dt, theta=theta)
Пример #4
0
def solver_scaled(beta, T, dt, theta=0.5):
    """
    Solve u'=-u+1, u(0)=beta for (0,T]
    with step dt and theta method.
    """
    print 'Computing the numerical solution'
    return solver_unscaled(I=beta,
                           a=lambda t: 1,
                           b=lambda t: 1,
                           T=T,
                           dt=dt,
                           theta=theta)