In [1]:
%matplotlib notebook
from sympy import init_printing
from sympy import S
from sympy import sin, cos, tanh, exp, pi, sqrt, log
from boutdata.mms import x, y, z, t
from boutdata.mms import DDX
import os, sys
# If we add to sys.path, then it must be an absolute path
common_dir = os.path.abspath('./../../../../common')
# Sys path is a list of system paths
sys.path.append(common_dir)
from CELMAPy.MES import make_plot, BOUT_print
init_printing()
In [2]:
folder = '../gaussianWSinAndParabola/'
In [3]:
# Initialization
the_vars = {}
In [4]:
# We need Lx
from boututils.options import BOUTOptions
myOpts = BOUTOptions(folder)
Lx = eval(myOpts.geom['Lx'])
Ly = eval(myOpts.geom['Ly'])
In [5]:
# Gaussian with sinus and parabola
# The skew sinus
# In cartesian coordinates we would like a sinus with with a wave-vector in the direction
# 45 degrees with respect to the first quadrant. This can be achieved with a wave vector
# k = [1/sqrt(2), 1/sqrt(2)]
# sin((1/sqrt(2))*(x + y))
# We would like 2 nodes, so we may write
# sin((1/sqrt(2))*(x + y)*(2*pi/(2*Lx)))
# The gaussian
# In cartesian coordinates we would like
# f = exp(-(1/(2*w^2))*((x-x0)^2 + (y-y0)^2))
# A parabola
# In cartesian coordinates, we have
# ((x-x0)/Lx)^2
wx = 0.5*Lx
wy = 0.5*Ly
x0 = 0.3*Lx
y0 = 0.5*Ly
the_vars['f'] = sin((1/sqrt(2))*(x + y)*(2*pi/(2*Lx)))*\
exp(-(((x-x0)**2/(2*wx**2)) + ((y-y0)**2/(2*wy**2))))*\
((x-x0)/Lx)**2
the_vars['a'] = the_vars['f'].subs(y, 0)
the_vars['b'] = the_vars['f'].diff(y).subs(y, 0)
In [6]:
make_plot(folder=folder, the_vars=the_vars, plot2d=True, include_aux=False, direction='y')
In [7]:
BOUT_print(the_vars, rational=False)