Layered Composite Calculations - how to perform a loop to calculate the moment for each layer of a composite when the equation changes as each layer is added in?

2 views (last 30 days)
So I am working on layered composites. I have already solved for sigma yy, sigma xx, and sigma xy for each layer. Now I'm trying to determine the moments of each layer which I have only been able to do manually instead of doing a loop for the whole thing which is now necessary as I'm getting into composites with hundreds of layers, not just 9. So if I can get the loop down for this 9 layered composite, hopefully I can manipulate it to work for a hundred layer one.
The sigma yy values for this 9-layered composite are:
sigyy =
25.1209 25.1209 -31.4011 -31.4011 25.1209 -31.4011 -31.4011 25.1209 25.1209
Here are the manual equations I have coded in to solve for the moments of each layer from top to bottom:
M1 = -sigyy(1)*1/2*h0^2;
M2 = -sigyy(1)*3/2*h0^2-sigyy(2)*1/2*h0^2;
M3 = -sigyy(1)*5/2*h0^2-sigyy(2)*3/2*h0^2-sigyy(3)*1/2*h0^2;
M4 = -sigyy(1)*7/2*h0^2-sigyy(2)*5/2*h0^2-sigyy(3)*3/2*h0^2-sigyy(4)*1/2*h0^2;
M5 = -sigyy(1)*9/2*h0^2-sigyy(2)*7/2*h0^2-sigyy(3)*5/2*h0^2-sigyy(4)*3/2*h0^2-sigyy(5)*1/2*h0^2;
M6 = -sigyy(1)*11/2*h0^2-sigyy(2)*9/2*h0^2-sigyy(3)*7/2*h0^2-sigyy(4)*5/2*h0^2-sigyy(5)*3/2*h0^2-sigyy(6)*1/2*h0^2;
M7 = -sigyy(1)*13/2*h0^2-sigyy(2)*11/2*h0^2-sigyy(3)*9/2*h0^2-sigyy(4)*7/2*h0^2-sigyy(5)*5/2*h0^2-sigyy(6)*3/2*h0^2-sigyy(7)*1/2*h0^2;
M8 = -sigyy(1)*15/2*h0^2-sigyy(2)*13/2*h0^2-sigyy(3)*11/2*h0^2-sigyy(4)*9/2*h0^2-sigyy(5)*7/2*h0^2-sigyy(6)*5/2*h0^2-sigyy(7)*3/2*h0^2-sigyy(8)*1/2*h0^2;
M9 = -sigyy(1)*17/2*h0^2-sigyy(2)*15/2*h0^2-sigyy(3)*13/2*h0^2-sigyy(4)*11/2*h0^2-sigyy(5)*9/2*h0^2-sigyy(6)*7/2*h0^2-sigyy(7)*5/2*h0^2-sigyy(8)*3/2*h0^2-sigyy(9)*1/2*h0^2;
This code also works to manually calculate the moments from the top to the bottom:
for i=1:9 % 1 to the number of layers
if (i==1)
M(i)=-sigyy(i)*0.5*h0^2;
end
if (i==2)
M(i)=-sigyy(i)*0.5*h0^2;
Mnew(i)=M(i)-sigyy(i-1)*(0.5+(i-1))*h0^2;
M(i)=Mnew(i);
end
if (i==3)
M(i)=-sigyy(i)*0.5*h0^2;
Mnew(i)=M(i)-sigyy(i-2)*(0.5+(i-1))*h0^2-sigyy(i-1)*(0.5+(i-2))*h0^2;
M(i)=Mnew(i);
end
if (i==4)
M(i)=-sigyy(i)*0.5*h0^2;
Mnew(i)=M(i)-sigyy(i-3)*(0.5+(i-1))*h0^2-sigyy(i-2)*(0.5+(i-2))*h0^2-sigyy(i-1)*(0.5+(i-3))*h0^2;
M(i)=Mnew(i);
end
if (i==5)
M(i)=-sigyy(i)*0.5*h0^2;
Mnew(i)=M(i)-sigyy(i-4)*(0.5+(i-1))*h0^2-sigyy(i-3)*(0.5+(i-2))*h0^2-sigyy(i-2)*(0.5+(i-3))*h0^2-sigyy(i-1)*(0.5+(i-4))*h0^2;
M(i)=Mnew(i);
end
if (i==6)
M(i)=-sigyy(i)*0.5*h0^2;
Mnew(i)=M(i)-sigyy(i-5)*(0.5+(i-1))*h0^2-sigyy(i-4)*(0.5+(i-2))*h0^2-sigyy(i-3)*(0.5+(i-3))*h0^2-sigyy(i-2)*(0.5+(i-4))*h0^2-sigyy(i-1)*(0.5+(i-5))*h0^2;
M(i)=Mnew(i);
end
if (i==7)
M(i)=-sigyy(i)*0.5*h0^2;
Mnew(i)=M(i)-sigyy(i-6)*(0.5+(i-1))*h0^2-sigyy(i-5)*(0.5+(i-2))*h0^2-sigyy(i-4)*(0.5+(i-3))*h0^2-sigyy(i-3)*(0.5+(i-4))*h0^2-sigyy(i-2)*(0.5+(i-5))*h0^2-sigyy(i-1)*(0.5+(i-6))*h0^2;
M(i)=Mnew(i);
end
if (i==8)
M(i)=-sigyy(i)*0.5*h0^2;
Mnew(i)=M(i)-sigyy(i-7)*(0.5+(i-1))*h0^2-sigyy(i-6)*(0.5+(i-2))*h0^2-sigyy(i-5)*(0.5+(i-3))*h0^2-sigyy(i-4)*(0.5+(i-4))*h0^2-sigyy(i-3)*(0.5+(i-5))*h0^2-sigyy(i-2)*(0.5+(i-6))*h0^2-sigyy(i-1)*(0.5+(i-7))*h0^2;
M(i)=Mnew(i);
end
if (i==9)
M(i)=-sigyy(i)*0.5*h0^2;
Mnew(i)=M(i)-sigyy(i-8)*(0.5+(i-1))*h0^2-sigyy(i-7)*(0.5+(i-2))*h0^2-sigyy(i-6)*(0.5+(i-3))*h0^2-sigyy(i-5)*(0.5+(i-4))*h0^2-sigyy(i-4)*(0.5+(i-5))*h0^2-sigyy(i-3)*(0.5+(i-6))*h0^2-sigyy(i-2)*(0.5+(i-7))*h0^2-sigyy(i-1)*(0.5+(i-8))*h0^2;
M(i)=Mnew(i)
end
end
Here are what the moments should come out to be at the very end if the code and loop work (should always be symmetric and come back to zero in the last layer):
M =
-17.1470 -68.5880 -115.7423 -120.0291 -120.0291 -115.7423 -68.5880 -17.1470 0.0000
* Need to have a more concise and simple loop that will do all these calculations in a couple lines of code instead of manually coding each layer in *
Thank you for the help.
  5 Comments

Sign in to comment.

Accepted Answer

Sara Boznik
Sara Boznik on 16 Aug 2020
If you have M(r):
k=2*r-1;
part=0;
mom=0;
for i=1:r
part=-siggy(i)*(k/2)*h0^2
k=k-2;
mom=mom+part
end
  4 Comments
Sara Boznik
Sara Boznik on 16 Aug 2020
Right now I do not see what I did wrong. Maybe we could wait for others (more experienced) to find the mistake.
Sorry, I tried my best.
Good luck.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by