[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
9.7.9 PDE sample
C++ code
mglData a,re(128),im(128); gr->Axis(); gr->Label('x', "\\i x"); gr->Label('y', "\\i z"); re.Fill("exp(-48*(x+0.7)^2)", gr->Min, gr->Max); a = mglPDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, gr->Min, gr->Max, 0.01, 30); a.Transpose("yxz"); gr->CAxis(0, 1); gr->Dens(a,"wyrRk"); gr->Plot("-x", "k|"); gr->Puts(mglPoint(0, 0.85), "absorption: (x+z)/2 for x+z>0"); gr->Title("\\r{Equation:} ik_0\\partial_zu + \\Delta u + x\\cdot u + \ i \\frac{x+z}{2}\\cdot u = 0", "iC", -1.5);
MGL code
axis xlabel '\i x' ylabel '\i z' new re 128 new im 128 fill re 'exp(-48*(x+0.7)^2)' pde a 'p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)' re im 0.01 30 transpose a crange 0 1 dens a 'wyrRk' fplot '-x' 'k|' text 0 0.85 'absorption: (x+z)/2 for x+z>0' '' -1 title 'Equation: ik_0\partial_zu + \Delta u + x\cdot u + i \frac{x+z}{2}\cdot u = 0' 'iC' -1.5
Pure C code
HMDT a = mgl_create_data(); HMDT re = mgl_create_data_size(128,1,1); HMDT im = mgl_create_data_size(128,1,1); mgl_axis(gr,"xyz"); mgl_label(gr,'x', "\\i x"); mgl_label(gr,'y', "\\i z"); mgl_data_fill_eq(gr,re,"exp(-48*(x+0.7)^2)", 0, 0); a = mgl_pde_solve(gr, "p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30.); mgl_data_transpose(a, "yxz"); mgl_set_caxis(gr, 0, 1); mgl_dens(gr, a,"wyrRk", -1.); mgl_fplot(gr, "-x", "k|", 100); mgl_puts(gr, 0., 0.85, 0., "absorption: (x+z)/2 for x+z>0"); mgl_title(gr, "\\r{Equation:} ik_0\\partial_zu + \\Delta u + x\\cdot u + \ i \\frac{x+z}{2}\\cdot u = 0", "iC", -1.5); mgl_delete_data(a); mgl_delete_data(im); mgl_delete_data(re);
Fortran code
integer a,re,im, mgl_create_data_size a = mgl_create_data() re = mgl_create_data_size(128,1,1) im = mgl_create_data_size(128,1,1) call mgl_axis(gr,'xyz') call mgl_label(gr,'x', '\i x') call mgl_label(gr,'y', '\i z') call mgl_data_fill_eq(gr,re,'exp(-48*(x+0.7)^2)', 0, 0) a = mgl_pde_solve(gr, 'p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)', re, im, 0.01, 30.) call mgl_data_transpose(a, 'yxz') call mgl_set_caxis(gr, 0., 1.) call mgl_dens(gr, a,'wyrRk', -1.) call mgl_fplot(gr, '-x', 'k|', 100) call mgl_puts(gr, 0., 0.85, 0., 'absorption: (x+z)/2 for x+z>0') call mgl_title(gr, '\r{Equation:} ik_0\partial_zu + \Delta u + x\cdot u + & i \frac{x+z}{2}\cdot u = 0', 'iC', -1.5) call mgl_delete_data(a) call mgl_delete_data(im) call mgl_delete_data(re)
Python
a, re, im = mglData(), mglData(128), mglData(128); gr.Axis(); gr.Label('x', "\\i x"); gr.Label('y', "\\i z"); gr.Fill(re,"exp(-48*(x+0.7)^2)"); a = gr.PDE("p^2+q^2-x-1+i*0.5*(z+x)*(z>-x)", re, im, 0.01, 30); a.Transpose("yxz"); gr.SetCRange(0, 1); gr.Dens(a,"wyrRk"); gr.Plot("-x", "k|"); gr.Puts(0, 0.85, 0., "absorption: (x+z)/2 for x+z>0"); gr.Title("\\r{Equation:} ik_0\\partial_zu + \\Delta u + x\\cdot u + \ i \\frac{x+z}{2}\\cdot u = 0", "iC", -1.5);
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |