Clear Filters
Clear Filters

Syntax for specifying boundary condition using dsolve.

6 views (last 30 days)
I am working on a beam bending/deflection problem. The boundary conditions I need to satisfy are...
  • Displacement at x = 0 is 0
  • Slope at x = 0 is 0
  • Displacement at x = L is 0
  • Moment at x = L is 0
The code I have is below. The issue I am having is specifying the moment to be zero at x=L (syntax).
syms I E L f x u0(x)
% initial equation
eq1 = diff(E*I*diff(u0,x,2),x,2) + f == 0
% gen. sol.
eq2 = dsolve(eq1)
% part. sol.
Du0 = diff(u0,x,1); DDu0 = diff(u0,x,2);
bc1 = u0(0) == 0 % Displacement at x = 0 is 0
bc2 = Du0(0) == 0 % Slope at x = 0 is 0
bc3 = u0(L) == 0 % Displacement at x = L is 0
bc4 = DDu0(x==L) == 0 % Moment at x = L is 0
eq3 = dsolve( eq1 , [ bc1, bc2 , bc3 , bc4 ] )
  2 Comments
Torsten
Torsten on 13 Jun 2024
Edited: Torsten on 13 Jun 2024
It's strange how the corrected form of bc4 is displayed. Why is L the differentiation variable and not x as in bc2 ?
syms I E L f x u0(x)
% initial equation
eq1 = diff(E*I*diff(u0,x,2),x,2) + f == 0;
% gen. sol.
eq2 = dsolve(eq1);
% part. sol.
Du0 = diff(u0,x,1); DDu0 = diff(u0,x,2);
bc1 = u0(0) == 0 ; % Displacement at x = 0 is 0
bc2 = Du0(0) == 0 % Slope at x = 0 is 0
bc2 = 
bc3 = u0(L) == 0 ; % Displacement at x = L is 0
bc4 = DDu0(L) == 0 % Moment at x = L is 0
bc4 = 
eq3 = dsolve( eq1 , [ bc1, bc2 , bc3 , bc4 ] );
Jonathan
Jonathan on 13 Jun 2024
Yes that is what initially confused me. But it yields the equivalent solution.
For instance, if you specifiy L = 1 and solve both ways you get the same result...
syms I E L f x u0(x)
% initial equation
eq1 = diff(E*I*diff(u0,x,2),x,2) + fv == 0
% gen. sol.
eq2 = dsolve(eq1)
% part. sol.
Du0 = diff(u0,x,1); DDu0 = diff(u0,x,2);
bc1 = u0(0) == 0 % Displacement at x = 0 is 0
bc2 = Du0(0) == 0 % Slope at x = 0 is 0
bc3 = u0(L) == 0 % Displacement at x = L is 0
bc4 = DDu0(L) == 0 % Moment at x = L is 0
eq3 = dsolve(eq1,bc1 , bc2 , bc3 , bc4)
% solve at x=0
u0_midpoint = vpa( subs( eq3 , [ x I L] , [ 0.5 Iv Lv ] ) , 3 )
% part. sol.
Du0 = diff(u0,x,1); DDu0 = diff(u0,x,2);
bc1 = u0(0) == 0 % Displacement at x = 0 is 0
bc2 = Du0(0) == 0 % Slope at x = 0 is 0
bc3 = u0(1) == 0 % Displacement at x = L is 0
bc4 = DDu0(1) == 0 % Moment at x = L is 0
eq3 = dsolve(eq1,bc1 , bc2 , bc3 , bc4)
% solve at x=0
u0_midpoint = vpa( subs( eq3 , [ x I] , [ 0.5 Iv ] ) , 3 )

Sign in to comment.

Accepted Answer

John D'Errico
John D'Errico on 13 Jun 2024
Edited: John D'Errico on 13 Jun 2024
Your beam is fixed in position at the left end, as is the slope at that point.
At the right end, you have fixed the location, but you want a zero bending moment. And you already know to do that, by setting the second derivative to zero there.
syms I E L f x u0(x)
% initial equation
eq1 = diff(E*I*diff(u0,x,2),x,2) + f == 0
eq1(x) = 
An order 4 ODE, so we need 4 conditions to solve.
Du0 = diff(u0,x,1); DDu0 = diff(u0,x,2);
xsol(x) = dsolve(eq1,u0(0) == 0, Du0(0) == 0, u0(L) == 0, DDu0(L) == 0)
xsol = 
This beam is one with a clamp at 0, the left end, and pinned at X==L, so it will have a zero bending moment there. This solution should have those properties. But that looks like effectively what you wrote...
Ah, looking at your code, you wrote this:
bc4 = DDu0(x==L) == 0 % Moment at x = L is 0
and that is clearly wrong. This would have worked instead:
bc4 = DDu0(L) == 0 % Moment at x = L is 0
And you actually knew how to do that! DDu0 is just a function of x, like u0 and Du0.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!