# Syntax for specifying boundary condition using dsolve.

3 ビュー (過去 30 日間)
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 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 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 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 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Jonathan 2024 年 6 月 13 日
Thanks very much. Yep it was just a syntax issue for me.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by