Source code documentation

em.py module

This is the entry-point module for EMP simulations. To execute it, call it as:

python /path/to/em.py simulation.yaml
class em.Parameters[source]

Container class for the input parameters. Each field of this class corresponds to a parameter that will be read from the input file.

em.import_object(s)[source]

Tanslates module.object into __import__(“module”).getattr(“object”)

em.main()[source]

The main function of the module. It reads input parameters and runs the time-advancing loop.

em.peak(t, A, tau, m)[source]

The waveform of the lightning electric current.

Arguments:

  • t: The input time. Usually an 1d Numpy array.
  • A: The total charge transferred by the discharge.
  • tau: Total duration of the impulse current.
  • tau: Fraction of tau in the rise phase.

fdtd.py module

This module contains the code to implement the Yee centered-differences, leapfrog FDTD algorithm.

class fdtd.Box

Box(x0, x1, y0, y1, z0, z1)

x0

Alias for field number 0

x1

Alias for field number 1

y0

Alias for field number 2

y1

Alias for field number 3

z0

Alias for field number 4

z1

Alias for field number 5

class fdtd.CPML(sim, coord, n, invert=False, m=4, R0=1e-06)[source]

Class for Convolutional Perfect Matching Layers. Inside this class we follow the evolution of the 12 pseudo-fields psi. In a 3d cube we must include 6 CPMLs.

allocate_fields()[source]

Allocate the field arrays, with two extra cell in each dimension to implement the b.c.

class fdtd.Cartesian3d(box, dim)[source]

A simulation domain for the cartesian 3d Yee algorithm.

add_cpml_boundaries(n, filter=None)[source]

Adds six cpml layers, one for each of the boundaries of the simulation.

allocate_fields()[source]

Allocate the field arrays, with two extra cell in each dimension to implement the b.c.

save(g)[source]

Saves the state of this grid into g. g has to satisfy the group interface of h5py.

update_e()[source]

Updates E{x, y, z} from time n to n+1 assuming that the H{x, y, z} are up to date at time n+1/2.

update_h()[source]

Updates H{x, y, z} from time n-1/2 to n+1/2 assuming that the E{x, y, z} are up to date at time n.

class fdtd.CylBox

CylBox(r0, r1, z0, z1)

r0

Alias for field number 0

r1

Alias for field number 1

z0

Alias for field number 2

z1

Alias for field number 3

class fdtd.CylDimensions

CylDimensions(nr, nz)

nr

Alias for field number 0

nz

Alias for field number 1

class fdtd.Cylindrical(box, dim)[source]

A simulation domain for the 3d Yee algorithm in cylindical coordinates and with axial symmetry.

add_cpml_boundaries(n, filter=None)[source]

Adds six cpml layers, one for each of the boundaries of the simulation.

allocate_fields()[source]

Allocate the field arrays, with two extra cell in each dimension to implement the b.c.

interpolator(v)[source]

Build and interpolator for v.

save_global(g)[source]

Saves the global properties of the simulation into g. In contrast to save, the values here do not change during a simulation.

update_e()[source]

Updates E{r, z, phi} from time n to n+1 assuming that the H{r, z, phi} are up to date at time n+1/2.

update_h()[source]

Updates H{x, y, z} from time n-1/2 to n+1/2 assuming that the E{x, y, z} are up to date at time n.

class fdtd.CylindricalCPML(sim, coord, n, invert=False, m=4, R0=1e-06)[source]

Class for Convolutional Perfect Matching Layers in cylindrical symmetry.

allocate_fields()[source]

Allocate the field arrays, with two extra cell in each dimension to implement the b.c.

class fdtd.Dimensions

Dimensions(nx, ny, nz)

nx

Alias for field number 0

ny

Alias for field number 1

nz

Alias for field number 2

fdtd.avg(a, n=1, axis=-1)[source]

This is based on diff from numpy but instead of calculating differences it calculates sums (i.e. instead of x[1:] - x[:-1] would calculate x[1:] + x[:-1]

fdtd.centers(x)[source]

Given an array of face coords, returns the center locations.

class fdtd.staggered(shape, inface, neumann_axes=[], **kwargs)[source]

This is a class to contain arrays representing variables in a grid that may be staggered along one or more dimensions.

avg(axis=-1, f=None)[source]

Same as before but using avg instead of diff.

diff(axis=-1, f=None)[source]

Computes the derivative along a certain axis, using the buffer to set the 0 b.c. without using wrong indices.

select(axis, face, center)[source]

Sees if axis is a face coordinate or a center coordinate and returns face or center accordingly.

class fdtd.staggeredview(parent, corner, shape)[source]

A staggeredview subclasses staggered to implement sub-grids that share memory with the wider grids.

langevin.py module

This module contains code that extends the classes in the fdtd module to solve the Langevin equation along with the Maxwell equations.

class langevin.CylindricalLangevin(box, dim)[source]

A simulation to solve the Langevin equation coupled with the electron density evolution equation.

interpolate_e()[source]

Interpolate E{x, y, z} at the locations of J.

j_(coord)[source]

Returns the coord component of j.

static load(g, step, set_dt=False, c=None)[source]

Loads an instance from g and initializes all its data.

load_ionization(fname)[source]

Loads the ionization rate from a file.

load_ne(fname, cutoff=None)[source]

Loads the electron density profile and interpolates it into z. If fname can be interpreted as a float, uses that value.

load_ngas(fname)[source]

Loads the density of neutrals and interpolates into z.

update_j()[source]

Updates j from time-step n-1/2 to n+1/2.

update_ne()[source]

Updates the electron density. Uses an implicit method, so we need to call this after update_e.

Table Of Contents

Previous topic

Input parameters

This Page