bfdtd package

Submodules

bfdtd.RCD module

RCD BFDTD objects

RCD = Rod Connected Diamond

bfdtd.RCD.FCC_BZ_dictionary(scale=1)[source]
class bfdtd.RCD.FRD_HexagonalLattice[source]

Bases: bfdtd.RCD.RCD_HexagonalLattice

unitCellType1(i, j, k)[source]

A unit-cell containing 3 “tetrahedrons”. lattice vectors: u1,v1,w1

unitCellType2(i, j, k)[source]

A unit-cell containing 6 “tetrahedrons”. lattice vectors: u2,v2,w2

bfdtd.RCD.RCD111_waveguide_vector_dictionary()[source]
class bfdtd.RCD.RCD_HexagonalLattice[source]

Bases: bfdtd.GeometryObjects.GeometryObject

This class allows you to create RCD structures with some cylinders alligned along the Z axis.

clearGeoList()[source]
createBlenderObject(blender_operator, context)[source]
createGeoList()[source]
createRectangularArray(Nx, Ny, Nz)[source]
createRectangularArraySymmetrical(Nx, Ny, Nz)[source]
fillBox(location, size)[source]
getCubicUnitCell()[source]

Get a Distorted object representing the cubic unit cell

getGeoList()[source]
getIndexOf(i, j, k, tetra_location, tetra_cylinder)[source]
getLatticeVectors()[source]
getMeshObject(Nx, Ny, Nz)[source]
getOuterRadius()[source]

get outer radius of rods

getRodLength()[source]
getUnitCell()[source]

Get a Distorted object representing the unit cell

getUnitCellType()[source]
getXMesh(Nx, Ny, Nz, NcellsMin)[source]
getXMesh_with_SpacingMax(Nx, Ny, Nz, spacing_max)[source]
getYMesh(Nx, Ny, Nz, NcellsMin)[source]
getYMesh_with_SpacingMax(Nx, Ny, Nz, spacing_max)[source]
getZMesh(Nx, Ny, Nz, NcellsMin1, NcellsMin2)[source]
getZMesh_with_SpacingMax(Nx, Ny, Nz, spacing_max)[source]
setCubicUnitCellSize(cubic_unit_cell_size)[source]
setLocation(location)[source]

Set the location of the RCD.

setOuterRadius(outer_radius)[source]

set outer radius of rods

setShifted(shifted)[source]
setUnitCellType(unit_cell_type)[source]
tetra(location, name='tetra')[source]

Return a list of 4 cylinders aranged as a “tetrahedron”, with one of the cylinders facing downwards. location is the position of the point at which all cylinders join.

unitCellType1(i, j, k)[source]

A unit-cell containing 3 “tetrahedrons”. lattice vectors: u1,v1,w1

unitCellType2(i, j, k)[source]

A unit-cell containing 6 “tetrahedrons”. lattice vectors: u2,v2,w2

write_entry(FILE)[source]
bfdtd.RCD.RCD_vector_dictionary()[source]
bfdtd.RCD.apply_transform(input_V, input_V_groups, mat3, scale, suffix)[source]

bfdtd.RCD_waveguides module

class bfdtd.RCD_waveguides.RCD_HexagonalLattice_ChiralWaveguide[source]

Bases: bfdtd.RCD.RCD_HexagonalLattice

chirality

chirality of the waveguide: right or left

createGeoList()[source]
unitCell(i, j, k)[source]

A unit-cell containing 6 “tetrahedrons”. lattice vectors: u2,v2,w2

bfdtd.RCD_waveguides.main()[source]

bfdtd.SpecialTriangularPrism module

class bfdtd.SpecialTriangularPrism.SpecialTriangularPrism(name='SpecialTriangularPrism', layer='SpecialTriangularPrism', group='SpecialTriangularPrism', lower=[0, 0, 0], upper=[1, 1, 1], permittivity=1, conductivity=0, NvoxelsX=10, NvoxelsY=10, NvoxelsZ=10, orientation=[0, 1, 2])[source]

Bases: bfdtd.GeometryObjects.GeometryObject

Creates prism with 45 degree mirrors. Should have support for arbitrarily angled mirrors at some point.

getBoundingBoxCentre()[source]
getGeoCentre()[source]
getGlobalEnvelopPoints()[source]
getInscribedSquarePlaneRadius(G_global)[source]
getLocalEnvelopPoints()[source]
getMeshingParameters(xvec, yvec, zvec, epsx, epsy, epsz)[source]
getVoxelDimensions()[source]
getVoxels()[source]
global2local(P_global)[source]
local2global(P_local)[source]
setGeoCentre(P)[source]
write_entry(FILE)[source]

writes the voxels to the file corresponding to the FILE handle

bfdtd.BFDTDobject module

class bfdtd.BFDTDobject.BFDTDobject[source]

Bases: object

addBoxFrequencySnapshots()[source]

This should be called after the box and mesh have been defined. Else the box size might be incorrect.

Returns the “base snapshot”.

addCentralXYZSnapshots(location, freqlist, withEpsilon=True)[source]
addDefaultExcitation()[source]

Simply adds a default excitation centered in the simulation box, of excitation_size = box_size/10.

addEpsilonBox()[source]
addEpsilonSnapshot(plane, position, name=None)[source]
addFrequencySnapshot(plane, position, frequency_list=None, name=None)[source]

Add a frequency snapshot.

Parameters:
  • plane – The X, Y or Z plane.
  • position (float or list/array of size 3) – the X, Y or Z (depending on the value of plane) position or simply a set of 3D coordinates (ex:[5.3, 6.4, 7.6]).
  • frequency_list (a list of floats (ex: [1.2, 2.3, 3.4])) – a list of frequencies
  • name (string) – string

See also: addSnapshot()

addModeFilteredProbe(plane, position, name=None)[source]
addSnapshot(snapshot_class, plane, position_input, name=None)[source]

Adds a snapshot of class “snapshot_class”.

Parameters:
  • snapshot_class – One of the snapshot classes or a custom snapshot class derived from them.
  • plane – ‘x’, ‘y’ or ‘z’
  • position_input – float or list/array of size 3
  • name – Name of the snapshot to add. If None, will be set to a string of the form “X/Y/Z snapshot_class.__name__”
addTimeSnapshot(plane, position, name=None)[source]
add_arguments(parser)[source]
appendExcitation(excitation)[source]

Add one or more Excitation objects to the simulation.

Parameters:obj – Excitation or list of Excitation instances
appendGeometryObject(obj)[source]

Add one or more geometry objects to the simulation.

Parameters:obj – GeometryObject or list of GeometryObject instances
appendProbe(obj)[source]

Add one or more Probe objects to the simulation.

Parameters:obj – Probe or list of Probe instances
appendSnapshot(obj)[source]

Add one or more snapshot objects to the simulation.

Parameters:obj – Snapshot or list of Snapshot instances
applyTransformationMatrix(M)[source]
autoMeshGeometry(meshing_factor, minimum_mesh_delta_vector3=[0.001, 0.001, 0.001])[source]

Automatically mesh geometry so that the max cell size is meshing_factor*1/n in each object.

autoMeshGeometryWithMaxNumberOfCells(Lambda, MAXCELLS=10000000.0, a_min=1, a_step=1, a_start=10)[source]

Calls autoMeshGeometry(Lambda/a) until it finds the biggest value of a (i.e. smallest cell size) so that Ncells < MAXCELLS.

Returns the final value used for a.

autosetExcitationStartTime()[source]
autosetFrequencySnapshotSettings(mode)[source]

Automatically sets frequency snapshots parameters.

mode = 0:
repetition = (MaxIterations - start)/self.autoset_N_FrequencySnapshots
mode = 1:
repetition = RepetitionFactor*period_max
mode = 2:
repetition = RepetitionFactor*ExcitationEndTimeMax
mode = 3:
repetition = biggest repetition between mode 1 and 2

start = ExcitationEndTimeMax first = start + repetition

calculateMeshingParameters(minimum_mesh_delta_vector3)[source]

Returns a MeshingParameters object that can be used for meshing.

It uses the getMeshingParameters() function and useForMeshing attribute of the various BFDTD objects.

minimum_mesh_delta_vector3 : smallest cell size acceptable in the mesh. Because too small cells can cause Bristol FDTD to crash.

meshing_parameters attributes:

  • meshing_parameters.maxPermittivityVector_X
  • meshing_parameters.thicknessVector_X
  • meshing_parameters.maxPermittivityVector_Y
  • meshing_parameters.thicknessVector_Y
  • meshing_parameters.maxPermittivityVector_Z
  • meshing_parameters.thicknessVector_Z
checkSimulation(output_checks=True)[source]

Supposed to make sure we don’t write out too many probes/snapshots…

  • Problem: snapshot boxes and other compound objects will not get counted properly…
  • Solution: Best to count objects after writing (maybe use tmp, sys.stdout, file buffer or similar to allow count without actual file output).
clearAllSnapshots()[source]

Remove all snapshots (time, frequency, etc).

clearEpsilonSnapshots()[source]

Remove all epsilon snapshots.

clearExcitationList()[source]

Clear the list of Excitation objects.

clearFileList()[source]

Clears the filelist.

clearFrequencySnapshots()[source]

Remove all frequency snapshots.

clearGeometry()[source]

Clear the list of geometry objects.

clearMesh()[source]

