DIMPy may be run in one of two ways:
From a DIMPy input file (see DIMPy Input File). For example, from the command line
python -m dimpy filename.dimpy
or from python
>>> import dimpy >>> calc = dimpy.run('filename.dimpy')
where
filename.dimpyis a DIMPy input file.From within python, explicitly specifying the nanoparticle and calculation type, for example
>>> import dimpy >>> nano = dimpy.Nanoparticle('Ag 0 0 0; Ag 0 0 1.89') >>> nano.build() >>> calc = dimpy.DIMr(nano, kdir='y') >>> calc.run()
The DIMPy input file is a file with extension .dimpy
that contains all the information necessary to run a DIMPy calculation.
In this documentation, we will go over the options in a DIMPy Input.
See files in DIMPy/examples/ for examples for DIMPy input files for specfic
types of calculation.
The following is the minimal input to perform a static (or
frequency-independent), discrete interaction model, quasi-static
approximation, molecular calculation on 2 silver atoms, where the
coordinates are assumed to be in Angstrom. The radius of the
silver atoms are taken to be the van der Walls radius. This minimal input
file (and all examples in this section)
can be found in the DIMPy/examples/ directory.
NANOPARTICLE
Atoms
Ag 0 0 0
Ag 0 0 1.89
End
ENDNANOPARTICLE
METHOD
Interaction DDA
ENDMETHODNANOPARTICLE (case insensitive) specificies the information for the
nanoparticle, with the Atoms starting the coordinates input sub-block
for the nanoparticle. See Nanoparticle Options for more information.
The Atoms sub-block is ended with the End key while the NANOAPARTICLE
block is ended with the ENDNANOPARTICLE key.
METHOD specifies the calculation method and is ended with ENDMETHOD.
In this example, we specify the type of atom interaction with Interaction DDA.
See Method Options for more information.
You may specify other input keys that are not unique to the nanoparticle or calculation method. For more details, see Other Input Options.
The general NANOPARTICLE block is
NANOPARTICLE
<Coordinates>
[PBC]
[Unit]
[AtomParam]
ENDNANOPARTICLECoordinates(required) specifies the coordinates of the nanoparticle, and may be done in one of two ways: (1) specifying the coordinates explicitly using theAtomssub-block; or (2) specifying an.xyzfile using theXYZFilekeyword. Examples are below:Using the
Atomssub-block:Atoms atom1 x1 y1 z1 atom2 x2 y2 z2 ... End
where
atom1is the symbol for an atom with coordinates (x1,y1,z1), and so on.Using the
XYZFilekeyword:XYZFile filename.xyzwhere
filename.xyz(case sensitive) is the (relative) path to the.xyzfile that contains the coordinates of the nanoparticle.
PBC(optional) specifies the periodic lattice parameters using a sub-block. The nanoparticle may be a single molecule (default, in absence of thePBCsub-block) or an infinite one- or two-dimensional array of nanoparticles. For a one-dimensional, periodically repeating nanoparticle, usePBC <Ux> <Uy> <Uz> End
where
<Ux>,<Uy>, and<Uz>specify the x, y, and z coordinates of the lattice vector.For nanoparticles repeating periodically in two dimensions with another lattice vector (
<Vx>,<Vy>,<Vz>), usePBC <Ux> <Uy> <Uz> <Vx> <Vy> <Vz> End
Unit(optional) specifies whether input coordinates and lattice vectors are given in Angstroms (the default) or Bohrs (atomic units). To specify that coordinates are given in Angstroms (again, this is the default behavior):Unit AngstromTo specify that coordinates are in atomic units, you may use:
Unit BohrAtomParam(optional) specifies an atom-specific parameter and may be repeated as many times as necessary. The general useage is:AtomParam Xx key valuewhere
Xxis the atomic symbol,keyis the type of parameter that you're setting (examples includeradandexp) , andvalueis the value for that key.Let's say you want to give silver atoms a radius of 1.72 Angstroms (this is the default van-der Waals radius):
AtomParam Ag rad 1.72Or, let's say you want to use the
Au_jcdielectric function for gold atoms (needed for frequency-dependent calculations):AtomParam Au exp Au_jc
The general METHOD block is
METHOD
<Interaction>
[Excitation]
[Kdir]
[Solver]
ENDMETHODInteraction(required) denotes the type of interaction between atoms. For a discrete interaction model (DIM) calculation that uses screened interaction tensors, use:Interaction DIMFor a discrete dipole approximation (DDA) calculation that uses un-screened interaction tensors, use:
Interaction DDAExcitation(optional) specify the excitation frequency (or frequencies). The default (no excitation specification) performs a static (or frequency-independent) calculation. The excitaiton frequencies may be specified in one of two ways:You may specify a calculation at a specified frequency (or frequencies) using
Frequency <unit> <value> [<value2> <value3> ...]where
<unit>may be one ofev(electron volts),nm(nanometers),hz(hertz),cm-1(wave numbers),hartree(hatrees), orau(atomic units or hartrees).<value>is the frequency to use. You may specify as many frequencies (separated by spaces) as needed, though specifying more than one frequency this way is optional.Alternatively, you may specify a range of frequencies using
FreqRange <unit> <start> <end> <number>where
<start>is the starting frequency,<end>is the ending frequency, and<number>is the number of frequencies between<start>and<end>to use (inclusively).
Kdir(optional) specifies the direction of the k-vector. In its absence, we assume the quasi-static behavior, where the electric fields do not change phase with distance (the default behavior). To include phase-changes (or retardation) effects, include the following in the input fileKdir <dir>where
<dir>>is one of eitherx,y, orzand gives the direction of the k-vector for retardation effects. The magnitude of the k-vector is determined automatically from the frequency (see above). Note that theKdirkey does nothing when the frequency is zero (i.e. a static calculation).Solver(optional) chooses the type of solver to use. The solvers used are all part of the :mod:`scipy.sparse.linalg` module. To manually choose a solver, include the following in the DIMPy input fileSolver <option>where
<option>may be one of (see the full list at :attr:`dimpy.read_input_file.ReadInput.solvers`):direct- direct inversion. Fast, but uses a lot of memory. Good for small nanoparticles (maximum of ~12k atoms with ~32GB of RAM).bicg- BIConjugate Gradient iterationbicgstab- BIConjugate Gradient STABilized iterationcg- Conjugate Gradient iteration (unstable)cgs- Conjugate Gradient Squared iteration (unstable)gmres- Generalized Minimal RESidual interationlgmres- Linear Generalized Minimal RESidual interationminres- MINimum RESidual iteration (unstable/incorrect)qmr- Quasi-Minimal Residual iterationgcrotmk- Generalized Conjugate Residual with inner Orthogonalization and outer Truncation method (default)
You may include any of the following in your DIMPy input file (outside of either
of the NANOPARTICLE or METHOD blocks) to add (or remove)
functionalities:
TITLE <calculation title>- This lets you give the name<calculation title>to your calculation. Without it, you calculation title will beNone.DEBUG- This will print additional timing and memory information into both the output and log files. This will also print the most verbose output and it overrides any choice forVERBOSE(below).VERBOSE <num>- This determines how much information is included in the output file. This keyword is ignored ifDEBUGis given. Options for<num>are:0- Nothing is printed to the output file.1- Only the most important results are printed.2- Important results as well as key information are printed (default).3- Additional information, such as atomic dipoles, are printed at this level.4- Even more information is printed.VERBOSE 4is almost the same asDEBUG, without printing additional timing and memory information.
All files listed in this section can be found in the DIMPy/examples/
directory. All calculations in this section may be analyzed using the
:class:`dimpy.analyzer.Analyzer` class.
The following example calculates the absorbance spectrum in the visible
region using DDA for a small 100-atom gold nanoparticle using the dielectric
function found in Au_jc.
The calculation calculates the properties of the nanoparticle at 40 frequency
steps between 400 nm and 800 nm.
This example uses input file gold_absorption_dda.dimpy
and the associated .xyz file Au_147_ico.xyz.
TITLE Gold absorption spectrum
NANOPARTICLE
XYZFile Au_147_ico.xyz
AtomParam Au exp Au_jc
ENDNANOPARTICLE
METHOD
Interaction DDA
FreqRange nm 400 800 40
ENDMETHODYou may run the calculation using the command line with
python -m dimpy gold_absorption_dda.dimpyor as part of a python script with
>>> import dimpy
>>> calc = dimpy.run('gold_absorption_dda.dimpy',
... output_filename='gold_absorption_dda.out')Let's calculate the absorbance for a 1-dimensional periodically repeating
gold chain that is 1-atom thick at 545 nm. This input file is
gold_chain_dda.dimpy.
TITLE 1-Dimensional single-atom gold chain
NANOPARTICLE
Atoms
Au 0 0 0
End
AtomParam Au exp Au_jc
PBC
0 0 2.48
End
ENDNANOPARTICLE
METHOD
Interaction DDA
Frequency nm 545
ENDMETHODLet's calculate the absorbance for a 2-dimensional periodically repeating
silver sheet that is 1-atom thick at 400 nm. The input file is
silver_sheet_dda.dimpy.
TITLE 2-Dimensional single-atom silver sheet
NANOPARTICLE
Atoms
Ag 0 0 0
End
PBC
0 0 1.89
0 1.89 0
End
AtomParam Ag exp Ag_jc
ENDNANOPARTICLE
METHOD
Interaction DDA
Frequency nm 545
ENDMETHODThe input file is method_dda_retardation.dimpy.
TITLE DDA with retardation
NANOPARTICLE
XYZFile Au_147_ico.xyz
AtomParam Au exp Au_jc
ENDNANOPARTICLE
METHOD
Interaction DDA
Frequency nm 545
Kdir x
ENDMETHOD