image0

General Theory Concepts

Before we start digging into the details of PRISM and our implementation, it is worth highlighting a few general theoretical topics. For those with a simulation or theory background, this notebook can probably be skipped.

Concepts

  • Reduced Units

Notebook Setup

To begin, please run Kernel-> Restart & Clear Output from the menu at the top of the notebook. It is a good idea to run this before starting any notebook so that the notebook is fresh for the user. Next, run the cell below (via the top menu-bar or <Shift-Enter>. If the cell throws an import error, there is likely something wrong with your environment.

Troubleshooting:

  • Did you activate the correct conda environment before starting the jupyter notebook?
  • If not using anaconda, did you install all dependencies before starting the jupyter notebook?
  • Is pyPRISM installed in your current environment on your PYTHONPATH?
[1]:
import pyPRISM
import numpy as np

Reduced Units

pyPRISM operates in a system of reduced units commonly called ‘Lennard Jones units’. In this unit system, all measures are reported relative to characteristic values: - characteristic length = \(d_c\) - characteristic mass = \(m_c\) - characteristic energy = \(e_c\)

While pyPRISM does not need to know the characteristic values to carry out calculations, users will need to give all input parameters in terms of these values. Note that the choice of characteristic values should not affect the results if all parameters are correctly scaled. The values are mostly arbitrary, but they should be chosen such that they correspond to values taken from the real system under study. For example, for mixture of nanoparticles with diameters - \(d_{1}=2.0\ nm\) - \(d_{2}=10.0\ nm\)

a user might want to set - \(d_c = 2\ nm\)

so that the diameters can be reported to pyPRISM as - \(d^{*}_{1} = 1\ d_c\) - \(d^{*}_{2} = 5\ d_c\).

Note that the star ,\(*\), indicates a reduced variable while the subscript \(c\) indicates a characteristic unit.

The characteristic energy is often chosen to be representative of an important energy scale in the system under study. For example, one could choose the size of thermal fluctuations (\(k_B T\)) at a given temperature. To convert from reduced temperature reported in units of thermal energy, \(T^{*}\), one must use the relation
- \(T^{*} = \frac{k_{B}T}{e_{c}}\)

It can be tedious for those outside of the simulation and theory fields to work in these unit systems. pyPRISM has a UnitConverter class that is designed to allow for easy translation between common reduced and real unit systems. The UnitConverter class is built on top of the Pint library.

In the example below we choose a set of characteristic units, and create a unit converter object.

[2]:
uconv = pyPRISM.util.UnitConverter( dc=1.0,   dc_unit='nanometer',
                                    mc=14.02, mc_unit='gram/mole',
                                    ec=2.48,  ec_unit='kilojoule/mole')

print(uconv)
<UnitConverter  dc:1e-09 meter | mc:0.01402 kilogram / mole | ec:2480.0 kilogram * meter ** 2 / mole / second ** 2>

Next, we can use several built in methods to convert common reduced units to real units. Note that these functions return a Quantity object rather than a number. To obtain the number as a floating point value, use the magnitude attribute as shown below

[3]:
# convert thermal energy to temperature
Tstar = 1.25
T = uconv.toKelvin(Tstar)

print("Reduced Temperature (ec)")
print(Tstar)

print("Temperature (ec)")
print(T)
print(T.magnitude)

print()

print('T is of type',type(T))
print('T.magnitude is of type',type(T.magnitude))
Reduced Temperature (ec)
1.25
Temperature (ec)
372.8443218289683 kelvin
372.8443218289683

T is of type <class 'pint.quantity.build_quantity_class.<locals>.Quantity'>
T.magnitude is of type <class 'float'>

The UnitConverter class also has a built in conversion for reduced wavenumber in order to make comparison to experimental scattering measurements easier.

[4]:
#convert reduced wavenumbers to inverse angstroms or inverse nanometers
kstar = np.logspace(start=-2,stop=0,num=10) #reduced wavenumber values
k = uconv.toInvAngstrom(kstar)

print("Reduced Wavenumber (dc^-1)")
print(kstar)
print()

print("Wavenumber (A^-1)")
print(k)
Reduced Wavenumber (dc^-1)
[0.01       0.01668101 0.02782559 0.04641589 0.07742637 0.12915497
 0.21544347 0.35938137 0.59948425 1.        ]

Wavenumber (A^-1)
[0.001      0.0016681  0.00278256 0.00464159 0.00774264 0.0129155 0.02154435 0.03593814 0.05994843 0.1       ] / angstrom

Alternatively, users can work directly with the Pint library. In the UnitConverter class, we have defined reduced unit Quantities that can be used for more “manual” unit conversion.

[5]:
Tstar = 1.25*uconv.ec # uconv.ec is the reduced "unit"
print('Tstar =', Tstar)

T = Tstar/uconv.pint.boltzmann_constant/uconv.pint.avogadro_number
print('T =',T)
print('T =',T.to('kelvin'))
Tstar = 1.25 echar
T = 1.25 echar / avogadro_number / boltzmann_constant
T = 372.8443218289683 kelvin

Summary

The goal of this notebook is to demystify some general theory topics for the reader. As we are continuously developing this tutorial, users should feel free to send us suggestions for future topics to go over in this or other notebooks.

image0

NB0.Introduction \(\cdot\) NB1.PythonBasics \(\cdot\) NB2.Theory.General \(\cdot\) NB3.Theory.PRISM \(\cdot\) NB4.pyPRISM.Overview \(\cdot\) NB5.CaseStudies.PolymerMelts \(\cdot\) NB6.CaseStudies.Nanocomposites \(\cdot\) NB7.CaseStudies.Copolymers \(\cdot\) NB8.pyPRISM.Internals \(\cdot\) NB9.pyPRISM.Advanced