In [1]:
%matplotlib notebook
from sympy import init_printing
from sympy import S
from sympy import sin, cos, tanh, exp, pi, sqrt
from sympy import integrate
import numpy as np
from boutdata.mms import x, y, z, t
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 get_metric, make_plot, BOUT_print
init_printing()
In [2]:
folder = '../zHat/'
metric = get_metric()
In [3]:
# Initialization
the_vars = {}
NOTE:
These do not need to be fulfilled in order to get convergence
But this needs to be fulfilled:
In [4]:
# We need Lx
from boututils.options import BOUTOptions
myOpts = BOUTOptions(folder)
Lx = eval(myOpts.geom['Lx'])
In [5]:
# Z hat function
# NOTE: The function is not continuous over origo
s = 2
c = pi
w = pi/2
the_vars['f'] = ((1/2)*(tanh(s*(z-(c-w/2)))-tanh(s*(z-(c+w/2)))))*sin(3*2*pi*x/Lx)
Calculating the solution
In [6]:
the_vars['S'] = (integrate(the_vars['f'], (z, 0, 2*np.pi))/(2*np.pi)).evalf()
In [7]:
make_plot(folder=folder, the_vars=the_vars, plot2d=True, include_aux=False)
In [8]:
BOUT_print(the_vars, rational=False)