Resets the mesh to the default.

clearModeFilteredProbes()[source]

Remove all “mode filtered probe” snapshots.

clearProbes()[source]

Clear the list of probes.

clearTimeSnapshots()[source]

Remove all time snapshots.

disableAutoFix()[source]
disableSafetyChecks()[source]
enableAutoFix()[source]
enableSafetyChecks()[source]
fitBox(vec6)[source]

Changes the limits of the box to fit the geometry. Moves all other things as necessary to have box min be [0,0,0] (necessary?).

fixSimulation()[source]

Automatically fix common mistakes.

getAllTimeSnapshots(filterBasedOnClass=False, split=False)[source]

Returns the time snapshots sorted into lists based on their type:

  • all_time_snapshots
  • time_snapshots
  • epsilon_snapshots
  • mode_filtered_probes

The classifications are exclusive, i.e.:

len(all_time_snapshots) = len(time_snapshots) + len(epsilon_snapshots) + len(mode_filtered_probes)
Parameters:filterBasedOnClass – Boolean. If True, the snapshot type will be determined based on its current class type, else it will be determined based on its attributes. Default: False.
Returns:(all_time_snapshots, time_snapshots, epsilon_snapshots, mode_filtered_probes) - tuple of lists

Warning

The SnapshotBox subclasses are not yet supported by this system and will not be returned even if they generate TimeSnapshot entries.

getBoundaries()[source]
getBox()[source]
getCentro()[source]
getDefaultRefractiveIndex()[source]
getDefaultRelativeConductivity()[source]
getDefaultRelativePermittivity()[source]
getEpsilonSnapshots(filterBasedOnClass=False, split=False)[source]

Returns all “epsilon snapshots”.

getExcitationEndTimeMax()[source]

Returns the biggest “end time” of all excitations.

getExcitationFrequencyMax()[source]

Returns the biggest “end frequency” of all excitations.

getExcitationFrequencyMin()[source]

Returns the smallest “start freqency” of all excitations.

getExcitationFrequencyRange()[source]

Returns the total frequency range covered by all excitations.

getExcitationFrequencySet()[source]

Returns a set of unique frequencies used in the excitations.

getExcitationInfos()[source]

Loops over all excitations and returns the tuple (StartTimeMin, EndTimeMax, FrequencyMin, FrequencyMax).

getExcitationStartTimeMin()[source]

Returns the smallest “start time” of all excitations.

getExcitations()[source]
getExecutable()[source]
getExtension()[source]
getFileBaseName()[source]
getFileList()[source]
getFlag()[source]
getFrequencySnapshots(split=False)[source]

Returns a list of the frequency snapshots. .. todo:: improve “super-snapshot” handling… (boxes, etc) -> one problem is that it depends on the mesh of course…

getGeometryObjects()[source]

Returns the list of geometry objects.

getGeometryObjectsByName(name)[source]

Returns the list of geometry objects matching the name name.

Parameters:name – string (ex: 'defect')
getGeometryObjectsByType(class_or_type_or_tuple)[source]

Returns the list of geometry objects of type/class class_or_type_or_tuple.

The filtering is done by isinstance(object, class_or_type_or_tuple).

Parameters:class_or_type_or_tuple – An FDTD object class like Block or a tuple of such classes like (Block, Cylinder), in which case it will match if it is an instance of any of the classes in the tuple.
getIdString()[source]
getIterations()[source]

Returns the number of iterations.

getLatestFrequencySnapTimeNumber(Nmax=100)[source]

Returns the highest snap_time_number for which all output files have been generated.

Note

It does this by incrementing snap_time_number from 0 and stopping as soon as all output files for the current snap_time_number cannot be found. This means that if snapshots for earlier snap_time_number values have been deleted, the result might not be what you expect.

If it cannot find output files for snap_time_number=0, it will return -1.

getLower()[source]
getMemoryRequirements()[source]

Return an estimate of the required memory to run the simulation.

At the moment, this is based on a fit of the data returned by Gema3 for various simulations and only depends on the number of cells. In reality, the memory used (and the speed) will also depend on the number of probes and snapshots used and is likely to be much higher.

memory required in Bytes = p1*x + p0, where x = number of cells, with:

  • p1 = 37.74864
  • p0 = 14153702.89349
getMesh()[source]
getModeFilteredProbes(filterBasedOnClass=False)[source]

Returns all “mode filtered probes”.

getNcells()[source]
getObjects()[source]

Returns the list of excitations and geometry objects.

getOutputFileNames(fsnap_time_number=0, tsnap_time_number=0)[source]

Print out names of all output files that will be generated.

getProbes()[source]
getRefractiveIndexSet()[source]

Returns a set of unique refractive indices used in the objects.

getSimulationTime()[source]

Returns the total simulation time based on the mesh and the number of iterations.

getSize()[source]
getSizeAndResolution()[source]
getSnapshotFirstMax()[source]
getSnapshotFrequencySet()[source]

Returns a set of unique frequencies used in the frequency snapshots.

getSnapshots(split=False)[source]

Returns a list of all snapshots.

getTimeSnapshots(filterBasedOnClass=False)[source]

Returns all “time snapshots”.

getTimeStep()[source]

Returns the timestep in:

  • seconds if dimensions are in meters
  • microseconds if dimensions are in micrometers
  • etc

The simulation timestep is given by:

timeStep = timeStepFactor/(c0*sqrt(1/dx^2+1/dy^2+1/dz^2))
getTimeStepFactor()[source]
getTimeStepMax()[source]

Returns the maxmimum acceptable timestep for stable simulations defined by:

timeStepMax = 1/(c0*sqrt(1/dx^2+1/dy^2+1/dz^2))
getUpper()[source]
getWallTime()[source]

get the walltime to use for torque job shellscripts

getXmesh()[source]
getYmesh()[source]
getZmesh()[source]
printInfo()[source]
readBristolFDTD(*filename)[source]

Reads in one or multiple BFDTD input files (.in (=>.inp+.geo), .geo or .inp) and adds their contents to the BFDTDobject.

Examples:

sim.readBristolFDTD('sim.in')
sim.readBristolFDTD('sim.geo')
sim.readBristolFDTD('sim.inp')
sim.readBristolFDTD('sim1.in','sim2.in','sim3.geo')
sim.readBristolFDTD('sim.geo','sim.inp')
  • Returns 0 on success.
  • Returns -1 on failure.
readDataFrequencySnapshots(snap_time_number=0, testrun=False)[source]
readDataTimeSnapshots(snap_time_number=0, testrun=False)[source]
readFileList(filename)[source]

read .in file

readInputFile(filename)[source]

read GEO or INP file

rotate(axis_point, axis_direction, angle_degrees)[source]
runSimulation(simdir='.', simname=None, verbosity=None)[source]

Writes the simulation files into simdir and runs a simulation there.

sampleFunction(sampling_function, destdir='.')[source]

Sample a function over the current mesh, i.e. generate .prn output files based on a sampling function of the form (epsilon, E, H) = f(x,y,z,t).

This is mainly for testing postprocessing tools with known input but can of course be used for anything else.

set2D()[source]
set3D()[source]
setAttributesFromParsedOptions(options)[source]

Sets the object’s attributes based on the ones from the options object (usually an argparse.ArgumentParser instance).

See also: add_arguments()

setAutosetExcitationStartTime(val)[source]
setAutosetFrequencySnapshotSettings(val)[source]
setAutosetNFrequencySnapshots(Nsnaps)[source]
setBoundaryConditionsToPML(number_of_layers=8, grading_index=2, min_reflection_coeff=0.001, thickness=None)[source]

Sets all boundaries to PML. You can specify the thickness either directly in meters/micrometers/etc or as a number of layers. If thickness == None, number_of_layers will be used else number_of_layers will be set so that the specified thickness is obtained (even if number_of_layers is already specified!).

setDataPaths(path_list)[source]
setDefaultRefractiveIndex(n)[source]
setDefaultRelativeConductivity(conductivity)[source]
setDefaultRelativePermittivity(permittivity)[source]
setExcitations(excitation_list)[source]
setExecutable(BFDTD_executable)[source]
setFileBaseName(fileBaseName, set_default_filelist=True)[source]
setFileList(fileList)[source]

Sets the filelist. ..todo:: appendFileList()? (but make sure always a single box in geo file and that it is at the end)

setGeometryObjects(geometry_object_list)[source]

Returns the list of geometry objects.

setIdString(id_string)[source]
setIterations(iterations, AfterSources=False)[source]

Sets the number of iterations. If AfterSources=True, the number of iterations is set so that all sources finish running and then adds iterations iterations after that.

setMesh(mesh)[source]
setSafetyChecks(val)[source]

Because safety checks are essential, they currently always raise exceptions. Will decide later which way to go.

setSimulationTime(maxtime=None, AfterSources=False)[source]

Sets the number of iterations to ceil(maxtime/timestep).

setSizeAndResolution(size_vec3, N_vec3, Ncells_per_unit=False)[source]

Sets the size and resolution (number of cells in the x,y and z directions) of the simulation.

See also: bfdtd.meshobject.MeshObject.setSizeAndResolution()

setSnapshots(obj)[source]

Removes all existing snapshots and replaces them with the elements from the list of snapshots obj (or [obj] if obj is not a list, for convenience).

Ex:

