cvm package¶
Subpackages¶
Submodules¶
cvm.base module¶
-
class
cvm.base.
BaseCVM
(meta: dict, *, series: List[dict] = None, experiment: dict = None)[source]¶ Bases:
collections.defaultdict
CVM is a general CVM (Cluster Variation Method) calculation framework using NIM (Natural Iteration Method).
- Parameters
meta (dict) – Meta information. It can be anything that will be used to describe this calculation set. This information will be passed over the whole calculation.
series (List[dict], optional) – Sample data contains raw energies, and other calculation needed parameters, by default None
experiment (dict, optional) – The experiment data, by default None
-
__call__
(*labels, verbose: bool = False, early_stopping: float = 0.2, sample_paras: dict = {}, reset_paras: dict = {}, update_en_paras: dict = {}, process_paras: dict = {})[source]¶ Run CVM calculation as generator. Will yield calculation details on each step.
- Parameters
labels (str) – If not
None
, only execute listed series samples.verbose (bool, optional) – Set to
True
to show extra information when running calculations, by default Falsesample_ite_paras (dict, optional) – The parameters will be passed to
sample.ite
andsample.__call__
method, by default empty.reset_paras (dict, optional) – The parameters will be passed to
self.reset
method, by default empty.update_en_paras (dict, optional) – The parameters will be passed to
self.update_energy
method, by default empty.process_paras (dict, optional) – The parameters will be passed to
self.process
method, by default empty.
-
classmethod
from_samples
(meta: dict, *samples, experiment: dict = None)[source]¶ Build a CVM instance from series samples.
- Parameters
- Returns
New CVM instance.
- Return type
-
run
(*labels, verbose: bool = False, early_stopping: float = 0.2, sample_paras: dict = {}, reset_paras: dict = {}, update_en_paras: dict = {}, process_paras: dict = {})[source]¶ Run CVM calculation.
- Parameters
labels (str) – If not
None
, only execute listed series samples.verbose (bool, optional) – Set to
True
to show extra information when running calculations, by default Falsesample_ite_paras (dict, optional) – The parameters will be passed to
sample.ite
andsample.__call__
method, by default empty.reset_paras (dict, optional) – The parameters will be passed to
self.reset
method, by default empty.update_en_paras (dict, optional) – The parameters will be passed to
self.update_energy
method, by default empty.process_paras (dict, optional) – The parameters will be passed to
self.process
method, by default empty.
-
property
results
¶ Get calculated results.
- Returns
- Return type
results
cvm.normalizer module¶
-
class
cvm.normalizer.
Normalizer
(energies: pandas.core.frame.DataFrame, clusters, targets)[source]¶ Bases:
collections.defaultdict
-
property
interaction_energies
¶
-
property
cvm.results module¶
cvm.sample module¶
-
class
cvm.sample.
Sample
(label: str, host: str, impurity: str, *, temperature: list = None, energies: pandas.core.frame.DataFrame = None, clusters: dict = None, mean: str = 'arithmetic', vibration: bool = True, skip: bool = False, x_1: float = 0.001, condition: float = 1e-07, r_0: Union[float, dict, str] = None, normalizer: Union[dict, cvm.normalizer.Normalizer] = None)[source]¶ Bases:
collections.defaultdict
Sample is a object which store a group of configuration data for calculation
- Parameters
label (str) – The Sample label.
host (str, optional) – The column name of host energies in
energies
.host – The column name of impurity energies in
energies
.temperature (list, optional) – Temperature steps follow the format [start, stop, # of steps]. By default
None
.energies (pd.DataFrame, optional) – A
pandas.DataFrame
object contain raw energies. By defaultNone
.clusters (dict, optional) – Set how to calculate interaction energy. By default
None
.mean (str, optional) – Specific how to mix atom weights. Can be ‘arithmetic’, ‘harmonic’, and ‘geometric’. By default ‘arithmetic’.
vibration (bool, optional) – Specific whether or not to import the thermal vibration effect. By default
True
.skip (bool, optional) – Set to true to skip this series sample. By default
False
.x_1 (float, optional) – The initialization concentration of impurity. By default
0.001
.condition (float, optional) – Convergence condition. By default
1e-07
.r_0 (Union[float, dict, str], optional) – Set how to estimate r_0 from the given T and c. If
local
, r_0 will be calculated from each phase respectively. If constant, will ignore T and c. If dict, will do a parabolic curve fitting. By defaultNone
.normalizer (Union[dict, Normalizer], optional) – Configuration of a
Normalizer
or an instance. If given, this will be used to normalize the long-range interaction energy. By defaultNone
.
-
__call__
(*, T: float = None, r: [<class 'float'>, <class 'dict'>, <class 'str'>, None] = None, vibration: bool = None, energy_patch: Callable[[float, float], collections.namedtuple] = None, **kwargs)[source]¶ Get interaction energies at given T, and r.
- Parameters
T (float) – Temperature.
r (float, dict, str, or None, optional) – Atomic distance. By default
None
.vibration (bool) – Specific whether or not to import the thermal vibration effect.
energy_patch (Callable[[float, float], namedtuple], optional) – A patch that will be used to correct the returns of interaction energy. By default
None
.
- Returns
namedtuple – Named tuple contains calculated interaction energies.
- Return type
namedtuple
-
ite
(*, temperature: list = None, k: int = 3, vibration: bool = None, r_0: [<class 'float'>, <class 'dict'>, <class 'str'>, None] = None, **kwargs)[source]¶ Iterate over each temperature
- Parameters
- Yields
T (float) – Temperature at current step.
r_func (Callable[[float], float]) – A function receiving impurity concentration c and returns corresponding atomic distance r.
-
property
clusters
¶
-
property
energies
¶
-
property
normalizer
¶
-
property
temperatures
¶
cvm.solution_limit module¶
cvm.utils module¶
-
cvm.utils.
parse_formula
(formula)[source]¶ - Parameters
formula (str) – A string formula, e.g. Fe2O3, Li3Fe2(PO4)3
- Returns
Composition with that formula.
Notes
In the case of Metallofullerene formula (e.g. Y3N@C80), the @ mark will be dropped and passed to parser.
cvm.vibration module¶
-
class
cvm.vibration.
ClusterVibration
(*, label: str, xs: list, ys: list, mass: float, num: int, morse_paras_bounds: list = None)[source]¶ Bases:
object
Tools class for cluster vibration
Calculate phase energy using debye-sg model
- Parameters
label (str) – Label in chemical composition format.
xs (list) – List of atomic distance.
ys (list) – List of phase energies.
mass (float) – Mixed mass.
num (int) – Number of atoms.
morse_paras_bounds (list, optional) – parameter bounds for fitting, by default
None
. See also, https://docs.scipy.org/doc/scipy/reference/generated/scipy.optimize.curve_fit.html
- Raises
ValueError – xs and ys must have same shape.
-
__call__
(*, T: float = None, r: [<class 'float'>, <class 'str'>] = 'local', min_x: str = None)[source]¶ Get free energy.
- Parameters
T (float, optional) – Temperature. If
None
, will set parametervibration
toFalse
automatically.r (float or str, optional) – Atomic distance, If
local
, will ues the default setting which be set when instancing. by defaultNone
.min_x (str, optional) – By default
None
. IfNone
, will ues the default setting which be set when instancing. If notNone
, function will returns equilibrium lattice constant as second result. The string can bews
orlattice
.
-
debye_temperature
(r: [<class 'float'>, <class 'str'>] = 'local') → float[source]¶ Debye temperature function.
-
property
gamma_0
¶
-
property
x_0
¶