In [6]:
import os
import sys
sys.path.insert(0, os.path.abspath('../../'))
from matplotlib import pyplot as pl
from scipy.integrate import odeint
import numpy as np
import h5py
from dg_maxwell import params
pl.rcParams['figure.figsize' ] = 9.6, 6.
pl.rcParams['figure.dpi' ] = 300
pl.rcParams['image.cmap' ] = 'jet'
pl.rcParams['lines.linewidth' ] = 1.5
pl.rcParams['font.family' ] = 'serif'
pl.rcParams['font.weight' ] = 'bold'
pl.rcParams['font.size' ] = 20
pl.rcParams['font.sans-serif' ] = 'serif'
pl.rcParams['text.usetex' ] = True
pl.rcParams['axes.linewidth' ] = 1.5
pl.rcParams['axes.titlesize' ] = 'medium'
pl.rcParams['axes.labelsize' ] = 'medium'
pl.rcParams['xtick.major.size'] = 8
pl.rcParams['xtick.minor.size'] = 4
pl.rcParams['xtick.major.pad' ] = 8
pl.rcParams['xtick.minor.pad' ] = 8
pl.rcParams['xtick.color' ] = 'k'
pl.rcParams['xtick.labelsize' ] = 'medium'
pl.rcParams['xtick.direction' ] = 'in'
pl.rcParams['ytick.major.size'] = 8
pl.rcParams['ytick.minor.size'] = 4
pl.rcParams['ytick.major.pad' ] = 8
pl.rcParams['ytick.minor.pad' ] = 8
pl.rcParams['ytick.color' ] = 'k'
pl.rcParams['ytick.labelsize' ] = 'medium'
pl.rcParams['ytick.direction' ] = 'in'
In [7]:
def dydt_0(y, t0):
'''
'''
E_00, B_01 = y
dydt = [-B_01 * 2 * np.pi, E_00 * 2 * np.pi]
return dydt
def dydt_1(y, t0):
'''
'''
E_01, B_00 = y
dydt = [B_00 * 2 * np.pi, -E_01 * 2 * np.pi]
return dydt
In [8]:
E_00_B_01_init = [1.0, 1.]
E_01_B_00_init = [1.0, 1.]
t = np.arange(0., 2., params.delta_t)
In [9]:
E_00_B_01 = odeint(dydt_0, E_00_B_01_init, t)
E_01_B_00 = odeint(dydt_1, E_01_B_00_init, t)
In [10]:
print(E_00_B_01)
In [11]:
print(params.delta_t * i * 5)
In [12]:
for i in np.arange(126):
# i = 20
print(i)
E_z = E_00_B_01[5 * i][0] * np.sin(2 * np.pi * params.element_LGL) + E_01_B_00[5 * i][0] * np.cos(2 * np.pi * params.element_LGL)
B_y = E_01_B_00[5 * i][1] * np.sin(2 * np.pi * params.element_LGL) + E_00_B_01[5 * i][1] * np.cos(2 * np.pi * params.element_LGL)
f, (ax1, ax2) = pl.subplots(2, sharex = True, sharey = True)
h5py_data = h5py.File('../../results/hdf5_%02d/dump_timestep_%06d' %(int(params.N_LGL), int(5 * i)) + '.hdf5', 'r')
E_z_LGL = (h5py_data['E_z'][:])
B_y_LGL = (h5py_data['B_y'][:])
ax1.plot(params.element_LGL, E_z)
ax2.plot(params.element_LGL, B_y)
ax1.plot(params.element_LGL, E_z_LGL, '.')
ax2.plot(params.element_LGL, B_y_LGL, '.')
pl.xlabel(r'$x$')
ax1.set_ylabel(r'$E_z$')
ax2.set_ylabel(r'$B_y$')
pl.xlim(-1, 1)
pl.ylim(-2, 2)
pl.title(r'$E_z$ Time = %.2f' % (i * 5 * params.delta_t))
f.savefig('../../results/1D_Wave_images_/%04d' %(i) + '.png')
pl.close('all')
# pl.show()
In [ ]: