Search code examples
python-3.xdifferential-equations

Euler beam, solving differential equation in python


I must solve the Euler Bernoulli differential beam equation which is:

w’’’’(x) = q(x)

and boundary conditions:

w(0) = w(l) = 0 

and

w′′(0) = w′′(l) = 0

The beam is as shown on the picture below:

beam

The continious force q is 2N/mm.

I have to use shooting method and scipy.integrate.odeint() func.

I can't even manage to start as i do not understand how to write the differential equation as a system of equation

Can someone who understands solving of differential equations with boundary conditions in python please help!

Thanks :)


Solution

  • You need to transform the ODE into a first order system, setting u0=w one possible and usually used system is

        u0'=u1,
        u1'=u2,
        u2'=u3,
        u3'=q(x)
    

    This can be implemented as

    def ODEfunc(u,x): return [ u[1], u[2], u[3], q(x) ]
    

    Then make a function that shoots with experimental initial conditions and returns the components of the second boundary condition

    def shoot(u01, u03): return odeint(ODEfunc, [0, u01, 0, u03], [0, l])[-1,[0,2]]
    

    Now you have a function of two variables with two components and you need to solve this 2x2 system with the usual methods. As the system is linear, the shooting function is linear as well and you only need to find the coefficients and solve the resulting linear system.