Table Of Contents

Previous topic

ScatPy.results

Next topic

ScatPy.utils

This Page

ScatPy.targets

Target definitions.

Inheritance Diagram

Inheritance diagram of ScatPy.targets

Class Summary

Base Classes

Otherclasses derive from these. Generally not intended to be used on their own.

Target([directive, sh_param, material, ...]) The base class for defining DDscat Target geometries.
Target_Builtin(directive[, d, material, folder]) Base class for the standard target geometries that are built into DDSCAT.
Periodic Base class for periodic targets

Isolated Builtin Targets

Classes for defining isolated finite targets based on target definitions built into DDSCAT.

Target_Builtin(directive[, d, material, folder]) Base class for the standard target geometries that are built into DDSCAT.
RCTGLPRSM(phys_shape[, d, material, folder]) A rectangular prism target
CYLNDRCAP(length, radius[, d, material, folder]) Homogeneous, isotropic finite cylinder with hemispherical endcaps.
ELLIPSOID(semiaxes[, d, material, folder]) An Ellipsoid target
CYLINDER(length, radius, orient[, d, ...]) Homogeneous, isotropic finite cylinder
Sphere(radius[, d, material, folder]) A Sphere target.
Cube(length[, d, material, folder]) A Cube target.

Arbitrarily Shaped Targets

Classes for defining isolated finite targets of arbitrary shape.

FROM_FILE([grid, d, material, folder]) Base class for targets of arbitrary geometry.
FRMFILPBC([grid, period, d, material, ...]) Base class for periodic targets of arbitrary geometry.
Iso_FROM_FILE([grid, d, material, folder]) Base class for targets of arbitrary geometry with isotropic materials.
Ellipsoid_FF(semiaxes[, d, material, folder]) Build an ellipsoidal target to be loaded from file
Helix(height, pitch, major_r, minor_r[, d, ...]) A helix target.
SpheresHelix(height, pitch, major_r, ...[, ...]) A helix target composed of isolated spheres
Conical_Helix(height, pitch1, pitch2, ...[, ...]) A helix target

Periodic Targets

Classes for defining targets with 1D and 2D semi-infinite periodicity.

Periodic Base class for periodic targets
FRMFILPBC([grid, period, d, material, ...]) Base class for periodic targets of arbitrary geometry.
RCTGL_PBC(phys_shape, period[, d, material, ...]) A target of periodic rectangular prisms.
CYLNDRPBC(length, radius, orient, period[, ...]) A target of periodic cylinders.

Class Definitions

Target definitions.

ScatPy.targets.default_d = 0.015

Default spacing between dipoles (in um)

class ScatPy.targets.Target(directive=None, sh_param=None, material=None, aeff=None, folder=None)[source]

Bases: object

The base class for defining DDscat Target geometries.

Parameters:
  • directive – The type of target (e.g. ‘CYLINDER1’, ‘FROM_FILE’)
  • sh_param – The three shape parameters used by DDSCAT to describe the target
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.

As it is, this class creates generic targets, which contain only a directive, sh_param, material and aeff: the bare minimum necessary to write a ddscat.par file. It is intended to provide an interface as close as possible to bare DDSCAT target definitions. It uses dipole units rather than subclasses which should use physical units.

Typically, this class will be subclassed to create more useful and feature- rich targets. Derived classes must provide the following attributes and methods: * sh_param: A property that returns the three values of the SHPAR definition used by DDSCAT * _calc_N(): A static method to calculate the number of dipoles based on the shape parameters * fromfile(): A class method to generate a working object from a ddscat.par file

save_str()[source]

Return the multi-line target definition string for the ddscat.par file

write()[source]
VTRconvert(outfile=None)[source]

Execute VTRconvert to generate a file for viewing in Paraview

folder[source]

The target working directory

copy()[source]
classmethod fromfile(fname)[source]

Load target definition from the specified file.

If the target directive matches the name of an existing target class then object creation is delegated to that class.

make_periodic(period)[source]

Return a periodic version of this target, if one is available.