sim.setSnapshots(EpsilonBoxFull()) # single snapshot
sim.setSnapshots(100*[EpsilonSnapshot()]) # list of 100 snapshots
Parameters:obj – Snapshot or list of Snapshot instances
setTimeStep(timeStep)[source]

Sets the timestep to timeStep indirectly by setting the timeStepFactor.

setTimeStepFactor(timeStepFactor)[source]
setVerbosity(verbosity)[source]
setWallTime(WALLTIME)[source]

set the walltime to use for torque job shellscripts

setWorkDir(WORKDIR)[source]
translate(vec3)[source]
writeAll(newDirName, fileBaseName=None, withGeom=True, writeShellScriptFunction=None, overwrite=True)[source]

Generate .in,.inp,.geo,.cmd,.sh files in directory newDirName (it will be created if it doesn’t exist)

Note

Please use writeTorqueJobDirectory if you wish to prepare a job directory for submission with qsub.

writeCondorScript(fileName, BASENAME=None)[source]

Generate fileName.cmd file for Condor using BASENAME.in, BASENAME.geo, BASENAME.inp

writeCtlFile(fileName, withGeom=True, overwrite=True, withBox=True, no_offset=False)[source]

Generate .ctl file

writeDatFiles(directory, overwrite=True)[source]

Generate template .dat file for a plane excitation

writeExcitationsToFile(fileName, overwrite=True, append=False, call_makedirs=False)[source]
writeFileList(fileName, fileList=None, overwrite=True, use_relpath=False)[source]

Generate .in file

writeGeoFile(fileName, withGeom=True, overwrite=True, withBox=True, call_makedirs=False)[source]

Generate .geo file

writeHDF5(h5file)[source]
writeInpFile(fileName=None, overwrite=True)[source]

Generate .inp file

writeProbesToFile(fileName, overwrite=True, append=False, call_makedirs=False)[source]
writeShellScript(fileName, EXE='fdtd', WORKDIR='$JOBDIR', overwrite=True)[source]

Generate .sh file

writeTorqueJobDirectory(destdir, overwrite=True)[source]

Generate .in, .inp, .geo and .sh files in directory destdir (it will be created if it doesn’t exist).

This function was created as a replacement for writeAll and makes it easier to generate the desired .sh file to be submitted with qsub.

Note

The destination directory will be created if it does not exist.

class bfdtd.BFDTDobject.Boundaries[source]

Bases: bfdtd.BFDTDentry.BFDTDentry

The following ABC algorithms are available in the FDTD program:

    1. Magnetic Wall
    1. Metal wall. -> “symmetry wall”
    1. Mur 1st. -> default setting
    1. Dispersive.
    1. Higdon 1st.
    1. Higdon 2nd
    1. PML

The parameters are for the second order and Perfectly Matched Layer boundary conditions and have the following meanings:

    1. Dispersive ABC Parameter 1 and parameter2 are the values of effective permittivity for which perfect absorption may be expected
    1. Higdon ABC Parameter 1 and parameter 2 are the values for the angle of incidence ( in degrees ) at which perfect absorption may be expected
    1. PML Parameter 1 is the number of layers in the PML region, parameter 2 is the grading index, normally 2, parameter 3 is the minimum reflection coefficient, try 0.01 - 0.001. This is not critical.

If you want to make the BFDTD simulations run faster, you can exploit the symmetry of the structure by putting the simulation box over only one half of the pillar and use a metallic wall at the symmetry boundary.

read_entry(entry)[source]
setBoundaryConditionsNormal()[source]
setBoundaryConditionsToPML(number_of_layers=8, grading_index=2, min_reflection_coeff=0.001)[source]

Sets all boundaries to PML.

setBoundaryConditionsXnegToPML(number_of_layers=8, grading_index=2, min_reflection_coeff=0.001)[source]
setBoundaryConditionsXposToPML(number_of_layers=8, grading_index=2, min_reflection_coeff=0.001)[source]
setBoundaryConditionsYnegToPML(number_of_layers=8, grading_index=2, min_reflection_coeff=0.001)[source]
setBoundaryConditionsYposToPML(number_of_layers=8, grading_index=2, min_reflection_coeff=0.001)[source]
setBoundaryConditionsZnegToPML(number_of_layers=8, grading_index=2, min_reflection_coeff=0.001)[source]
setBoundaryConditionsZposToPML(number_of_layers=8, grading_index=2, min_reflection_coeff=0.001)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
class bfdtd.BFDTDobject.Box(name=None, layer=None, group=None, lower=None, upper=None)[source]

Bases: object

