|
29 | 29 | } |
30 | 30 | ], |
31 | 31 | "source": [ |
| 32 | + "from __future__ import annotations\n", |
| 33 | + "\n", |
| 34 | + "import numpy as np\n", |
| 35 | + "\n", |
32 | 36 | "from pymatgen.analysis.diffusion.aimd.pathway import ProbabilityDensityAnalysis\n", |
33 | 37 | "from pymatgen.core import Structure\n", |
34 | | - "import numpy as np\n", |
35 | 38 | "\n", |
36 | | - "#First prepare the structure and ionic trajectories files\n", |
| 39 | + "# First prepare the structure and ionic trajectories files\n", |
37 | 40 | "trajectories = np.load(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_trajectories.npy\")\n", |
38 | 41 | "structure = Structure.from_file(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4.cif\", False)\n", |
39 | 42 | "\n", |
40 | | - "#ProbabilityDensityAnalysis object\n", |
| 43 | + "# ProbabilityDensityAnalysis object\n", |
41 | 44 | "pda = ProbabilityDensityAnalysis(structure, trajectories, interval=0.5)\n", |
42 | | - "#Save probability distribution to a CHGCAR-like file\n", |
| 45 | + "# Save probability distribution to a CHGCAR-like file\n", |
43 | 46 | "pda.to_chgcar(filename=\"CHGCAR_new.vasp\")\n", |
44 | 47 | "\n", |
45 | | - "print(\"Maximum: %s, Minimum: %s\" % (pda.Pr.max(), pda.Pr.min()))\n", |
| 48 | + "print(f\"Maximum: {pda.Pr.max()}, Minimum: {pda.Pr.min()}\")\n", |
46 | 49 | "# \\int P(r)d^3r = 1\n", |
47 | | - "print(\"Total probability: %s\" % np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2]))\n" |
| 50 | + "print(f\"Total probability: {np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0] / pda.lens[1] / pda.lens[2])}\")" |
48 | 51 | ] |
49 | 52 | }, |
50 | 53 | { |
|
69 | 72 | } |
70 | 73 | ], |
71 | 74 | "source": [ |
72 | | - "from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer\n", |
73 | 75 | "import json\n", |
74 | 76 | "\n", |
75 | | - "#ProbabilityDensityAnalysis object\n", |
76 | | - "filename=\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"\n", |
| 77 | + "from pymatgen.analysis.diffusion.analyzer import DiffusionAnalyzer\n", |
| 78 | + "\n", |
| 79 | + "# ProbabilityDensityAnalysis object\n", |
| 80 | + "filename = \"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"\n", |
77 | 81 | "\n", |
78 | | - "data = json.load(open(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\", \"r\"))\n", |
| 82 | + "data = json.load(open(\"../pymatgen/analysis/diffusion/aimd/tests/cNa3PS4_pda.json\"))\n", |
79 | 83 | "diff_analyzer = DiffusionAnalyzer.from_dict(data)\n", |
80 | 84 | "\n", |
81 | | - "pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diff_analyzer, interval=0.5,\n", |
82 | | - " species=(\"Na\", \"Li\"))\n", |
83 | | - "#Save probability distribution to a CHGCAR-like file\n", |
| 85 | + "pda = ProbabilityDensityAnalysis.from_diffusion_analyzer(diff_analyzer, interval=0.5, species=(\"Na\", \"Li\"))\n", |
| 86 | + "# Save probability distribution to a CHGCAR-like file\n", |
84 | 87 | "pda.to_chgcar(filename=\"CHGCAR_new2.vasp\")\n", |
85 | 88 | "\n", |
86 | | - "print(\"Maximum: %s, Minimum: %s\" % (pda.Pr.max(), pda.Pr.min()))\n", |
| 89 | + "print(f\"Maximum: {pda.Pr.max()}, Minimum: {pda.Pr.min()}\")\n", |
87 | 90 | "# \\int P(r)d^3r = 1\n", |
88 | | - "print(\"Total probability: %s\" % np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0]/pda.lens[1]/pda.lens[2]))\n" |
| 91 | + "print(f\"Total probability: {np.sum(pda.Pr * pda.structure.lattice.volume / pda.lens[0] / pda.lens[1] / pda.lens[2])}\")" |
89 | 92 | ] |
90 | 93 | } |
91 | 94 | ], |
92 | 95 | "metadata": { |
93 | 96 | "kernelspec": { |
94 | | - "display_name": "Python 3", |
| 97 | + "display_name": "Python 3 (ipykernel)", |
95 | 98 | "language": "python", |
96 | 99 | "name": "python3" |
97 | 100 | }, |
|
105 | 108 | "name": "python", |
106 | 109 | "nbconvert_exporter": "python", |
107 | 110 | "pygments_lexer": "ipython3", |
108 | | - "version": "3.8.8" |
| 111 | + "version": "3.11.10" |
109 | 112 | } |
110 | 113 | }, |
111 | 114 | "nbformat": 4, |
112 | | - "nbformat_minor": 1 |
| 115 | + "nbformat_minor": 4 |
113 | 116 | } |
0 commit comments