Syntax for specifying boundary condition using dsolve.

조회 수: 10 (최근 30일)
Jonathan
Jonathan 2024년 6월 13일
댓글: Jonathan 2024년 6월 13일
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
Torsten
Torsten 2024년 6월 13일
편집: Torsten 2024년 6월 13일
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 2024년 6월 13일
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 )

댓글을 달려면 로그인하십시오.

채택된 답변

John D'Errico
John D'Errico 2024년 6월 13일
편집: John D'Errico 2024년 6월 13일
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.
  댓글 수: 1
Jonathan
Jonathan 2024년 6월 13일
Thanks very much. Yep it was just a syntax issue for me.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by