Period:The unit vector in um. A component = 0: no repetition
class ScatPy.targets.Target_Builtin(directive, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Target

Base class for the standard target geometries that are built into DDSCAT.

Parameters:
  • directive – The type of target (e.g. ‘CYLINDER1’, ‘ELLIPSOID’)
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.

Typically, this class will be subclassed to create more useful and feature- rich targets. Classes should take their names from the name used by DDSCAT (e.g. RCTGLPRSM, ELLIPSOID).

Target subclasses constructed with :class:Target_Builtin are intended to work with physical units rather than dipole units used in :class:Target. Therefore, derived classes must provide the following attributes and methods for converting between physical dimensions and the internal representation understood by DDSCAT: * sh_param: A property that returns the three values of the SHPAR definition used by DDSCAT * _calc_N(): A static method to calculate the number of dipoles based on the shape parameters * fromfile(): A class method to generate a working object from a ddscat.par file

sh_param[source]

Unimplemented method for calculating the shape parameters.

Subclasses must implement this themselves. The method should take the internally stored physical dimensions (e.g. self.radius, self.length) and translate them into the shape parameters DDSCAT expects for this target type.

This would be a good application for ABCs.

classmethod fromfile(fname)[source]

Unimplemented method for loading target from file.

Subclasses must implement this themselves. The form is to load the target information from the par file using _read_values(). Then parse those values and pass them to the class’s initializer.

This would be a good application for ABCs.

N[source]

Calculate the numner of dipoles in the target

aeff[source]

Calculate the effective diameter of the target

class ScatPy.targets.RCTGLPRSM(phys_shape, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Target_Builtin

A rectangular prism target

Parameters:
  • phys_shape – (length, width, height) of the prism in microns
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
sh_param[source]

The shape parameters based on the physical shape

classmethod fromfile(fname)[source]

Load target definition from the specified .par file.

class ScatPy.targets.Cube(length, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.RCTGLPRSM

A Cube target.

Parameters:
  • length – the edge length of the cube
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
class ScatPy.targets.CYLNDRCAP(length, radius, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Target_Builtin

Homogeneous, isotropic finite cylinder with hemispherical endcaps.

Parameters:
  • length – the length of the cylinder in microns (not including endcaps)
  • radius – the radius of the cylinder
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.

Total height of the structureis length+2*rad

sh_param[source]

Calculate the shape parameters

classmethod fromfile(fname)[source]

Load target definition from the specified .par file.

class ScatPy.targets.ELLIPSOID(semiaxes, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Target_Builtin

An Ellipsoid target

Parameters:
  • semiaxes – 3-tuple giving the lengths of the three semiaxes
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
sh_param[source]

Calculate the shape parameters

classmethod fromfile(fname)[source]

Load target definition from the specified .par file.

class ScatPy.targets.Sphere(radius, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.ELLIPSOID

A Sphere target.

Parameters:
  • radius – the radius of the sphere
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
class ScatPy.targets.CYLINDER(length, radius, orient, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Target_Builtin

Homogeneous, isotropic finite cylinder

Parameters:
  • length – the length of the cylinder in microns (not including endcaps)
  • radius – the radius of the cylinder
  • orient – the orientation of the cylinder SHPAR3 = 1 for cylinder axis a^1 | x^TF: a^1 = (1, 0, 0)TF and a^2 = (0, 1, 0)TF; SHPAR3 = 2 for cylinder axis a^1 | y^TF: a^1 = (0, 1, 0)TF and a^2 = (0, 0, 1)TF; SHPAR3 = 3 for cylinder axis a^1 | z^TF: a^1 = (0, 0, 1)TF and a^2 = (1, 0, 0)TF in the TF.
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
sh_param[source]

Calculate the shape parameters

classmethod fromfile(fname)[source]

Load target definition from the specified .par file.

class ScatPy.targets.FROM_FILE(grid=None, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Target

Base class for targets of arbitrary geometry.

Parameters:
  • grid – The dipole grid
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.

If anisotropic, the “microcrystals” in the target are assumed to be aligned with the principal axes of the dielectric tensor parallel to the TF axes.

FROM_FILE does not inherit from Target_Builtin so for the purposes of inheritence it is not considered a builtin target.

aeff[source]

Calculate the effective diameter of the target

sh_param[source]

The dimensions of the target in dipole units

N[source]

The number of dipoles

write()[source]

Write the shape file.

classmethod fromfile(fname)[source]

Load target definition from the specified .par file.

Assumes that the accompanying shape.dat file is in the same folder.

This function currently assumes that the target basis vectors are orthonormal.

classmethod fromfunction(func, pt1, pt2, origin=None, d=None, material=None, folder=None, **kwargs)[source]

Generate a target from a function.

Parameters:
  • func – The generating function. Returns integers corresponding to material index when evaluated at each point in the target volume
  • pt1 – One corner of the target volume, (xmin, ymin, zmin), in um.
  • pt2 – The opposite corner of the target volume, (xmax, ymax, zmax), in um.
  • origin – The origin of the target (in um)
  • kwargs – Further kwargs are passed to func

See numpy.fronfunction for details on the function func.

VTRconvert(outfile=None)[source]

Execute VTRConvert to generate a model file viewable in Paraview

show(*args, **kwargs)[source]

Display the dipoles using Mayavi.

Currently assumes that all dipoles are isotropic.

class ScatPy.targets.Iso_FROM_FILE(grid=None, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.FROM_FILE

Base class for targets of arbitrary geometry with isotropic materials.

Parameters:
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.

The major difference is that the grid in this case has only one value at each dipole.

class ScatPy.targets.Ellipsoid_FF(semiaxes, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Iso_FROM_FILE

Build an ellipsoidal target to be loaded from file

Parameters:
  • semiaxes – is the length of the three semi-major axes in physical units
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
class ScatPy.targets.Helix(height, pitch, major_r, minor_r, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Iso_FROM_FILE

A helix target.

dimensions are physical, in um

Parameters:
  • height – the height of the helix (not counting it’s thickness)
  • pitch – the helix pitch, um/turn
  • major_r – the radius of the helix sweep
  • minor_r – the radius of the wire that is swept to form the helix
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
class ScatPy.targets.SpheresHelix(height, pitch, major_r, minor_r, n_sphere, d=None, build=True, **kwargs)[source]

Bases: ScatPy.targets.Iso_FROM_FILE

A helix target composed of isolated spheres

Dimensions are physical, in um.

Parameters:
  • height – the height of the helix (not counting it’s thickness)
  • pitch – the helix pitch, um/turn
  • major_r – the radius of the helix sweep
  • minor_r – the radius of the spheres that compose the helix
  • n_sphere – the number of spheres that compose the helix
  • d – the dipole dipole spacing, if not specified default value is used
  • build – if False, delays building the helix until requested. default is True
build_helix()[source]
class ScatPy.targets.Conical_Helix(height, pitch1, pitch2, major_r, minor_r, d=None, build=True, **kwargs)[source]

Bases: ScatPy.targets.Iso_FROM_FILE

A helix target

dimensions are physical, in um

Parameters:
  • height – the height of the helix (not counting it’s thickness)
  • pitch1 – the starting helix pitch, um/turn (if pitch1 is different from pitch2 will swipe between during the growth)
  • pitch2 – the final helix pitch, um/turn (if pitch1 is different from pitch2 will swipe between during the growth)
  • major_r – the radius of the helix sweep
  • minor_r – the radius of the wire that is swept to form the helix
  • d – the dipole dipole spacing, if not specified default value is used
  • build – if False, delays building the helix until requested. default is True
build_helix()[source]
class ScatPy.targets.Polygon(polygon, thickness, bbox=None, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.Iso_FROM_FILE

A planar target in the shape defined by the polygon

dimensions are physical, in um

Parameters:
  • polygon – a list of vertices for the polygon
  • thickness – the thickness of the polygon
  • bbox – the bounding box. By default uses the smallest box that contains the entire polygon. If bbox is a 2-tuple then the values specify the width and height of the box and the polygon is centred within it. If the bbox is a 4-tuple, then the values specify the bottom left x,y coordinates and the width and height.
  • d – the dipole dipole spacing, if not specified default value is used
  • material – A string specifying the material file to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.

Dipoles within the polygon correspond to material, outside to ambient.

class ScatPy.targets.Periodic[source]

Bases: object

Base class for periodic targets

Parameters:
  • dim – The number of periodic dimensions (1 or 2)
  • period – A 2-tuple which defines the period of the array in the x,y TF directions. (in um)
dimension[source]

Returns the number of periodic dimensions

class ScatPy.targets.FRMFILPBC(grid=None, period=(0, 0), d=None, material=None, folder=None, fname=None)[source]

Bases: ScatPy.targets.FROM_FILE, ScatPy.targets.Periodic

Base class for periodic targets of arbitrary geometry.

Parameters:
  • grid – The dipole grid
  • period – A 2-tuple which defines the period of the array in the x,y TF directions. (in um)
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.

If anisotropic, the “microcrystals” in the target are assumed to be aligned with the principal axes of the dielectric tensor parallel to the TF axes.

FROMFILPBC does not inherit from Target_Builtin so for the purposes of inheritence it is not considered a builtin target.

directive = 'FRMFILPBC'
sh_param[source]

Return the shape parameter

classmethod fromfile(fname)[source]

Load target definition from the specified .par file.

Assumes that the accompanying shape.dat file is in the same folder.

This function currently assumes that the target basis vectors are orthonormal.

class ScatPy.targets.RCTGL_PBC(phys_shape, period, d=None, material=None, folder=None, fname=None)[source]

Bases: ScatPy.targets.RCTGLPRSM, ScatPy.targets.Periodic

A target of periodic rectangular prisms.

Parameters:
  • phys_shape – (length, width, height) of the prism in microns
  • period – A 2-tuple which defines the period of the array in the x,y TF directions. (in um)
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
directive = 'RCTGL_PBC'
sh_param[source]

Return the shape parameter

classmethod fromfile(fname)[source]

Load target definition from the specified .par file.

class ScatPy.targets.CYLNDRPBC(length, radius, orient, period, d=None, material=None, folder=None)[source]

Bases: ScatPy.targets.CYLINDER, ScatPy.targets.Periodic

A target of periodic cylinders.

Parameters:
  • length – the length of the cylinder in microns (not including endcaps)
  • radius – the radius of the cylinder
  • orient – the orientation of the cylinder SHPAR3 = 1 for cylinder axis aˆ1 ∥ xˆTF: aˆ1 = (1, 0, 0)TF and aˆ2 = (0, 1, 0)TF; SHPAR3 = 2 for cylinder axis aˆ1 ∥ yˆTF: aˆ1 = (0, 1, 0)TF and aˆ2 = (0, 0, 1)TF; SHPAR3 = 3 for cylinder axis aˆ1 ∥ zˆTF: aˆ1 = (0, 0, 1)TF and aˆ2 = (1, 0, 0)TF in the TF.
  • period – The periodicity
  • period – A 2-tuple which defines the period of the array in the x,y TF directions. (in um)
  • d – The dipole density. Default is taken from targets.default_d.
  • material – A string, or list of strings specifying the material file(s) to use for the target. Default is taken from default.par.
  • folder – The target working directory. The default is the CWD.
sh_param[source]

Return the shape parameter

classmethod fromfile(fname)[source]

Load target definition from the specified .par file.

ScatPy.targets.cls_conversion = {<class 'ScatPy.targets.FROM_FILE'>: <class 'ScatPy.targets.FRMFILPBC'>, <class 'ScatPy.targets.RCTGLPRSM'>: <class 'ScatPy.targets.RCTGL_PBC'>, <class 'ScatPy.targets.CYLINDER'>: <class 'ScatPy.targets.CYLNDRPBC'>}

A dict which translates between a finite isolated target class and its corresponding (semi)infite periodic partner. The keys are the classes of the isolated target, and the values are the classes of the periodic ones.

ScatPy.targets.Holify(target, radius, posns=None, num=None, seed=None)[source]

Punches holes into a target

radius: the radius of the holes to be punched (in units of d)

Where to punch the holes can be specified by:

posns: a list of the x,y,z positions to punch the holes

or

num: the number of holes. their positions are selected randomly seed: a seed value to use for the random number generator