UserDefinedTabulatedPotential

class UserDefinedTabulatedPotential(particleType1, particleType2, fileName, splineType=None)

Constructor of the potential.

Parameters:
  • particleType1 (ParticleType or ParticleIdentifier) – Identifier of the first particle type.
  • particleType2 (ParticleType or ParticleIdentifier) – Identifier of the second particle type.
  • fileName (str) –

    The name of the file that holds the spline data. It must be a text file that stores the spline in the following way:

    numPoints distance <energy at 0 * distance> <energy at 1 * distance> ... <energy at (numPoints-1) * distance>
  • splineType

    The spline interpolation that will be used. Must be one of the following variables:

    UserDefinedTabulatedPotential.akima UserDefinedTabulatedPotential.bessel UserDefinedTabulatedPotential.fivepoint UserDefinedTabulatedPotential.hermitian UserDefinedTabulatedPotential.natural

getAllParameterNames()

Return the names of all used parameters as a list.

getAllParameters()

Return all parameters of this potential and their current values as a <parameterName / parameterValue> dictionary.

static getDefaults()

Get the default parameters of this potential and return them in form of a dictionary of <parameter name, default value> key-value pairs.

getParameter(parameterName)

Get the current value of the parameter parameterName.

setCutoff(r_cut)

Set the cutoff radius for this potential.

Parameters:r_cut (PhysicalQuantity of type length) – The cutoff radius of this potential.
setParameter(parameterName, value)

Set the parameter parameterName to the given value.

Parameters:
  • parameterName (str) – The name of the parameter that will be modified.
  • value – The new value that will be assigned to the parameter parameterName.
setSplineType(splineType)

Set the used spline type.

Parameters:splineType

The spline interpolation that will be used. Must be one of the following variables:

UserDefinedTabulatedPotential.akima UserDefinedTabulatedPotential.bessel UserDefinedTabulatedPotential.fivepoint UserDefinedTabulatedPotential.hermitian UserDefinedTabulatedPotential.natural

Usage Examples

Read a tabulated potential from a file tab_potential_argon.dat and add it between argon particles.

# Setup an argon crystal.

# Set up lattice
vector_a = [5.316, 0.0, 0.0]*Angstrom
vector_b = [0.0, 5.316, 0.0]*Angstrom
vector_c = [0.0, 0.0, 5.316]*Angstrom
lattice = UnitCell(vector_a, vector_b, vector_c)

# Define elements
elements = [Argon, Argon, Argon, Argon]

# Define coordinates
fractional_coordinates = [[ 0. ,  0. ,  0. ],
                          [ 0.5,  0.5,  0. ],
                          [ 0.5,  0. ,  0.5],
                          [ 0. ,  0.5,  0.5]]

# Set up configuration
bulk_configuration = BulkConfiguration(
    bravais_lattice=lattice,
    elements=elements,
    fractional_coordinates=fractional_coordinates
    )

potential_set = TremoloXPotentialSet(name = "argon_tabulated")

# Add default argon particle.
potential_set.addParticleType(ParticleType.fromElement(Argon))

# Add the tabulated potential form the file 'tab_potential_argon.dat'.
potential_set.addPotential(UserDefinedTabulatedPotential(
    particleType1='Ar',
    particleType2='Ar',
    fileName='tab_potential_argon.dat',
    splineType='fivepoint'
))

calculator = TremoloXCalculator(potential_set)

bulk_configuration.setCalculator(calculator)


The top of the file tab_potential_argon.dat should look like the following example.

65000 0.0001
0
4e+48
9.765625e+44
7.52670569264e+42
2.38418579102e+41
1.6384e+40
1.83757463199e+39
2.88990463236e+38
5.82076609135e+37
1.41628246459e+37
4e+36
1.27452327084e+36
4.48626619138e+35
1.71687929672e+35
7.05543123135e+34
3.0829386517e+34
# .. continue until the specified number of points is reached.


Notes

Define a tabulated potential that is read from a file. The tabulated file must be present in your project directory, otherwise the correct path has to be given.

The first line of the file must contain two entries:

  • The number of data points \(N\) of the tabulation.
  • The distance \(\Delta r\) between two data points.

The following \(N\) lines must contain the potential energy values \(E_i, (i=1...N)\), representing the energy at a particle distance \(r=i\Delta r\) .

Possible spline types are

  • hermitian
  • bessel
  • akima
  • natural
  • fivepoint

If hermitian splines are used, a second column is required in the potential file, which contains the derivative values.