A small collection of Julia utility scripts and their associated wrappers that I use. The shell scripts all use the environmental variable JULIABIN to find the julia scripts, so make sure these are in a location given by the directory to which you set JULIABIN.
For two functions
The assumption here is that the data to convolve represents the output of some function that is zero for non-positive arguments. The lower integration limit can then be truncated to 0.
I made this for functions
The gaussian distribution is given by
Cross sections
In implementation, the normalization factor
The Cauchy — or Lorentz — distribution is given by
where
In practice, the upper integration limit is taken to be the last available value of
The shell script convolve
is a wrapper script for the Julia script convolve.jl
.
Script arguments
convolve
Wrapper for my julia script located at : \$JULIABIN
usage: convolve [operation] [operand]
operations: operand: function:
-h none show this message.
-i,--input file specify input file
-o,--output file specify output file
--dx,--width float specify gaussian width
--nx integer number of convolution x-grid points
--logx none if supplied, a logarithmic grid will be used.
-t, --ct, --convtype (gauss|cauchy) determines convolution function
The following is a valid implementation of convolve :
convolve -i data_to_convolve.dat -o convolved_data.dat --dx=1.3e-3 --nx=1000 --logx
In the situation where we have scattering cross sections (electron-atom or electron-molecule) as a function of collision energy and want to obtain thermally averaged rate coefficients as a fucntion of the kinetic temperature, the script thermal
can be used.
Just as above, this reduces to convolving a function
The Maxwell-Boltzmann distribution is a probability distribution, typically used for describing particle speeds in an ideal gas. In three dimensions, It is given by
where
which should then be averaged over initial states. However, this is not done by the script (this requires information like state energies and rotational quantum numbers, so this can be done separately [1]) The normalization factor is also computed numerically.
For cross sections behaving as
This script requires my script units
(https://github.com/banana-bred/units).
thermal
Wrapper for my julia script (\$JULIABIN), which produces state-selected
kinetic rate coefficients from cross sections behaving as 1/E (E being electron energy)
at the E=0 threshold.
usage: thermal [operation] [operand]
operations: operand: function:
-h none show this message.
-i,--input file specify input file
-o,--output file specify output file
--logx none if supplied, a logarithmic grid will be used.
--Ti float lowest kinetic temperature (K)
--Tf float highest kinetic temperature (K)
--nT integer number of kinetic temperatures
--input-xs-units string the unit type of the input data (e.g., "cm" for cm^2).
Output rates will be in these units ^3 / s
--input-energy-units string the unit type of the input energy (e.g., "eV" for electron volts).
--extrap none extrapolate cross sections to E = 0 threshold assuming 1/E behavior ? Otherwise,
assume it is zero.
--electron-energy-min float lowest electron energy (should be closer to 0 than the lowest available point)
--num-extrap-energies integer number of extrapolation energies (extrapolating to 0)
The following would be a valid implementation of thermal :
thermal -i data_to_convolve.dat -o convolved_data.dat \
--logx \
--Ti=1e-6 \
--Tf=1e3 \
--extrap \
--electron-energy-min=1e-8 \
--num-extrap-energies=1000 \
--nT=500 \
--input-xs-units=cm \
--input-energy-units=eV
Input file: a file of electron energies (Eel) and cross sections (σ)
in any units of energy and length^2, formatted as
Eel σ
. .
. .
. .
Output file: a file of temperatures (T) in K and rate coefficients (α) in cm^3/s, formatted as
T α
. .
. .
. .
Given data that (hopefully) resembles an interatomic or intermolecular potential, the script morseFit
can be used to fit the data to a Morse potential.
One case in which this might be useful is when such a potential is calculated and needs to be extrapolated to larger distances.
The Morse potential is often used as an improved approximation to the harmonic oscillator model for molecular vibration. It is given by
where
The scripts take as input a file containing space separated x (--tailonly
option be supplied, the script will append the fitted data to the supplied data.
A decent guess for
morseFit
Wrapper for my julia script located at (\$JULIABIN)
usage: morseFit [operation] [operand]
operations: operand: function:
-h none show this message.
-i,--input file specify input file
-o,--output file specify output file
--tailonly none if specified, only fit the tail of the potentil
--rcut number cutoff distance for fitting only the potential tail
--rmin number smallest distance for the fit. Ignored if --tailonly is supplied
--rmax number largest distance for the fit
--rstep number linear step size for the fit
-a number initial guess for the 'a' parameter in the Morse potetial controlling the well width
-r0 number initial guess for the 'r0' parameter in the Morse potetial controlling the location of the well minimum
-D number initial guess for the 'D' parameter in the Morse potetial controlling the well depth
--dissociation-limit number initial guess for the absolute value of the the dissociation limit (assumed to be negative) of the potential.
--positive-dissoc-limit none if specified, the dissociation limit is taken to have a positive value
--print-parameters none if specified, print the fit parameters
The following is a valid implementation of morseFit :
morseFit -i input.dat -o output.dat --tailonly --rcut=2.6 --rstep=0.01 --rmax=10 --dissociation-limit 75 --positive-dissoc-limit
For a full fit:
morseFit -i input.dat -o output.dat --rmin=0.8 --rstep=0.01 --rmax=10 --dissociation-limit 75 --positive-dissoc-limit
For a tail fit:
morseFit -i input.dat -o output.dat --rcut=2.6 --rstep=0.01 --rmax=10 --dissociation-limit 75 --positive-dissoc-limit
[1] Forer, J. et. al. (2023) Kinetic rate coefficients for electron-driven collisions with CH+: dissociative recombination and rovibronic excitation. Monthly Notices of the Royal Astronomical Society 527, 5238-5234