Path dependent loop in Matlab
2 views (last 30 days)
Show older comments
Hi,
Right now I am doing riser-soil interaction model. The interaction between them is path-dependent which means if the response follow certain conditions it will follow certain path. Right now, I manage it by using for-loop but it will become cumbersome if the interaction become more complex. My question is there any efficient method to simulate path-dependent process within matlab? I thought of using while-loop but I am not so sure.
Here is my present code:
%SOIL MODEL
clear all
clc
%Parameter
fsuc=0.203;
w=0.433;
phi=0.661;
S0=800;
Sg=0;
k0=660*S0;
T=10; %Period of motion [s]
w0=2*pi/T; %Frequency of motion [rad/s];
D=0.2032; %Pipe diameter [m]
%Motion Definition
t=0:0.05:100; %Time definition
Y1=100; %Dummy/Initial Backbone point
Y2=80;
Y3=60;
I=100;
for i=1:length(t)
y(i)=0.06*sin(w0*t(i)); %Motion definition
%BACKBONE CURVE (INITIAL PENETRATION)
P(i)=bbone(y(i),D,S0,Sg);
if i>2
if (y(i)<y(i-1)&&y(i-1)>y(i-2))
Y1=y(i-1); %Backbone Point
I=i-1;
P1=bbone(Y1,D,S0,Sg);
Y2=Y1-(((1+w)*P1/k0)*((1+fsuc)/(w-fsuc)));
Y3=Y2-phi*(Y1-Y2);
P2=-fsuc*P1;
end
if(y(i)<Y1 && y(i)<y(i-1) && y(i)>Y2) %Point 1 to Point 2
P(i)=P12(y(i),Y1,P1,k0,w,-1);
elseif (y(i)<Y1 && y(i)>y(i-1) && y(i)>Y2)
Yrb=y(i);
Prb=P12(Yrb,Y1,P1,k0,w,-1);
P(i)=P12(y(i),Yrb,Prb,k0,w,1);
end
if (y(i)<Y2 && y(i)>Y3 && y(i)<y(i-1)) %Point 2 to Point 3
P(i)=P23(y(i),Y2,Y3,P2);
elseif (y(i)<Y2 && y(i)>Y3 && y(i)>y(i-1))
Yrb=y(i);
Prb=P23(y(i),Y2,Y3,P2);
P(i)=P31r(y,Y1,Yrb,P1,Prb);
end
if (y(i)<Y3 && i>I) %Full separation
P(i)=0;
end
if (y(i)>Y3 && y(i)>y(i-1) && y(i)<=Y1) %Point 3 to Point 1
P(i)=P31(y(i),Y1,Y3,P1);
end
if (y(i)>Y1 && y(i)>y(i-1))
P(i)=bbone(y(i),D,S0,Sg);
end
end
end
0 Comments
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!