def update_e(self): super(CylindricalLangevin, self).update_e() self.er.v[:] -= (0.5 * self.dt / co.epsilon_0 * avg(self.j_(R), axis=R)) self.ez.v[:] -= (0.5 * self.dt / co.epsilon_0 * avg(self.j_(Z_), axis=Z_)) self.ephi.v[:] -= (0.5 * self.dt / co.epsilon_0 * self.j_(PHI)) self.interpolate_e() self.update_ne()
def semi_step(): """ Performs a timestep from n - 1/2 to n + 1/2. Here it means updating J. """ # The b.c. here is J=0 at the boundaries J[1:-1] = (A[1:-1] * J[1:-1] + (0.5 * co.epsilon_0 * wp2[1:-1] * K[1:-1]) * avg(E))
def panel(sim, profile, ofile, mun=2e24, **kwargs): pylab.figure(figsize=(20, 8)) pylab.clf() pylab.subplots_adjust(left=0.065, right=0.98, wspace=0.07, top=0.95) jr = sum(avg(sim.j_(R), axis=R), axis=-1) jz = sum(avg(sim.j_(Z_), axis=Z_), axis=-1) jphi = sum(avg(sim.j_(PHI), axis=PHI), axis=-1) eabs = sqrt(sum(sim.e**2, axis=-1)) En = (eabs * co.elementary_charge / (mun * sim.nu[:, :, 0] * co.electron_mass)) En[:] = where(isfinite(En), En, 0.0) logargs = dict(vmin=1e-2, vmax=1e4, norm=LogNorm()) freelogargs = dict(norm=LogNorm()) VProfile = namedtuple("VProfile", "var label args") profiles = { "fields": [VProfile(sim.hphi.v.T, "$H_\phi$ [SI]", {}), VProfile(sim.ez.v.T, "$E_z$ [V/m]", {}), VProfile(sim.hr.v.T, "$H_r$ [SI]", {}), VProfile(sim.er.v.T, "$E_r$ [V/m]", {})], "logfields": [VProfile(abs(sim.hphi.v.T), "$H_\phi$ [SI]", logargs), VProfile(abs(sim.ez.v.T), "$E_z$ [V/m]", logargs), VProfile(abs(sim.hr.v.T), "$H_r$ [SI]", logargs), VProfile(abs(sim.er.v.T), "$E_r$ [V/m]", logargs)], "freelogfields": [VProfile(abs(sim.hphi.v.T), "$H_\phi$ [SI]", freelogargs), VProfile(abs(sim.ez.v.T), "$E_z$ [V/m]", freelogargs), VProfile(abs(sim.hr.v.T), "$H_r$ [SI]", freelogargs), VProfile(abs(sim.er.v.T), "$E_r$ [V/m]", freelogargs)], "reduced": [VProfile(abs(jz.T), "$J_z$ [A/m$^\\mathdefault{2}$]", {}), VProfile(abs(jz.T), "$J_z$ [A/m$^\\mathdefault{2}$]", {}), VProfile(En.T / Td, "$E/N$ [Td]", {}), VProfile(abs(sim.er.v.T), "$E_z$ [V/m]", {})], "logreduced": [VProfile(abs(jz.T), "$J_z$ [A/m$^\\mathdefault{2}$]", logargs), VProfile(abs(sim.er.v.T), "$E_r$ [V/m]", logargs), VProfile(En.T / Td, "$E/N$ [Td]", logargs), VProfile(abs(sim.ez.v.T), "$E_z$ [V/m]", logargs)]} print("") print("\teabs : ", amin(eabs), amax(eabs)) pylab.title("t = %.4d $\mu$s" % (sim.te / co.micro)) for i, vp in enumerate(profiles[profile]): pylab.subplot(2, 2, i + 1) args = kwargs.copy() args.update(vp.args) plot(sim, vp.var, label=vp.label, **args) try: pylab.savefig(ofile) except (ValueError, AttributeError) as e: warn("Error saving the figure")
def int_step(): """ Performs a timestep from n to n + 1. Here it means updating E. """ E[:] = E - (0.5 * dt / co.epsilon_0) * avg(J)
from numpy import * import scipy.constants as co import pylab from saturn2d import ne, nt, peak from fdtd import avg # Number of cell (centers) nc = 1000 # Number of faces nf = nc + 1 z0, z1 = 900 * co.kilo, 1000 * co.kilo zf = linspace(z0, z1, nf) zc = 0.5 * avg(zf) # The electric field is defined on cell centers E = zeros((nc,)) # The current is defined on cell faces J = zeros((nf,)) sz0 = 950 * co.kilo sz1 = 960 * co.kilo szc = (sz0 + sz1) / 2 ssigma = (sz1 - sz0) / 6 isz0, isz1 = [argmin(abs(zc - z)) for z in (sz0, sz1)] # Here we assume a constant mu * N. Later, we can use field-dependent # mobility.
def jphi(sim, params): return sum(avg(sim.j_(PHI), axis=PHI), axis=-1)
def jz(sim, params): "$j_z [$\\mathdefault{A/m^2}$]" return avg(sim.j_(Z_), axis=Z_)
def jr(sim, params): "$j_r [$\\mathdefault{A/m^2}$]" return sum(avg(sim.j_(R), axis=R), axis=-1)