diff --git a/docs/source/vasp_d.ipynb b/docs/source/vasp_d.ipynb index a8d6a752..87e2249b 100644 --- a/docs/source/vasp_d.ipynb +++ b/docs/source/vasp_d.ipynb @@ -55,7 +55,7 @@ "metadata": {}, "outputs": [], "source": [ - "b_params = {'dimension': 'xy'}" + "u_params = {'dimension': 'xy'}" ] }, { @@ -65,7 +65,7 @@ "outputs": [], "source": [ "xd = Xdatcar('./example_XDATCAR.gz')\n", - "diff = DiffusionAnalyzer.from_Xdatcar(xd, parser_params=p_params, bootstrap_params=b_params)" + "diff = DiffusionAnalyzer.from_Xdatcar(xd, parser_params=p_params, uncertainty_params=b_params)" ] }, { @@ -136,7 +136,7 @@ "metadata": {}, "outputs": [], "source": [ - "diff.diffusion(diff.ngp_max)" + "diff.diffusion(0.4)" ] }, { @@ -334,6 +334,15 @@ " 'progress': False})" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "loaded_diff.dt[:]" + ] + }, { "cell_type": "code", "execution_count": null, @@ -342,7 +351,7 @@ "source": [ "plt.plot(loaded_diff.dt, loaded_diff.msd, 'k-')\n", "for i, ci in enumerate(credible_intervals):\n", - " plt.fill_between(loaded_diff.dt[5:],\n", + " plt.fill_between(loaded_diff.dt[3:],\n", " *np.percentile(ppd.T, ci, axis=1),\n", " alpha=alpha[i],\n", " color='#0173B2',\n", @@ -351,11 +360,18 @@ "plt.xlabel('$\\Delta t$/ps')\n", "plt.show()" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { "kernelspec": { - "display_name": "intensive", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, diff --git a/docs/source/vasp_dj.ipynb b/docs/source/vasp_dj.ipynb index f883448f..73d7e24d 100644 --- a/docs/source/vasp_dj.ipynb +++ b/docs/source/vasp_dj.ipynb @@ -50,7 +50,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "While the `b_params` dictionary describes the details of the bootstrapping process, these are documented in the [diffusion module](./diffusion.html#kinisi.diffusion.MSDBootstrap). Here, we indicate that we only want to investigate diffusion in the *xy*-plane of the system." + "While the `u_params` dictionary describes the details of the uncertainty calculation process, these are documented in the [diffusion module](./diffusion.html#kinisi.diffusion.MSDBootstrap). Here, we indicate that we only want to investigate diffusion in the *xy*-plane of the system." ] }, { @@ -61,7 +61,7 @@ }, "outputs": [], "source": [ - "b_params = {'dimension': 'xyz'}" + "u_params = {'dimension': 'xy'}" ] }, { @@ -73,7 +73,7 @@ "outputs": [], "source": [ "xd = Xdatcar('./example_XDATCAR.gz')\n", - "diff = JumpDiffusionAnalyzer.from_Xdatcar(xd, parser_params=p_params, bootstrap_params=b_params)" + "diff = JumpDiffusionAnalyzer.from_Xdatcar(xd, parser_params=p_params, uncertainty_params=u_params)" ] }, { @@ -345,9 +345,9 @@ ], "metadata": { "kernelspec": { - "display_name": "Python [conda env:kinisi]", + "display_name": "kinisi", "language": "python", - "name": "conda-env-kinisi-py" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -359,7 +359,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.15" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/kinisi/analyzer.py b/kinisi/analyzer.py index 5b50f735..afab4bdb 100644 --- a/kinisi/analyzer.py +++ b/kinisi/analyzer.py @@ -120,14 +120,13 @@ def _from_pymatgen(cls, return cls(u.delta_t, u.disp_3d, u._n_o, u.volume, **kwargs) else: raise ValueError('The dtype specified was not recognised, please consult the kinisi documentation.') - + @classmethod def _from_ase(cls, - trajectory: List[Union['ase.atoms.Atoms', - List['ase.atoms.Atoms']]], - parser_params: dict, - dtype: str = None, - **kwargs): + trajectory: List[Union['ase.atoms.Atoms', List['ase.atoms.Atoms']]], + parser_params: dict, + dtype: str = None, + **kwargs): """ Create a :py:class:`Analyzer` object from a list or nested list of :py:class:`ase.atoms.Atoms` objects. @@ -289,7 +288,7 @@ def _stack_trajectories(u: Union[MDAnalysisParser, PymatgenParser]) -> List[np.n disp[u[0].disp_3d[i].shape[0] * j:u[0].disp_3d[i].shape[0] * (j + 1)] = u[j].disp_3d[i] joint_disp_3d.append(disp) return joint_disp_3d - + def posterior_predictive(self, posterior_predictive_params: Union[dict, None] = None): """ Sample the posterior predictive distribution. The shape of the resulting array will be diff --git a/kinisi/conductivity_analyzer.py b/kinisi/conductivity_analyzer.py index d1d4ce6f..31545c62 100644 --- a/kinisi/conductivity_analyzer.py +++ b/kinisi/conductivity_analyzer.py @@ -27,7 +27,7 @@ class ConductivityAnalyzer(Analyzer): There is one array in the list for each delta_t value. Note: it is necessary to use a list of arrays as the number of observations is not necessary the same at each data point. :param volume: The volume of the simulation cell. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.DiffBootstrap` object. See + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.DiffBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :param ionic_charge: The charge on the mobile ions, either an array with a value for each ion or a scalar if all values are the same. Optional, default is :py:attr:`1`. @@ -64,7 +64,7 @@ def from_pymatgen(cls, List['pymatgen.core.structure.Structure']]], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None, + uncertainty_params: dict = None, ionic_charge: Union[np.ndarray, int] = 1): """ Create a :py:class:`ConductivityAnalyzer` object from a list or nested list of @@ -78,29 +78,27 @@ def from_pymatgen(cls, these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :param ionic_charge: The charge on the mobile ions, either an array with a value for each ion or a scalar if all values are the same. Optional, default is :py:attr:`1`. :return: Relevant :py:class:`ConductivityAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} cond_anal = super()._from_pymatgen(trajectory, parser_params, dtype=dtype) cond_anal._diff = diffusion.MSCDBootstrap(cond_anal._delta_t, cond_anal._disp_3d, ionic_charge, cond_anal._n_o, - **bootstrap_params) + **uncertainty_params) return cond_anal - @classmethod def from_ase(cls, - trajectory: List[Union['ase.atoms.Atoms', - List['ase.atom.Atoms']]], - parser_params: dict, - dtype: str = None, - bootstrap_params: dict = None, - ionic_charge: Union[np.ndarray, int] = 1): + trajectory: List[Union['ase.atoms.Atoms', List['ase.atom.Atoms']]], + parser_params: dict, + dtype: str = None, + uncertainty_params: dict = None, + ionic_charge: Union[np.ndarray, int] = 1): """ Create a :py:class:`ConductivityAnalyzer` object from a list or nested list of :py:class:`ase.Atoms` objects. @@ -113,18 +111,18 @@ def from_ase(cls, these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :param ionic_charge: The charge on the mobile ions, either an array with a value for each ion or a scalar if all values are the same. Optional, default is :py:attr:`1`. :return: Relevant :py:class:`ConductivityAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} cond_anal = super()._from_ase(trajectory, parser_params, dtype=dtype) cond_anal._diff = diffusion.MSCDBootstrap(cond_anal._delta_t, cond_anal._disp_3d, ionic_charge, cond_anal._n_o, - **bootstrap_params) + **uncertainty_params) return cond_anal @classmethod @@ -132,7 +130,7 @@ def from_Xdatcar(cls, trajectory: Union['pymatgen.io.vasp.outputs.Xdatcar', List['pymatgen.io.vasp.outputs.Xdatcar']], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None, + uncertainty_params: dict = None, ionic_charge: Union[np.ndarray, int] = 1): """ Create a :py:class:`ConductivityAnalyzer` object from a single or a list of @@ -146,18 +144,18 @@ def from_Xdatcar(cls, then it is necessary to identify if these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :param ionic_charge: The charge on the mobile ions, either an array with a value for each ion or a scalar if all values are the same. Optional, default is :py:attr:`1`. :return: Relevant :py:class:`ConductivityAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} cond_anal = super()._from_Xdatcar(trajectory, parser_params, dtype=dtype) cond_anal._diff = diffusion.MSCDBootstrap(cond_anal._delta_t, cond_anal._disp_3d, ionic_charge, cond_anal._n_o, - **bootstrap_params) + **uncertainty_params) return cond_anal @classmethod @@ -165,7 +163,7 @@ def from_file(cls, trajectory: Union[str, List[str]], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None, + uncertainty_params: dict = None, ionic_charge: Union[np.ndarray, int] = 1): """ Create a :py:class:`ConductivityAnalyzer` object from a single or a list of Xdatcar file(s). @@ -177,18 +175,18 @@ def from_file(cls, list of files is passed, then it is necessary to identify if these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :param ionic_charge: The charge on the mobile ions, either an array with a value for each ion or a scalar if all values are the same. Optional, default is :py:attr:`1`. :return: Relevant :py:class:`ConductivityAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} cond_anal = super()._from_file(trajectory, parser_params, dtype=dtype) cond_anal._diff = diffusion.MSCDBootstrap(cond_anal._delta_t, cond_anal._disp_3d, ionic_charge, cond_anal._n_o, - **bootstrap_params) + **uncertainty_params) return cond_anal @classmethod @@ -196,7 +194,7 @@ def from_universe(cls, trajectory: 'MDAnalysis.core.universe.Universe', parser_params: dict, dtype: str = None, - bootstrap_params: dict = None, + uncertainty_params: dict = None, ionic_charge: Union[np.ndarray, int] = 1): """ Create an :py:class:`ConductivityAnalyzer` object from an :py:class:`MDAnalysis.core.universe.Universe` object. @@ -209,18 +207,18 @@ def from_universe(cls, :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be :py:attr:`identical`. For a series of consecutive trajectories, please construct the relevant object using :py:mod:`MDAnalysis`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :param ionic_charge: The charge on the mobile ions, either an array with a value for each ion or a scalar if all values are the same. Optional, default is :py:attr:`1`. :return: Relevant :py:class:`ConductivityAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} cond_anal = super()._from_universe(trajectory, parser_params, dtype=dtype) cond_anal._diff = diffusion.MSCDBootstrap(cond_anal._delta_t, cond_anal._disp_3d, ionic_charge, cond_anal._n_o, - **bootstrap_params) + **uncertainty_params) return cond_anal def conductivity(self, start_dt: float, temperature: float, conductivity_params: Union[dict, None] = None): diff --git a/kinisi/diffusion_analyzer.py b/kinisi/diffusion_analyzer.py index 7a1bf8f0..487093fd 100644 --- a/kinisi/diffusion_analyzer.py +++ b/kinisi/diffusion_analyzer.py @@ -27,7 +27,7 @@ class DiffusionAnalyzer(Analyzer): There is one array in the list for each delta_t value. Note: it is necessary to use a list of arrays as the number of observations is not necessary the same at each data point. :param volume: The volume of the simulation cell. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.DiffBootstrap` object. See + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.DiffBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. """ @@ -62,7 +62,7 @@ def from_pymatgen(cls, List['pymatgen.core.structure.Structure']]], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None): + uncertainty_params: dict = None): """ Create a :py:class:`DiffusionAnalyzer` object from a list or nested list of :py:class:`pymatgen.core.structure.Structure` objects. @@ -76,23 +76,23 @@ def from_pymatgen(cls, these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`DiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} diff = super()._from_pymatgen(trajectory, parser_params, dtype=dtype) - diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **bootstrap_params) + diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **uncertainty_params) return diff - + @classmethod def from_ase(cls, - trajectory: List[Union['ase.atoms.Atoms', List['ase.atoms.Atoms']]], - parser_params: dict, - dtype: str = None, - bootstrap_params: dict = None): + trajectory: List[Union['ase.atoms.Atoms', List['ase.atoms.Atoms']]], + parser_params: dict, + dtype: str = None, + uncertainty_params: dict = None): """ Create a :py:class:`DiffusionAnalyzer` object from a list or nested list of :py:class:`ase.atoms.Atoms` objects. @@ -106,15 +106,15 @@ def from_ase(cls, these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`DiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} diff = super()._from_ase(trajectory, parser_params, dtype=dtype) - diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **bootstrap_params) + diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **uncertainty_params) return diff @classmethod @@ -122,7 +122,7 @@ def from_Xdatcar(cls, trajectory: Union['pymatgen.io.vasp.outputs.Xdatcar', List['pymatgen.io.vasp.outputs.Xdatcar']], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None): + uncertainty_params: dict = None): """ Create a :py:class:`DiffusionAnalyzer` object from a single or a list of :py:class:`pymatgen.io.vasp.outputs.Xdatcar` objects. @@ -135,15 +135,15 @@ def from_Xdatcar(cls, then it is necessary to identify if these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`DiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} diff = super()._from_Xdatcar(trajectory, parser_params, dtype=dtype) - diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **bootstrap_params) + diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **uncertainty_params) return diff @classmethod @@ -151,7 +151,7 @@ def from_file(cls, trajectory: Union[str, List[str]], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None): + uncertainty_params: dict = None): """ Create a :py:class:`DiffusionAnalyzer` object from a single or a list of Xdatcar file(s). @@ -162,15 +162,15 @@ def from_file(cls, list of files is passed, then it is necessary to identify if these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`DiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} diff = super()._from_file(trajectory, parser_params, dtype=dtype) - diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **bootstrap_params) + diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **uncertainty_params) return diff @classmethod @@ -178,7 +178,7 @@ def from_universe(cls, trajectory: 'MDAnalysis.core.universe.Universe', parser_params: dict, dtype: str = None, - bootstrap_params: dict = None): + uncertainty_params: dict = None): """ Create an :py:class:`DiffusionAnalyzer` object from an :py:class:`MDAnalysis.core.universe.Universe` object. @@ -190,15 +190,15 @@ def from_universe(cls, :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be :py:attr:`identical`. For a series of consecutive trajectories, please construct the relevant object using :py:mod:`MDAnalysis`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`DiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} diff = super()._from_universe(trajectory, parser_params, dtype=dtype) - diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **bootstrap_params) + diff._diff = diffusion.MSDBootstrap(diff._delta_t, diff._disp_3d, diff._n_o, **uncertainty_params) return diff def diffusion(self, start_dt: float, diffusion_params: Union[dict, None] = None): diff --git a/kinisi/jump_diffusion_analyzer.py b/kinisi/jump_diffusion_analyzer.py index 94fdea9c..eacf1d0e 100644 --- a/kinisi/jump_diffusion_analyzer.py +++ b/kinisi/jump_diffusion_analyzer.py @@ -27,7 +27,7 @@ class JumpDiffusionAnalyzer(Analyzer): There is one array in the list for each delta_t value. Note: it is necessary to use a list of arrays as the number of observations is not necessary the same at each data point. :param volume: The volume of the simulation cell. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.DiffBootstrap` object. See + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.DiffBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. """ @@ -62,7 +62,7 @@ def from_pymatgen(cls, List['pymatgen.core.structure.Structure']]], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None): + uncertainty_params: dict = None): """ Create a :py:class:`JumpDiffusionAnalyzer` object from a list or nested list of :py:class:`pymatgen.core.structure.Structure` objects. @@ -75,24 +75,24 @@ def from_pymatgen(cls, these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`JumpDiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} jdiff_anal = super()._from_pymatgen(trajectory, parser_params, dtype=dtype) jdiff_anal._diff = diffusion.MSTDBootstrap(jdiff_anal._delta_t, jdiff_anal._disp_3d, jdiff_anal._n_o, - **bootstrap_params) + **uncertainty_params) return jdiff_anal - + @classmethod def from_ase(cls, - trajectory: List[Union['ase.atoms.Atoms', List['ase.atoms.Atoms']]], - parser_params: dict, - dtype: str = None, - bootstrap_params: dict = None): + trajectory: List[Union['ase.atoms.Atoms', List['ase.atoms.Atoms']]], + parser_params: dict, + dtype: str = None, + uncertainty_params: dict = None): """ Create a :py:class:`JumpDiffusionAnalyzer` object from a list or nested list of :py:class:`ase.atoms.Atoms` objects. @@ -105,16 +105,16 @@ def from_ase(cls, these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`JumpDiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} jdiff_anal = super()._from_ase(trajectory, parser_params, dtype=dtype) jdiff_anal._diff = diffusion.MSTDBootstrap(jdiff_anal._delta_t, jdiff_anal._disp_3d, jdiff_anal._n_o, - **bootstrap_params) + **uncertainty_params) return jdiff_anal @classmethod @@ -122,7 +122,7 @@ def from_Xdatcar(cls, trajectory: Union['pymatgen.io.vasp.outputs.Xdatcar', List['pymatgen.io.vasp.outputs.Xdatcar']], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None): + uncertainty_params: dict = None): """ Create a :py:class:`JumpDiffusionAnalyzer` object from a single or a list of :py:class:`pymatgen.io.vasp.outputs.Xdatcar` objects. @@ -135,16 +135,16 @@ def from_Xdatcar(cls, then it is necessary to identify if these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`JumpDiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} jdiff_anal = super()._from_Xdatcar(trajectory, parser_params, dtype=dtype) jdiff_anal._diff = diffusion.MSTDBootstrap(jdiff_anal._delta_t, jdiff_anal._disp_3d, jdiff_anal._n_o, - **bootstrap_params) + **uncertainty_params) return jdiff_anal @classmethod @@ -152,7 +152,7 @@ def from_file(cls, trajectory: Union[str, List[str]], parser_params: dict, dtype: str = None, - bootstrap_params: dict = None): + uncertainty_params: dict = None): """ Create a :py:class:`JumpDiffusionAnalyzer` object from a single or a list of Xdatcar file(s). @@ -163,16 +163,16 @@ def from_file(cls, list of files is passed, then it is necessary to identify if these constitute a series of :py:attr:`consecutive` trajectories or a series of :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be either :py:attr:`consecutive` or :py:attr:`identical`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`JumpDiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} jdiff_anal = super()._from_file(trajectory, parser_params, dtype=dtype) jdiff_anal._diff = diffusion.MSTDBootstrap(jdiff_anal._delta_t, jdiff_anal._disp_3d, jdiff_anal._n_o, - **bootstrap_params) + **uncertainty_params) return jdiff_anal @classmethod @@ -180,7 +180,7 @@ def from_universe(cls, trajectory: 'MDAnalysis.core.universe.Universe', parser_params: dict, dtype: str = None, - bootstrap_params: dict = None): + uncertainty_params: dict = None): """ Create an :py:class:`JumpDiffusionAnalyzer` object from an :py:class:`MDAnalysis.core.universe.Universe` object. @@ -192,16 +192,16 @@ def from_universe(cls, :py:attr:`identical` starting points with different random seeds, in which case the `dtype` should be :py:attr:`identical`. For a series of consecutive trajectories, please construct the relevant object using :py:mod:`MDAnalysis`. - :param bootstrap_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the + :param uncertainty_params: The parameters for the :py:class:`kinisi.diffusion.MSDBootstrap` object. See the appropriate documentation for more guidance on this. Optional, default is the default bootstrap parameters. :return: Relevant :py:class:`JumpDiffusionAnalyzer` object. """ - if bootstrap_params is None: - bootstrap_params = {} + if uncertainty_params is None: + uncertainty_params = {} jdiff_anal = super()._from_universe(trajectory, parser_params, dtype=dtype) jdiff_anal._diff = diffusion.MSTDBootstrap(jdiff_anal._delta_t, jdiff_anal._disp_3d, jdiff_anal._n_o, - **bootstrap_params) + **uncertainty_params) return jdiff_anal def jump_diffusion(self, start_dt: float, jump_diffusion_params: Union[dict, None] = None): diff --git a/kinisi/tests/test_analyze.py b/kinisi/tests/test_analyze.py index a21e06d3..26e95f77 100644 --- a/kinisi/tests/test_analyze.py +++ b/kinisi/tests/test_analyze.py @@ -33,7 +33,6 @@ dc_params = {'specie': 'Li', 'time_step': 1.0 * 1e-3, 'step_skip': 1} - class TestAnalyzer(unittest.TestCase): """ Tests for the Analyzer base class. @@ -45,7 +44,7 @@ def tearDownClass(cls): for test_file in test_files: if os.path.exists(test_file): os.remove(test_file) - + def test_save(self): a = Analyzer._from_pymatgen(xd.structures, parser_params=da_params) filename = "test_save" @@ -212,7 +211,7 @@ class TestDiffusionAnalyzer(unittest.TestCase): def test_properties(self): a = DiffusionAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}) + uncertainty_params={'random_state': np.random.RandomState(0)}) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.msd, a._diff.n) assert_almost_equal(a.msd_std, a._diff.s) @@ -225,7 +224,7 @@ def test_diffusion(self): with warnings.catch_warnings(record=True) as _: a = DiffusionAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}) + uncertainty_params={'random_state': np.random.RandomState(0)}) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.msd, a._diff.n) assert_almost_equal(a.msd_std, a._diff.s) @@ -240,7 +239,7 @@ def test_diffusion_ppd(self): with warnings.catch_warnings(record=True) as _: a = DiffusionAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}) + uncertainty_params={'random_state': np.random.RandomState(0)}) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.msd, a._diff.n) assert_almost_equal(a.msd_std, a._diff.s) @@ -257,7 +256,7 @@ def test_dictionary_roundtrip(self): with warnings.catch_warnings(record=True) as _: a = DiffusionAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}) + uncertainty_params={'random_state': np.random.RandomState(0)}) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.msd, a._diff.n) assert_almost_equal(a.msd_std, a._diff.s) @@ -287,7 +286,7 @@ def test_properties(self): with warnings.catch_warnings(record=True) as w: a = JumpDiffusionAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}) + uncertainty_params={'random_state': np.random.RandomState(0)}) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.mstd, a._diff.n) assert_almost_equal(a.mstd_std, a._diff.s) @@ -299,7 +298,7 @@ def test_diffusion(self): with warnings.catch_warnings(record=True) as w: a = JumpDiffusionAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}) + uncertainty_params={'random_state': np.random.RandomState(0)}) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.mstd, a._diff.n) assert_almost_equal(a.mstd_std, a._diff.s) @@ -314,7 +313,7 @@ def test_dictionary_roundtrip(self): with warnings.catch_warnings(record=True) as w: a = JumpDiffusionAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}) + uncertainty_params={'random_state': np.random.RandomState(0)}) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.mstd, a._diff.n) assert_almost_equal(a.mstd_std, a._diff.s) @@ -344,7 +343,7 @@ def test_properties(self): with warnings.catch_warnings(record=True) as w: a = ConductivityAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}, + uncertainty_params={'random_state': np.random.RandomState(0)}, ionic_charge=1) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.mscd, a._diff.n) @@ -357,7 +356,7 @@ def test_diffusion(self): with warnings.catch_warnings(record=True) as w: a = ConductivityAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}, + uncertainty_params={'random_state': np.random.RandomState(0)}, ionic_charge=1) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.mscd, a._diff.n) @@ -373,7 +372,7 @@ def test_dictionary_roundtrip(self): with warnings.catch_warnings(record=True) as w: a = ConductivityAnalyzer.from_pymatgen(xd.structures, parser_params=da_params, - bootstrap_params={'random_state': np.random.RandomState(0)}) + uncertainty_params={'random_state': np.random.RandomState(0)}) assert_almost_equal(a.dt, a._diff.dt) assert_almost_equal(a.mscd, a._diff.n) assert_almost_equal(a.mscd_std, a._diff.s)