getCentro()[source]
getExtension()[source]
getLower()[source]
getSize()[source]
getUpper()[source]
read_entry(entry)[source]
setCentro(nova_centro)[source]
setExtension(lower, upper)[source]
setLower(lower)[source]
setSize(size_vec3)[source]
setUpper(upper)[source]
translate(vec3)[source]
writeCTL(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
class bfdtd.BFDTDobject.Entry[source]

Bases: object

class bfdtd.BFDTDobject.Flag[source]

Bases: bfdtd.BFDTDentry.BFDTDentry

  • iterationMethod: Set to 1 if FDTD/PEEC is wanted
  • propagationConstant: Propagation constant for two dimensional runs
  • flagOne: Set to 1 to use the Celuch method for dealing with curved dielectrics
  • flagTwo: Set to:
    1. Set to specify a two dimensional simulation
    2. Specify Static Field Solutions for metal strips
    3. Specify Pre-calculated Correction Factors for metal strips
    4. Specify MAMPs
  • iterations: Number of iterations required
  • timeStepFactor: Time step as a proportion of the maximum allowed
  • id_string: Probe identifier, “id”
  • 8: Set to 1 to ask for a file to be produced for input to the POVRAY ray tracing program
getIdString()[source]
getIterations()[source]

Returns the number of iterations.

getTimeStepFactor()[source]
read_entry(entry)[source]
set2D()[source]
set3D()[source]
setIdString(id_string)[source]
setIterations(iterations)[source]

Sets the number of iterations.

setTimeStepFactor(timeStepFactor)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

bfdtd.bfdtd_parser module

This is the main module for Bristol FDTD related classes and functions. It provides an easier way to work with Bristol FDTD.

Example:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# import everything from the bfdtd module into current namespace
from bfdtd import *

# create a BFDTDobject instance, which will store everything related to the simulation
sim = BFDTDobject()

# set a size and resolution
# Note: This will create a homogeneous mesh. For a custom mesh, please refer to some of the existing scripts. The meshing system is still changing a lot.)
sim.setSizeAndResolution([10,10,10],[100,100,100])

# create an object
obj = Cylinder()

# set some of its parameters
obj.setLocation([1,2,3])
obj.setStartEndPoints([-1,2,-5], [1,1,1])
obj.setOuterRadius(0.5)

# add the object to the simulation
sim.appendGeometryObject(obj)

# add an excitation to the simulation
E = Excitation()
sim.appendExcitation(E)

# add a probe to the simulation
P = Probe()
P.setPosition([4,5,6])
sim.appendProbe(P)

# add a snapshot to the simulation
F = FrequencySnapshot()
F.setFrequencies([100])
sim.appendSnapshot(F)

# write out only a .geo file
sim.writeGeoFile('foo.geo')

# write out only a .inp file
sim.writeInpFile('foo.inp')

# write out only a .in file
sim.writeFileList('foo.in')

# write out all files necessary to submit the job using qsub (i.e. the *Torque* queueing system).
sim.writeTorqueJobDirectory('somedir')

# You can even run the simulation directly. Files will be written as necessary.
sim.runSimulation()

For more examples, please have a look in the script_inception_public/examples directory.

Developer notes:

The BFDTD simulation box always goes from (0,0,0) to (Sx,Sy,Sz).
The MEEP/MPB simulation box always goes from (-Sx/2,-Sy/2,-Sy/2) to (+Sx/2,+Sy/2,+Sy/2).
This might cause problems when trying to inegrate the two.
One possible solution: The user places the simulation box like all other objects according to his own coordinate system. The writing/export functions will automatically reposition things as needed.

IDEAS:

  • instaur “.bfdtd.py” extension for geometry creating scripts, so that people use them like .ctl files for MPB/MEEP
  • create MPB/MEEP like runner to run those “.bfdtd.py”, while taking care of imports and other recurring things
  • Use “#PBS”-like prefix/comment in “.bfdtd.py” scripts or other for special things/CLI option replacement
  • create extended snapshot classes. Ex: FullBoxSnapshots -> when write is called, it will create snapshots along a specified axis over the whole simulation box.
  • accept loss of information once writing to .geo/.inp files (special class info could be added later in comments eventually to allow reading back in written .geo/.inp files)

Note about plane specifications:

  • BFDTD indices: 1,2,3 -> _bfdtdidx
  • python indices: 0,1,2 -> _pythonidx
  • upper letters indices: ‘X’,’Y’,’Z’ -> _upperletteridx
  • lower letter indices: ‘x’,’y’,’z’ -> _lowerletteridx
  • vectors: [1,0,0], [0,1,0], [0,0,1] -> _upperletteridx
class bfdtd.bfdtd_parser.FDTDdataObject[source]

Bases: object

Nx = 1
Ny = 1
Nz = 1
data_epsilon = None
data_frequency_snapshots = None
data_time_snapshots = None
setData(x, y, z, field, value)[source]
bfdtd.bfdtd_parser.readBristolFDTD(*filename, **kwargs)[source]

Reads one or more .in (=>.inp+.geo), .geo or .inp files and returns a BFDTDobject built from them.

Usage:

sim = readBristolFDTD('foo.geo')
sim = readBristolFDTD('foo.inp')
sim = readBristolFDTD('foo.in')
sim = readBristolFDTD('foo1.geo','foo2.geo','foo3.inp','foo4.in',...)
L = ['foo1.geo','foo2.geo','foo3.inp','foo4.in']
sim = readBristolFDTD(*L)
readBristolFDTD('sim1.in', 'sim2.in', verbosity=9001)
Available keyword arguments:
verbosity : integer
bfdtd.bfdtd_parser.testCylinderRotation()[source]
bfdtd.bfdtd_parser.testParallelpiped()[source]
bfdtd.bfdtd_parser.testWriting()[source]

function to test the various functions, might not create working input files, but should create the correct format can be used as a template to create new geometries

bfdtd.bfdtd_parser.truncateGeoList(geo_list, xmin, xmax, ymin, ymax, zmin, zmax)[source]

bfdtd.GeometryObjects module

Module containing the basic geometry objects available in BFDTD.

class bfdtd.GeometryObjects.Block[source]

Bases: bfdtd.GeometryObjects.GeometryObject

Create a Block.

getAABB()[source]

Returns the lower and upper corners of an Axis-Aligned Bounding Box (AABB) in absolute coordinates in the form (minBB, maxBB), where minBB = [xmin,ymin,zmin] and maxBB = [xmax,ymax,zmax].

getCentro()[source]

Returns the centre of the block (which can be different from its location). At the moment, the origin of a block can be arbitrarily defined, so keeping this around is useful.

getLowerRelative()[source]
getMEEPobject()[source]
getMeshingParameters(xvec, yvec, zvec, epsx, epsy, epsz)[source]

get meshing parameters

getSize()[source]

get the size of the block as an array of size 3

getUpperRelative()[source]
read_entry(entry)[source]

read an entry extracted from a .geo file

setLowerAbsolute(lower_absolute)[source]
setLowerRelative(lower_relative)[source]
setOriginToGeometry()[source]

Sets the origin of the block (i.e. the location) to the geometric centre of the block, without changing the absolute lower and upper coordinates.

setSize(size_vec3)[source]

size_vec3 can be a vector of size 3 or a simple int or float (vector of size 1, scalar)

setUpperAbsolute(upper_absolute)[source]
setUpperRelative(upper_relative)[source]
writeCTL(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, offset=array([0, 0, 0]))[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

write an entry to a file object

class bfdtd.GeometryObjects.Cone[source]

Bases: bfdtd.GeometryObjects.Cylinder

getInnerRadius1()[source]
getInnerRadius2()[source]
getOuterRadius1()[source]
getOuterRadius2()[source]
setInnerRadius2(inner_radius_2)[source]
setOuterRadius2(outer_radius_2)[source]
class bfdtd.GeometryObjects.Cylinder(inner_radius=None, outer_radius=None, height=None, angle_deg=None)[source]

Bases: bfdtd.GeometryObjects.GeometryObject

createBlenderObject(blender_operator, context)[source]
getAABB()[source]

Returns the lower and upper corners of an Axis-Aligned Bounding Box (AABB) in absolute coordinates in the form (minBB, maxBB), where minBB = [xmin,ymin,zmin] and maxBB = [xmax,ymax,zmax].

getAxis()[source]
getCentro()[source]
getHeight()[source]
getInnerRadius()[source]
getLowerRelative()[source]

Returns the lower corner of an Axis-Aligned Bounding Box (AABB) in coordinates relative to the location (centre of the cylinder).

getMEEPobject()[source]
getMeshingParameters(xvec, yvec, zvec, epsx, epsy, epsz)[source]
getOuterRadius()[source]
getSize()[source]
getStartEndPoints()[source]
getUpperRelative()[source]

Returns the upper corner of an Axis-Aligned Bounding Box (AABB) in coordinates relative to the location (centre of the cylinder).

read_entry(entry)[source]
setAxis(axis_vec3)[source]
setDiametre(diametre)[source]
setHeight(height)[source]
setInnerRadius(inner_radius)[source]
setOuterRadius(outer_radius)[source]
setSize(dimensions)[source]

sets size from a 3d vector of the form [2*outer_radius, 2*outer_radius, height] (if the first 2 values are different, it takes the maximum)

setStartEndPoints(start_point_vec3, end_point_vec3)[source]
writeCTL(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, offset=array([0, 0, 0]))[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

cylinder { 1-7 Coordinates of the material volume ( xc yc zc r1 r2 h ) 7 permittivity 8 conductivity 9 angle_deg of inclination }

  • xc, yc and zc are the coordinates of the centro of the cylinder. r1 and r2 are the inner and outer radius respectively
  • h is the cylinder height
  • angle_deg is the angle of inclination in degrees The cylinder is aligned with the y direction if =0 and with the x direction if =90 i.e. angle_deg = Angle of rotation in degrees around -Z=(0,0,-1)
class bfdtd.GeometryObjects.Distorted[source]

Bases: bfdtd.GeometryObjects.GeometryObject

A cuboid object with arbitrary vertex positioning.

_images/distorted_vertices.png

Vertex indices:

  • 0,1,2,3 = top face numbered clockwise viewed from outside
  • 4,5,6,7 = bottom face numbered clockwise viewed from outside

Edges:

  • 3 connected to 4
  • 2 connected to 5
  • 0 connected to 7
  • 1 connected to 6

Normal faces viewed from outside:

  • [3,2,1,0]
  • [7,6,5,4]
  • [0,1,6,7]
  • [1,2,5,6]
  • [2,3,4,5]
  • [3,0,7,4]
getCentroOfMassAbsolute()[source]

Returns the “centro of mass” of the object, i.e. sum(vertices)/8.

getMeshingParameters(xvec, yvec, zvec, epsx, epsy, epsz)[source]

todo:: improve meshing system + add support for rotations

getVerticesAbsolute()[source]

Get absolute coordinates of the object’s vertices.

getVerticesRelative()[source]

Get relative coordinates of the object’s vertices.

read_entry(entry)[source]

Read a .geo file entry.

setOrigin(location)[source]

Sets the location to the specified location, but so that the vertices keep the same absolute coordinates. This has no effect on BFDTD output, but is useful for placing objects. It is similar to changing the origin of an object in blender, while keeping the mesh in the same place. .. todo:: Rotations will complicate things here. May need to make sure it adapts the rotation accordingly.

setOriginToGeometry()[source]

Sets the origin of the object to its centro of mass.

setVerticesAbsolute(vertices_absolute)[source]

Set absolute coordinates of the object’s vertices.

setVerticesRelative(vertices_relative)[source]

Set relative coordinates of the object’s vertices.

write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

Write a .geo file entry.

class bfdtd.GeometryObjects.Ellipsoid[source]

Bases: bfdtd.GeometryObjects.Parallelepiped

class bfdtd.GeometryObjects.GeometryObject[source]

Bases: object

AABB_intersects(obj)[source]

Returns true if the bounding box of the object intersects with the one of the object obj.

getExtension()[source]
getLocation()[source]
getLowerAbsolute()[source]
getName()[source]
getRefractiveIndex()[source]
getRelativeConductivity()[source]
getRelativePermittivity(mean=True)[source]
getRotationAxisAngle()[source]
getRotationMatrix()[source]
getUpperAbsolute()[source]
rotate(axis_point, axis_direction, angle_degrees)[source]
setLocation(location)[source]
setName(name)[source]
setRefractiveIndex(n)[source]
setRelativeConductivity(conductivity)[source]
setRelativePermittivity(permittivity)[source]
setRotationAxisAngle(rotation_axis_angle)[source]
translate(vec3)[source]
writeRotations(FILE)[source]
class bfdtd.GeometryObjects.MeshBox(name=None, layer=None, group=None, lower=None, upper=None)[source]

Bases: bfdtd.GeometryObjects.GeometryObject

GeometryObject whose only function is to provide a custom “mesh box”.

Main attributes are the lists of MeshParams objects in X,Y,Z:

  • xmesh_params
  • ymesh_params
  • zmesh_params

It also provides a getMeshingParameters() function.

Note

I might keep this class, just because of rotations for the meshs… Mmh… Or is GeometryObject enough if it gets the MeshParams stuff?

getCentro()[source]
getMeshingParameters(xvec, yvec, zvec, epsx, epsy, epsz)[source]

Note

adapting and leaving this until we have time to rework the automeshing function

write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

Note

Does nothing for the moment. Could eventually add a nice little comment to the .geo or .inp file. Or we bypass it in the writeGeoFile function.

class bfdtd.GeometryObjects.Parallelepiped[source]

Bases: bfdtd.GeometryObjects.Distorted

A parallelepiped (i.e., a brick, possibly with non-orthogonal axes).

Properties:

  • location [vector3]: Center point of the object. default value: [0,0,0]
  • size [vector3]: The lengths of the block edges along each of its three axes. Not really a 3-vector, but it has three components, each of which should be nonzero. default value: [1,1,1]
  • e0, e1, e2 [vector3]: The directions of the axes of the block; the lengths of these vectors are ignored. Must be linearly independent. They default to the three lattice directions.
getAxes()[source]
getSize()[source]
setAxes(e0, e1, e2)[source]
setDirectionsAndSize(e0, e1, e2, size)[source]
setSize(size)[source]
updateVertices()[source]
class bfdtd.GeometryObjects.Rotation(name=None, axis_point=None, axis_direction=None, angle_degrees=None)[source]

Bases: object

getRotationMatrix()[source]
read_entry(entry)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
class bfdtd.GeometryObjects.Sphere[source]

Bases: bfdtd.GeometryObjects.GeometryObject

getInnerRadius()[source]
getLowerRelative()[source]
getOuterRadius()[source]
getSize()[source]

get the size of the sphere as an array of size 3

getUpperRelative()[source]
read_entry(entry)[source]
setInnerRadius(inner_radius)[source]
setOuterRadius(outer_radius)[source]
setSize(size_vec3)[source]

setSize wrapper for use in BFDTD export scripts

writeCTL(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, offset=array([0, 0, 0]))[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

BFDTD sphere object:

  • 1-5 Coordinates of the sphere ( xc yc zc r1 r2 )
  • 6 permittivity
  • 7 conductivity

bfdtd.bristolFDTD_generator_functions module

bfdtd.bristolFDTD_generator_functions.GEOcommand(filename, BASENAME)[source]

CMD file generation

bfdtd.bristolFDTD_generator_functions.GEOin(filename, file_list, overwrite=True, use_relpath=False)[source]

IN file generation

bfdtd.bristolFDTD_generator_functions.GEOshellscript(filename, BASENAME, EXE='fdtd', WORKDIR='$JOBDIR', WALLTIME=12, overwrite=True, PPN=1)[source]
bfdtd.bristolFDTD_generator_functions.GEOshellscript_advanced(filename, BASENAME, probe_col, EXE='fdtd', WORKDIR='$JOBDIR', WALLTIME=12)[source]
bfdtd.bristolFDTD_generator_functions.main()[source]

bfdtd.ellipsoid module

class bfdtd.ellipsoid.Ellipsoid(name=None, layer=None, group=None, block_direction=None, non_elliptical_directions=None)[source]

Bases: bfdtd.GeometryObjects.Block

getMeshingParameters(xvec, yvec, zvec, epsx, epsy, epsz)[source]

get meshing parameters

getVoxels()[source]
write_entry(FILE)[source]

writes the voxels to the file corresponding to the FILE handle

bfdtd.ellipsoid.test0()[source]
bfdtd.ellipsoid.test1()[source]

bfdtd.excitation module

class bfdtd.excitation.Excitation(name=None, current_source=None, P1=None, P2=None, E=None, H=None, Type=None, time_constant=None, amplitude=None, time_offset=None, frequency=None, param1=None, param2=None, template_filename=None, template_source_plane=None, template_target_plane=None, template_direction=None, template_rotation=None, layer=None, group=None)[source]

Bases: object

The base class for BFDTD excitations.

When using a gaussian sinewave, undesired effects (part of the signal cut off) might happen, if the time offset is too small compared to the time constant.

To prevent this, the writing procedure automatically checks if:

MIN_TIME_OFFSET_TIME_CONSTANT_RATIO*self.time_constant > self.time_offset.

If this is the case, there are 3 possible outcomes, depending on the value of self.TimeOffsetSafetyBehaviour:

  • self.TimeOffsetSafetyBehaviour=0 (the default): adapt the time offset by setting self.time_offset = MIN_TIME_OFFSET_TIME_CONSTANT_RATIO*self.time_constant
  • self.TimeOffsetSafetyBehaviour=1: raise an Exception
  • self.TimeOffsetSafetyBehaviour=2: ignore and continue writing

Note

You can change MIN_TIME_OFFSET_TIME_CONSTANT_RATIO in interactive mode as follows: bfdtd.excitation.MIN_TIME_OFFSET_TIME_CONSTANT_RATIO=42

From MEEP documentation. Not fully implemented yet, but the plan is to clearly and accurately document the sources and make it easier to get exactly what we want. It is possible that BFDTD gaussian sources behave differently than MEEP sources. BFDTD sources do not seem to have a proper cutoff for instance, or at least not properly return to zero and stay there.

Note

Units: Usually DISTANCE=1μm, so that frequencies are in MHz and times in μs.

Gaussian source:

A Gaussian-pulse source roughly proportional to exp( − iωt − (t − t0)^2 / (2*w^2)). cf MEEP documentation.

Attributes:

  • frequency [number]:

    The center frequency f in units of (m/s)/DISTANCE (or ω in units of 2π*(m/s)/DISTANCE).

    No default value.

    You can instead specify:

    • wavelength = c0/f in units of DISTANCE
    • period = 1/f in units of DISTANCE/(m/s)
  • width [number]:

    The width w used in the Gaussian. No default value. You can instead specify:

    • fwidth x, which is a synonym for (width (/ 1 x)) (i.e. the frequency width is proportional to the inverse of the temporal width)
    • FWHM_time
    • FWHM_frequency
    • FWHM_angular_frequency
  • start-time [number]:

    The starting time for the source; default is 0 (turn on at t = 0). (Not the time of the peak! See below.) You can instead specify:

    • end-time
    • peak-time
  • cutoff [number]:

    How many widths the current decays for before we cut it off and set it to zero—this applies for both turn-on and turn-off of the pulse. The default is 5.0. A larger value of cutoff will reduce the amount of high-frequency components that are introduced by the start/stop of the source, but will of course lead to longer simulation times. The peak of the gaussian is reached at the time t0= start-time + cutoff*width.

check()[source]

Checks the excitation for common mistakes.

checkPeriodvsTimeConstant(raise_exception=False)[source]
disableAutoFix()[source]
disableSafetyChecks()[source]
enableAutoFix()[source]
enableSafetyChecks()[source]
fix()[source]

Automatically fix common mistakes.

getAdaptedTimeOffset()[source]

Returns MIN_TIME_OFFSET_TIME_CONSTANT_RATIO*self.time_constant

cf setTimeOffset()

getAmplitude()[source]
getCentro()[source]
getEndTime()[source]

cf setTimeOffset()

getExcitedComponentNames()[source]
getExtension()[source]
getFrequency()[source]
getFrequencyMax()[source]
getFrequencyMin()[source]
getFrequencyRange()[source]
getLambda()[source]
getLocation()[source]
getMeshingParameters(xvec, yvec, zvec, epsx, epsy, epsz)[source]
getName()[source]
getPeakTime()[source]

cf setTimeOffset()

getPeriod()[source]
getSize()[source]
getStartTime()[source]

cf setTimeOffset()

getTimeConstant()[source]
getTimeOffset()[source]

cf setTimeOffset()

getWavelength()[source]
getWavelengthMax()[source]
getWavelengthMin()[source]
getWavelengthRange()[source]
printInfo()[source]
read_entry(entry)[source]
setAmplitude(amplitude)[source]
setCentro(nova_centro)[source]
setEndTime(end_time)[source]

cf setTimeOffset()

setEx()[source]
setExtension(P1, P2)[source]
setEy()[source]
setEz()[source]
setFrequency(freq_MHz)[source]
setFrequencyRange(fmin, fmax, autofix=False)[source]

Sets central frequency and frequency width so that the FFT of the pulse covers from fmin to fmax.

Formulas used:

  • frequency = 0.5*(fmin+fmax)
  • time_constant = 1/(4*(fmax-fmin))
setLambda(lambda_mum)[source]
setLocation(loc)[source]
setName(name)[source]
setPeakTime(peak_time)[source]

cf setTimeOffset()

setPeriod(period)[source]
setSize(size_vec3)[source]
setStartTime(start_time)[source]

cf setTimeOffset()

setTimeConstant(time_constant)[source]
setTimeOffset(time_offset=None)[source]

Set the time offset. If time_offset is None, it adapts the time offset by setting self.time_offset = MIN_TIME_OFFSET_TIME_CONSTANT_RATIO*self.time_constant

The time offset can be get/set using the following three alternatives:

_images/excitation_doc_annotated.png
setWavelength(lambda_mum)[source]
setWavelengthRange(lambda_min, lambda_max)[source]
translate(vec3)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, AutoFix=True, SafetyChecks=True)[source]

write entry into FILE .. todo:: reduce code duplication here .. todo:: Should fix+check functions be called from BFDTDobject? Or should fix+check args be passed to write_entry? or should object’s AutoFix/SafetyChecks be modified from BFDTDobject?

Every function should do one thing and do it well -> no fix+check in here Having fix+check in here reduces risk of accidental bad output writing -> fix+check should be in here

Writing bad output should be made difficult, but not too difficult for testing purposes.

class bfdtd.excitation.ExcitationWithGaussianTemplate(name=None, layer=None, group=None, centre=None, sigma_x=None, sigma_y=None, amplitude=None, plane_direction=None, excitation_direction=None, frequency=None, template_filename=None, mesh=None)[source]

Bases: bfdtd.excitation.Excitation

getTemplate()[source]
updateTemplate()[source]
write_entry(FILE)[source]

write entry into FILE .. todo:: reduce code duplication here .. todo:: Should fix+check functions be called from BFDTDobject? Or should fix+check args be passed to write_entry? or should object’s AutoFix/SafetyChecks be modified from BFDTDobject?

Every function should do one thing and do it well -> no fix+check in here Having fix+check in here reduces risk of accidental bad output writing -> fix+check should be in here

Writing bad output should be made difficult, but not too difficult for testing purposes.

class bfdtd.excitation.ExcitationWithUniformTemplate(name=None, layer=None, group=None, centre=None, amplitude=None, plane_direction=None, excitation_direction=None, frequency=None, template_filename=None, mesh=None)[source]

Bases: bfdtd.excitation.Excitation

getTemplate()[source]
updateTemplate()[source]
write_entry(FILE)[source]

write entry into FILE .. todo:: reduce code duplication here .. todo:: Should fix+check functions be called from BFDTDobject? Or should fix+check args be passed to write_entry? or should object’s AutoFix/SafetyChecks be modified from BFDTDobject?

Every function should do one thing and do it well -> no fix+check in here Having fix+check in here reduces risk of accidental bad output writing -> fix+check should be in here

Writing bad output should be made difficult, but not too difficult for testing purposes.

bfdtd.excitationTemplate module

class bfdtd.excitationTemplate.ExcitationGaussian1(amplitude=1, beam_centre_x=0, beam_centre_y=0, sigma_x=1, sigma_y=1, out_col_name='z', column_titles=['x', 'y', 'z'], fileName='template.dat')[source]

Bases: object

gaussian excitation template object which creates a 2D gaussian surface with a central maximum point

writeDatFile(fileName, overwrite=True)[source]

Generate template .dat file for a plane excitation

class bfdtd.excitationTemplate.ExcitationGaussian2(amplitude=1, beam_centre_x=0, beam_centre_y=0, c=1, sigma=2, out_col_name='z', column_titles=['x', 'y', 'z'], fileName='template.dat')[source]

Bases: object

gaussian excitation template object which creates a 2D gaussian surface with a circular maximum of radius c

writeDatFile(fileName, overwrite=True)[source]

Generate template .dat file for a plane excitation

class bfdtd.excitationTemplate.ExcitationUniform(amplitude=None, out_col_name=None, column_titles=None, fileName=None, x_list=None, y_list=None)[source]

Bases: object

gaussian excitation template object which creates a 2D gaussian surface with a circular maximum of radius c

writeDatFile(fileName, overwrite=True)[source]

Generate template .dat file for a plane excitation

bfdtd.excitation_utilities module

bfdtd.excitation_utilities.ExcitationWrapper(Ysym, centre, size, plane_direction, type, excitation_direction, frequency, template_filename='template.dat')[source]

Returns an Excitation and Template object: (excitation, template)

  • Ysym: adapt source extension for “Y symetric simulation”? (boolean value)
  • centre: centre of the source for 2D source or P1 for 1D source
  • size: the sigma value for the gaussian 2D source or the distance between P1 and P2 for a 1D source
  • plane_direction: emission direction of the source (i.e. orthogonal direction to the source plane or excitation direction)
  • type: ‘1D’ or ‘2D’:
  • excitation_direction: direction of the E field
  • frequency: frequency of the excitation
  • template_filename: name of the template file
bfdtd.excitation_utilities.QuadrupleExcitation(Ysym, bfdtd_object, P, propagation_direction, delta, template_radius, freq, exc)[source]

Adds an Excitation object and, if necessary, a corresponding Template object to the BFDTDobject “bfdtd_object”.

  • Ysym: adapt source extension for “Y symetric simulation”?
  • bfdtd_object: BFDTDobject to which to add the Excitation+Template
  • P: centre of the source for 2D source or P1 for 1D source
  • propagation_direction: emission direction of the source (i.e. orthogonal direction to the source plane or excitation direction)
  • delta: the distance between P1 and P2 for a 1D source (ONLY VALID FOR 1D SOURCE)
  • template_radius: the sigma value for the gaussian 2D source (ONLY VALID FOR 2D SOURCE)
  • freq: frequency of the excitation
  • exc: type of excitation desired:
    • exc=0: 1D, excitation_direction = ‘propagation_direction + 1 in the (x,y,z) cycle’
    • exc=1: 1D, excitation_direction = ‘propagation_direction + 2 in the (x,y,z) cycle’
    • exc=2: 2D, excitation_direction = ‘propagation_direction + 1 in the (x,y,z) cycle’
    • exc=3: 2D, excitation_direction = ‘propagation_direction + 2 in the (x,y,z) cycle’

bfdtd.meshobject module

Note

Doc cleanup. Disregard this at the moment.

Note

The following class names are all temporary and subject to change!

class bfdtd.meshobject.MeshObject[source]

Bases: bfdtd.BFDTDentry.BFDTDentry

3D mesh class.

Just an object to store xmesh,ymesh,zmesh values, with various related utility functions like writeMesh(FILE) Each BFDTDobject uses a single such MeshObject.

attributes:

  • xmesh: list of the position (not a thickness list!) of each line of the mesh in the x direction
  • ymesh: list of the position (not a thickness list!) of each line of the mesh in the y direction
  • zmesh: list of the position (not a thickness list!) of each line of the mesh in the z direction

Example:

xmesh = [0, 0.25, 0.5, 0.75, 1] will create a [0.25, 0.25, 0.25, 0.25] thickness sequence in the XMESH object of the .inp file.
getExtension()[source]
getIndexRange(lower, upper, direction=0)[source]

Convenience function to get absolute and relative index ranges based on a given real coordinates based block volume.

Returns (idx_L, idx_U, relative_index_range_x, relative_index_range_y, relative_index_range_z)

getMesh()[source]
getMeshDelta()[source]
getMinDeltas()[source]
getNcells()[source]

Returns the number of cells in the mesh.

getNearest(P, direction=0)[source]
getSizeAndResolution()[source]
getXmesh()[source]
getXmeshCentres()[source]
getXmeshDelta()[source]
getYmesh()[source]
getYmeshCentres()[source]
getYmeshDelta()[source]
getZmesh()[source]
getZmeshCentres()[source]
getZmeshDelta()[source]
setMesh(xmesh, ymesh, zmesh)[source]
setMeshDelta(xmesh_delta, ymesh_delta, zmesh_delta)[source]
setSizeAndResolution(size_vec3, N_vec3, Ncells_per_unit=False)[source]

Sets the size and resolution in all 3 directions.

The Ncells_per_unit=True option can be used to obtain MEEP/MPB-like behaviour, i.e. resolution will be in cells per distance unit, i.e. cells/micron or cells/metre. In this case, the number of cells in a given direction is set to N[i] = ceil(N_vec3[i] * size_vec3[i]), i.e. increased resolution is preferred if size is not integer.

setXmesh(xmesh)[source]
setXmeshDelta(xmesh_delta)[source]
setYmesh(ymesh)[source]
setYmeshDelta(ymesh_delta)[source]
setZmesh(zmesh)[source]
setZmeshDelta(zmesh_delta)[source]
writeMesh(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>)[source]

writes mesh to FILE .. todo:: should be renamed to write_entry() for better standardization… (+ choose better name than write_entry() for all, like write(), writeEntry()?)

class bfdtd.meshobject.MeshingParameters[source]

Bases: object

Object containing parameters that can be used for meshing (with the subGridMultiLayer() function for example). The getMeshingParameters() of the various BFDTD objects return such an object for example.

List of attributes:
  • maximum permittivity lists * maxPermittivityVector_X * maxPermittivityVector_Y * maxPermittivityVector_Z
  • thickness lists * thicknessVector_X * thicknessVector_Y * thicknessVector_Z
  • limit lists * limits_X * limits_Y * limits_Z
addLimits_X(limits, permittivity)[source]
addLimits_Y(limits, permittivity)[source]
addLimits_Z(limits, permittivity)[source]
bfdtd.meshobject.increaseResolution3D(mesh_orig, Nx, Ny, Nz)[source]

Applies increaseResolution() to all three directions and return a new MeshObject.

bfdtd.snapshot module

This module defines the basic snapshots and some additional snapshot objects for convenience.

digraph snapshot_system_diagram {
"Snapshot" -> "FrequencySnapshot"
"Snapshot" -> "TimeSnapshot"

"FrequencySnapshot" -> "EnergySnapshot"
"EnergySnapshot" -> "ModeVolumeBox"
"ModeVolumeBox" -> "ModeVolumeBoxFull"

"TimeSnapshot" -> "ModeFilteredProbe"
"TimeSnapshot" -> "EpsilonSnapshot"

"EpsilonSnapshot" -> "EpsilonBox"
"EpsilonBox" -> "EpsilonBoxFull"

"SnapshotBox" -> "SnapshotBoxXYZ"
"SnapshotBox" -> "SnapshotBoxSurface"
"SnapshotBox" -> "SnapshotBoxVolume"
}

Deprecated notes. To be updated at some point.:

  • IDEA:
    • main bfdtd class writer calls snap.write(file, mesh)
    • main snap class defines mainwrite(file, mesh, subwrite) (which writes one or multiple snap entries to file)
    • sub snap classes (freq,time,etc) define subwrite() (which just writes single snap entry to file)
    • sub snap classes define write(file, mesh) which calls mainwrite(file, mesh, subwrite)
  • NOTES:
    • When P1,P2 do not form a plane, a single snapshot is created at X1 if plane=1, Y1 if plane=2, Z1 if plane=3, i.e. P1 is used for positioning the slice.
    • When coordinates in P1 or P2 do not correspond to a mesh point, they are snapped to the closest one.
    • When X1>X2 or similar: Behaviour unknown!!!
  • Writing methods:
    • single plane if (P1,P2) form a plane.
    • 6 planes, one on each side if (P1,P2) form a box.
    • N planes in X, Y or Z based on mesh if (P1,P2) form a box.
    • 3 planes (X,Y,Z) intersecting at (P1+P2)/2.
  • The main writing function should be the same for all snapshots and call the specific writing functions depending on an attribute defining which one is desired.
  • The specific writing functions of the base class should be overridden in the child classes.
class bfdtd.snapshot.EnergySnapshot[source]

Bases: bfdtd.snapshot.FrequencySnapshot

getSplitSnapshots()[source]

Returns the epsilon and frequency snapshots that would be used.

setFromSnapshot(snapshot_in)[source]

Copies the properties from snapshot_in.

setupEpsilonSnapshot()[source]
write_data(sampling_function, mesh=None, numID=0, probe_ident='_id_', snap_time_number=0, destdir='.')[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.EpsilonBox[source]

Bases: bfdtd.snapshot.EpsilonSnapshot

write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.EpsilonBoxFull[source]

Bases: bfdtd.snapshot.EpsilonBox

write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.EpsilonSnapshot[source]

Bases: bfdtd.snapshot.TimeSnapshot

Child class of TimeSnapshot, which disables all output columns except epsilon.

setDefaults()[source]

Sets the following properties:

  • self.E = [0,0,0]
  • self.H = [0,0,0]
  • self.J = [0,0,0]
  • self.power = 0
  • self.eps = 1
  • self.first = 1
  • self.repetition = int(1e9)
setFromSnapshot(snapshot_in)[source]

Copies the properties from snapshot_in, but then calls EpsilonSnapshot.setDefaults().

class bfdtd.snapshot.FrequencySnapshot[source]

Bases: bfdtd.snapshot.Snapshot

Simple base class for all single-entry BFDTD snapshots written as FREQUENCY_SNAPSHOT in .inp files.

Attributes:

  • interpolate: 0 or 1
  • real_dft: 0 or 1
  • mod_only: 0 or 1
  • mod_all: 0 or 1
  • frequency_vector: float vector
  • starting_sample: integer

The format of a frequency snapshot object is:

    1. first: iteration number for the first snapshot
    1. repetition: number of iterations between snapshots
    1. interpolate:
    • If set to 1 : the H field samples are interpolated to give the value at the plane of the E field nodes
    • If set to 2 : as above but the field values are multiplied by the area of the cell on the plane and interpolated to the centre of the square in the plane of the E field nodes..
    • If set to 3 : as above but the order of the field components in the output file is changed so that for the x,y and z planes the order is (yzx), (zxy) and (xyz) respectively instead of always being (xyz)
    • If set to 4 : as for 2 except that all 3 coordinates are given for each point
    1. real_dft: Set this if it is not required to write the imaginary component to file
    1. mod_only: Write only the modulus to file
    1. mod_all: Write the modulus AND the real and imaginary parts to file
    1. plane: 0=all, 1=x, 2=y, 3=z
  • 8-13) P1,P2: coordinates of the lower left and top right corners of the plane P1(x1,y1,z1), P2(x2,y2,z2)

    1. frequency_vector: frequency (in MHz! ). Will create a frequency snapshot for each frequency in the list/vector
    1. starting_sample: iteration number at which to start the running fourier transforms
  • 16-24) E,H,J: field components to be sampled E(Ex,Ey,Ez), H(Hx,Hy,Hz), J(Jx,Jy,Jz)

The output file is of the same format as the snapshot “list format” and the naming is the same except that the time serial number starts at “00” instead of “aa”.

Clarification on how real_dft, mod_only and mod_all work:

  • if mod_only or mod_all: output mod
  • if not(mod_only): output real part
  • if not(real_dft) and not(mod_only): output imaginary part

Or in table form:

Inputs Output
real_dft mod_only mod_all |field| real(field) imag(field)
0 0 0 0 1 1
0 0 1 1 1 1
0 1 0 1 0 0
0 1 1 1 0 0
1 0 0 0 1 0
1 0 1 1 1 0
1 1 0 1 0 0
1 1 1 1 0 0

Note

J output does not work at the moment. This is a Bristol FDTD related issue.

fillData(data3D, x_idx, y_idx, z_idx, header, row)[source]
getFileNames(fsnap_numID=1, tsnap_numID=1, probe_ident='_id_', snap_time_number=0)[source]
getFrequencies()[source]
getLambda()[source]

Get the wavelength list.

getOutputColumnHeaders()[source]
getOutputColumnHeadersSubFunction(field)[source]
getStartingSample()[source]
read_entry(entry)[source]
setFrequencies(frequency_vector)[source]

Set the frequencies of the frequency snapshot.

setFromSnapshot(snapshot_in)[source]

Copies the properties from snapshot_in.

setStartingSample(starting_sample)[source]

dummy function, to be re-implemented in subclasses, such as FrequencySnapshot .. todo:: Why not just give it to all? no need for FrequencySnapshot defining it then…

setWavelengths(wavelength_vector)[source]
write_data_row(csvwriter, sampling_function, x, y, z, t)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.ModeFilteredProbe[source]

Bases: bfdtd.snapshot.TimeSnapshot

Child class of TimeSnapshot, which disables all output columns. This leads to a mode filtered probe behaviour.

Unlike usual time and epsilon snapshots, the ModeFilteredProbe output filenames start with “i” instead of “x/y/z” and start with a 0 index instead of 1, i.e. the first ModeFilteredProbe output file will be “i1_id_00.prn” instead of “x1_id_01.prn”.

Requires a “template”. The default template filename is “template.int”.

The output columns are always:

#Time inner_product_e inner_product_h inner_product_poynting sum difference
class bfdtd.snapshot.ModeVolumeBox[source]

Bases: bfdtd.snapshot.EnergySnapshot

This one is definitely necessary and should be as easy to use as possible.

The other necessity is an EpsilonBox for geometry checking. Perhaps with Nx,Ny,Nz specification for mesh independence.

setupEnergySnapshotBox()[source]
write_data(sampling_function, mesh=None, numID=0, probe_ident='_id_', snap_time_number=0, destdir='.')[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.ModeVolumeBoxFull[source]

Bases: bfdtd.snapshot.ModeVolumeBox

Example usage:

MV=ModeVolumeBoxFull()
sim.appendSnapshot(MV)
getEnergySnapshots(mesh=None)[source]

Returns the energy snapshots that would be written. Useful for counting the resulting number of snapshots and split-writing. .. todo:: create this function at a lower level, so it works for other boxes, etc + make use of it when finally writing

getSplitSnapshots(mesh=None)[source]

Returns the epsilon and frequency snapshots that would be used.

setup(mesh=None)[source]

to call before using .. todo:: mesh keeps having to be passed arround. Define as attribute?

write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.Snapshot[source]

Bases: object

Simple base class for all single-entry BFDTD snapshots.

Attributes:

  • first: integer
  • repetition: integer
  • plane: integer
  • P1: 3D vector
  • P2: 3D vector
  • E: 3D vector
  • H: 3D vector
  • J: 3D vector

Note

Plane snapshots will never output data for the upper edges of the simulation box.

Example: Box from (0,0,0) to (1,1,1) with Z snapshot from (0,0) to (1,1) -> Snapshot output will not contain any points along the x=1 and y=1 lines.

A Z snapshot at z=1 will however still output data!

getCentro()[source]
getEfield()[source]
getExtension()[source]

Returns the extension, i.e. (lower, upper) = (P1,P2).

getFirst()[source]
getHfield()[source]
getJfield()[source]
getLower()[source]

Returns the lower corner (P1).

getMeshingParameters(xvec, yvec, zvec, epsx, epsy, epsz)[source]
getName()[source]
getPlaneBfdtdIndex()[source]
getPlaneLetter()[source]

return letter describing plane orientation (‘x’,’y’ or ‘z’)

getPlanePythonIndex()[source]
getRepetition()[source]
getSize()[source]
getTypeBasedOnAttributes()[source]

Returns class by default, but overloaded in the TimeSnapshot class to differentiate time and epsilon snapshots.

getUpper()[source]

Returns the upper corner (P1).

plane

orientation of the snapshot plane

read_data(data3D, mesh=None, fsnap_numID=1, tsnap_numID=1, probe_ident='_id_', snap_time_number=0, dataPaths=['.'], testrun=False)[source]
setCentro(centro_vec3)[source]

Reposition the snapshot so that (P1+P2)/2 = centro_vec3, i.e. its centre is at centro_vec3.

setEfield(E_vec3)[source]
setExtension(lowerCorner_vec3, upperCorner_vec3)[source]

Set the extension of the snapshot, i.e. its lower and upper corners.

If you have an (L,U) tuple like the one you get from getExtension(), you can pass it directly via python’s unpacking feature as follows:

obj.setExtension(*sim.getExtension())
setExtensionFromSnapshot(snapshot_in)[source]

Copies the P1, P2 and plane attributes from snapshot_in, i.e. the extension and the plane orientation.

setExtensionX(x1, x2)[source]
setExtensionY(y1, y2)[source]
setExtensionZ(z1, z2)[source]
setFirst(first)[source]
setFromSnapshot(snapshot_in)[source]

Copies the properties from snapshot_in.

setFullExtensionOff()[source]
setFullExtensionOn()[source]
setGroup(group)[source]
setHfield(H_vec3)[source]
setJfield(J_vec3)[source]
setLayer(layer)[source]
setName(name)[source]
setPlaneBfdtdIndex(bfdtd_index)[source]
setPlaneLetter(plane_letter)[source]

set plane orientation by passing ‘x’,’y’ or ‘z’

setPlaneOrientationX()[source]
setPlaneOrientationY()[source]
setPlaneOrientationZ()[source]
setPlanePythonIndex(python_index)[source]
setRepetition(repetition)[source]
setSize(size_vec3)[source]

Set the size of the snapshot, i.e. [size_x, size_y, size_z] = P2 - P1.

Parameters:size_vec3 – A list or array of length 3, or a scalar int or float value. If a scalar S is passed, the size vector [S, S, S] will be used.
setStartingSample(starting_sample)[source]

dummy function, to be re-implemented in subclasses, such as FrequencySnapshot .. todo:: Why not just give it to all? no need for FrequencySnapshot defining it then…

setUseForMeshing(useForMeshing)[source]
write_data(sampling_function, mesh=None, numID=0, probe_ident='_id_', snap_time_number=0, destdir='.')[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.SnapshotBox[source]

Bases: object

A base class representing a snapshot box instead of a snapshot plane like the Snapshot class.

It has one attribute:
  • baseSnapshot

Its purpose is to be used by child classes implementing a write_entry function, which will write snapshot planes based on baseSnapshot in various ways.

getBaseSnapshot()[source]
getExtension()[source]
getName()[source]
setBaseSnapshot(baseSnapshot)[source]
setExtension(lowerCorner_vec3, upperCorner_vec3)[source]
setFirst(starting_sample)[source]
setRepetition(starting_sample)[source]
setStartingSample(starting_sample)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.SnapshotBoxSurface[source]

Bases: bfdtd.snapshot.SnapshotBox

A utility class to easily create 6 snapshots on the surface of a box.

Dilemma:
  • create boxsurface, boxvolume, etc classes which then write various snapshot types
  • or different snapshot types, which can then be written using boxsurface, boxvolume, etc writing functions?
Solution 1 seems better. One or more snapshot classes could be passed to the writing function or as attribute…
Also writing functions are more likely to increase, compared to the relatively static BFDTD.
And if BFDTD does add new snapshot types, we should be able to derive them relatively easily from the base classes.
Base classes should remain as simple as possible.
problem: redefining all attributes and passing them…
Maybe we should still go with including functions in the base Snapshot class?
No, just inherit from Snapshot and redefine the writing function.
But how to deal with the different types of snapshots?
This would mean N*M classes for N snapshots and M writing methods.
Better to pass a prepared snapshot to the writing classes, leading to N+M classes, but allowing for the same N*M behaviours!
Snapping to the mesh should be done by the user outside this module.
This gives more flexibility while keeping this module simple.
Some utilities for snapping already exist ion the mesh class or elsewhere and more can be added.
Once the meshing system is properly developed, all objects can easily access such functions to snap to the mesh or other similar operations. (ex: 50 snaps, but all on mesh, centered on snap i…)
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.SnapshotBoxVolume[source]

Bases: bfdtd.snapshot.SnapshotBox

Fill the volume corresponding to the box defined by (P1,P2) with snapshots based on the given baseSnapshot.

setPlaneOrientationX()[source]
setPlaneOrientationY()[source]
setPlaneOrientationZ()[source]
setupSnapshots(mesh=None)[source]
write_data(sampling_function, mesh=None, numID=0, probe_ident='_id_', snap_time_number=0, destdir='.')[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.SnapshotBoxXYZ[source]

Bases: bfdtd.snapshot.SnapshotBox

getIntersectionPoint()[source]
setIntersectionPoint(point)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.TimeSnapshot[source]

Bases: bfdtd.snapshot.Snapshot

Simple base class for all single-entry BFDTD snapshots written as SNAPSHOT in .inp files.

Attributes:

  • power: 0 or 1
  • epsilon: 0 or 1

One or more field components may be sampled over a specified plane in the structure after a specified number of iterations. It is possible to take snapshots after every “n” iterations by setting the “iterations between snapshots” parameter to “n”.

For each snapshot requested a file is produced in one of two formats:

  • List format which has a filename of the form “x1idaa.prn”, where “x” is the plane over which the snapshot has been taken, “1”is the snapshot serial number. ie. the snaps are numbered in the order which they appear in the input file.. “id” in an identifier specified in the “flags” object. “aa” is the time serial number ie. if snapshots are asked for at every 100 iterations then the first one will have “aa, the second one “ab” etc The file consists of a single header line followed by columns of numbers, one for each field component wanted and two for the coordinates of the point which has been sampled. These files can be read into Gema.
  • Matrix format for each snapshot a file is produced for each requested field component with a name of the form “x1idaa_ex” where the “ex” is the field component being sampled. The rest of the filename is tha same as for the list format case. The file consists of a matrix of numbers the first column and first row or which, gives the position of the sample points in each direction. These files can be read into MathCad or to spreadsheet programs.

The format of the snapshot object is as follows:

  • 1 : first: iteration number for the first snapshot
  • 2 : repetition: number of iterations between snapshots
  • 3 : plane: 1=x,2=y,3=z
  • 4-9 : P1, P2: coordinates of the lower left and top right corners of the plane P1(x1,y1,z1), P2(x2,y2,z2)
  • 10-18 : E, H, J: field components to be sampled E(Ex,Ey,Ez), H(Hx,Hy,Hz), J(Jx,Jy,Jz)
  • 19 : power: print power? =0/1
  • 20 : eps: create EPS (->epsilon->refractive index) snapshot? =0/1
  • 21 : ???: write an output file in “list” format (NOT IMPLEMENTED YET)(default is list format)
  • 22 : ???: write an output file in “matrix” format (NOT IMPLEMENTED YET)

Mode filtered probe files (Requires a template for the first excitation object!):

Mode filtered probe files are specified in the same way as a snapshot across the reference plane except that no field components are selected, i.e. E=H=J=power=eps=(0,0,0). In addition, the “repetition” parameter takes the role which the “step” parameter does on normal probes.

The output will have the same form as a probe file and will consist of the inner product at each time step of the field distribution across the reference plane with the template specified for the first excitation object. This template will normally be the wanted mode of the guiding structure and, thus, the output of this probe will be the amplitude of just this mode.

The effect of this is that the amplitude of the mode of interest is sampled across the whole waveguide cross-section. If a normal field probe had been used, then the unwanted effects of other modes would cause inaccuracies in the final result.

Note

JX,JY,JZ output does not seem to work. (Bristol FDTD issue)

The output columns are (assuming all columns were enabled):

  • For X planes:

    #y z Ex Ey Ez Hx Hy Hz Pow material 
    
  • For Y planes:

    #x z Ex Ey Ez Hx Hy Hz Pow material 
    
  • For Z planes:

    #x y Ex Ey Ez Hx Hy Hz Pow material 
    
fillData(data3D, x_idx, y_idx, z_idx, header, row)[source]
getEpsilon()[source]
getFileNames(fsnap_numID=1, tsnap_numID=1, probe_ident='_id_', snap_time_number=0)[source]
getOutputColumnHeaders()[source]
getPower()[source]
getTypeBasedOnAttributes()[source]

Returns the “type” of the snapshot based on the selected output columns (E, H, J, power and epsilon).

  • If all output columns are disabled: ModeFilteredProbe
  • If all output columns are disabled, except epsilon: EpsilonSnapshot
  • Else: TimeSnapshot

Or in table form:

Attributes Output
E H J Power Epsilon Type
000 000 000 0 0 ModeFilteredProbe
000 000 000 0 1 EpsilonSnapshot
* * * * * TimeSnapshot
read_entry(entry)[source]
setEpsilon(eps)[source]
setPower(power)[source]
write_data_row(csvwriter, sampling_function, x, y, z, t)[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.TimeSnapshotBox[source]

Bases: bfdtd.snapshot.TimeSnapshot

setupSnapshotBox()[source]
write_data(sampling_function, mesh=None, numID=0, probe_ident='_id_', snap_time_number=0, destdir='.')[source]
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
class bfdtd.snapshot.TimeSnapshotBoxFull[source]

Bases: bfdtd.snapshot.TimeSnapshotBox

Example usage:

Tbox=TimeSnapshotBoxFull()
sim.appendSnapshot(Tbox)
write_entry(FILE=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, mesh=None)[source]
bfdtd.snapshot.test_interactive()[source]

bfdtd.triangular_prism module

class bfdtd.triangular_prism.TriangularPrism(name='triangularprism', layer='triangularprism', group='triangularprism', lower=[0, 0, 0], upper=[1, 1, 1], permittivity=1, conductivity=0, Nvoxels=10, orientation=[0, 1, 2])[source]

Bases: bfdtd.GeometryObjects.GeometryObject

Creates prism without 45 degree mirrors. Should be superseded by the current SpecialTriangularPrism completely at one point.

getCenter()[source]
getVoxels()[source]
write_entry(FILE)[source]

Module contents

This module contains BFDTD related code. However, it might be extended to more general FDTD utilities later, so it can be used with other FDTD software.