Skip to main content

STIFFNESS OF BENDING STRINGS


## A 'realistic', 'non-elastic' string, which responses to any
## bending and has stifness. This script takes in the previous
## and the present profiles and iterates to find
## the profile in the next time step. The ratio 'r' is not 1
## like in the 'non-realistic' string since the speed of the wave
## always less than the speed of the string it should be less than 1
## for best and most stable solution
##constants
dx=1e-2 ## Spatial increment (m)
L=2 ## Length of the string (m)
M=L/dx ## Dimensionless partition
r=0.25 ## Famous dimensionless ratio
E=1e-4 ## Dimensionless stiffnes
x=-1:dx:1;
l=length(x);
x0=0.5;
k=1e2;
## Set up the initial profile
y=initial_profile(x,x0,k);
plot(x,y)
pause
## Impose the time boundary condition
ynow=y;
yprev=y;
ynow(1)=ynow(2)=0
Nsteps=2000;
for n=3:Nsteps
ynow(Nsteps-1)=ynow(Nsteps-2)=0;
ynext=propagate_stiff(ynow,yprev,r);
plot(x,ynext,';;')
axis([-1.05,1.05,-1.1,1.1])
pause(0);
endfor

Comments

Popular posts from this blog

FACTORIAL

## Function that calculates the factorial of a number ## Usage : f=factorial(n) function f=factorial(n) ## Initialize the output f=1; ## Check whether the input is correct if ( (n<0) || (rem(n,1)~=0) ) printf("n cannot be a negative number. Exiting...\n"); return endif for num=1:n f*=num; endfor endfunction

PRIME OR NOT

## A funtion that takes a number ## in as an argument and returns ## the output p=1 if it is prime ## otherwise returns p=0. function prime_or_not(num) p=1; ## assume the number is prime. div=2; ## the smallest divisor. ## since 2*num/2> num. Forbidden Nsteps=num/2 ; ## Interval of division: the half ## of the num end itself for i= div:Nsteps ## to divide al the numbers less than ## num/2. if(rem(num,i)==0) ## any prime num cannot be ## divided with an integer. p=0; ## otherwise exit the loop. break; endif endfor if(p == 1) ## prints the result p=1 else p=0 endif endfunction

FREE FALL

## A function, free fall, that takes in h (in metres), and ## returns the final velocity of the ball at the ## time step just before it touches the ground and makes ## a plot of velocity versus time. function freefall(h) ## constants and initializations v=0; ## initial velocity(at rest) [m/sec] y=h; ## initial altitude of the ball from the ground [m] t=0; ## initial time[sec ] B1=0.05; ## Coeff of the term prop to v [kg/sec] B2=6E-4; ## Coeff of the term prop to v^2 [kg/m] m=0.25; ## Mass of the ball [kg] g=9.8; ## Gravitational acceleration [m/sec^2] dt=0.1; ## Time increment [sec] n=1; ## Initialize the loop index[dimensionless] ## Run the loop or iterate until the vertical component is ## smaller than zero. while (y(n)>0); ## decrease the altitude in each step y=[y;y(n)+v(n)*dt]; ## and accumlate the results in the array ## of the vertical displacement. ## increase the time in each step t=[t;t(n)+dt]; ## and accumlate the results in the array ## of the tim...