Skip to main content

REALISTIC AND NON-REALISTIC 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
E=1e-4 ## Dimensionless stiffnes
function ynext=propagate_stiff(ynow,yprev,r)
## Quick and dirty way to fix boundary conditions -- for each step
## they are the same as the previous step.
ynext=ynow;
ynow(1)=ynow(2)=0;
##Entering the loop
for i=3:length(ynow)-1
## boundary condition
ynow(length(ynow)-1)=ynow(length(ynow)-2)=0;
## Divide the ynext with many terms into three parts for easiness
ynext(i)=(2−(2*r^2)−(6*E*(r^2)*(M^2)))*ynow(i)−yprev(i);
ynext(i)=ynext(i)+(r^2)*(1+4*E*(M^2))*(ynow(i+1)+ynow(i−1));
ynext(i)=ynext(i)-E*(r^2)*(M^2)*(ynow(i+2)+ynow(i−2));
endfor
endfunction

Comments

Popular posts from this blog

NEWTON-RAPSON METHOD-8th degree Legendre polynomial

## Newton-Rapson Method to the smallest non negative root
## of the 8th degree Legendre Polynomial
## P8(x)=(1/128)(6435x^8-12012x^6+6930x^4-1260x^2+35)
## where -1<=x<=1.
## for the smallest non negative root, we can ignore
## all the terms except the last two by truncated
## the function to be zero and find
## x=0.167 as the initial smallest non negative
## root.
##Constants and initializations
x=[]; ## Empty array for the iterated x roots
x(1)=0.16700000; ## Initial guess to begin the iteration for the
## smallest non-negative root.
L8=[]; ## Empty array for the Legendre polynomial
L8p=[]; ## Empty array for the derivative of the Legendre polynomial
for i=1:100
##The value of the function at x
L8(i)=(1/128)*(6435*x(i)^8-12012*x(i)^6+6930*x(i)^4-1260*x(i)^2+35);
##The value of the derivative of the function at x
L8p(i)=(1/128)*(6435*8*x(i)^7-12012*6*x(i)^5+6930*4*x(i)^3-1260*2*x(i));
x(i+1)=x(i)-L8(i)/L8p(i); ## the iteration
endfor
## For plot let's define a new variable…

Second Harmonic Generation

gnuplot> set xrange [-180:180] gnuplot> set yrange [-180:180] gnuplot> set pm3d gnuplot> set hidden3d  gnuplot> set title 'SHG' gnuplot> splot sin(cos(x*pi/180))*sin(cos(x*pi/180))/(cos(x*pi/180)*cos(x*pi/180))*sin(cos(y*pi/180))*sin(cos(y*pi/180))/(cos(y*pi/180)*cos(y*pi/180)) title 'N=1
'