FEM1D Conversion Clause Samples

FEM1D Conversion load Results; E=35; V=E*uh; t=10-2*tempo/.3^2; S=E*exp(coord); mesh(S,t,V) int s=10; // y-scale int m=60; int L=50; int LL=50; border aa(t=0,L){x=t;y=0;}; //length 50 borders border bb(t=0,LL){x=L;y=t;}; border cc(t=L,0){x=t ;y=LL;}; border dd(t=LL,0){x = 0; y = t;}; mesh th = buildmesh(aa(m)+bb(m)+cc(m)+dd(m)); //mesh with 60 points on the borders fespace Vh(th,P1); // continuous piecewise linear mesh real sigmax=0.3; // volatility x real sigmay=0.3; // volatility y real rho=0.0; // correlation real r=0.05; // risk free real K=35; // strike price real dt=0.01; // timestep real eps=0.3; func f = max(K-max(x,0*y),0.); // put options, max(strike-value, 0) Vh u=f,v,w; func beta = 1; // (w<=f-eps)*eps + (w>=f) + (w<f)*(w>f-eps)*(eps+(w-f+eps)/eps)*eps); plot(u,wait=1,value=1); //th = adaptmesh(th,u,abserror=1,nbjacoby=2, //err=0.004, nbvx=5000, omega=1.8,ratio=1.8, nbsmooth=3, //splitpbedge=1, maxsubdiv=5,rescaling=1 ); u=u; plot(u,wait=1,value=1); Vh xveloc = -x*r+x*sigmax^2+x*rho*sigmax*sigmay/2; Vh yveloc = -y*r+y*sigmay^2+y*rho*sigmax*sigmay/2; int j=0; int n; real t=0; problem eq1(u,v,init=j,solver=LU) = int2d(th)( u*v*(r+1/dt/beta) + dx(u)*dx(v)*(x*sigmax)^2/2. + dy(u)*dy(v)*(y*sigmay)^2/2. + dy(u)*dx(v)*rho*sigmax*sigmay*x*y/2. + dx(u)*dy(v)*rho*sigmax*sigmay*x*y/2. ) + int2d(th)( -v*convect([xveloc,yveloc],dt,w)/dt/beta) + on(bb,u=f*exp(-r*t)); //+ on(Vh,u>f*exp(-r*t)); ; int ww=1; for ( n=0; n*dt <= 1.0; n++) { t=t+dt;