inftools 2026.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. inftools-2026.1/LICENSE +21 -0
  2. inftools-2026.1/PKG-INFO +94 -0
  3. inftools-2026.1/README.md +72 -0
  4. inftools-2026.1/inftools/analysis/Free_energy.py +80 -0
  5. inftools-2026.1/inftools/analysis/Wham_Pcross.py +853 -0
  6. inftools-2026.1/inftools/analysis/get-interfaces.py +119 -0
  7. inftools-2026.1/inftools/analysis/gromacs.py +29 -0
  8. inftools-2026.1/inftools/analysis/rec_error.py +31 -0
  9. inftools-2026.1/inftools/analysis/toolsWHAM.py +43 -0
  10. inftools-2026.1/inftools/analysis/wham.py +67 -0
  11. inftools-2026.1/inftools/bin.py +31 -0
  12. inftools-2026.1/inftools/exercises/puckering.py +574 -0
  13. inftools-2026.1/inftools/misc/async_postprocess.py +48 -0
  14. inftools-2026.1/inftools/misc/binhelper.py +65 -0
  15. inftools-2026.1/inftools/misc/calc_help.py +17 -0
  16. inftools-2026.1/inftools/misc/data_helper.py +48 -0
  17. inftools-2026.1/inftools/misc/free_help.py +35 -0
  18. inftools-2026.1/inftools/misc/infinit_helper.py +385 -0
  19. inftools-2026.1/inftools/misc/tomlreader.py +16 -0
  20. inftools-2026.1/inftools/misc/xyz_help.py +15 -0
  21. inftools-2026.1/inftools/report/clean_jupyter.sh +3 -0
  22. inftools-2026.1/inftools/report/infretis_report.ipynb +389 -0
  23. inftools-2026.1/inftools/report/report.py +33 -0
  24. inftools-2026.1/inftools/tistools/calc_reaction_free_energy.py +75 -0
  25. inftools-2026.1/inftools/tistools/calc_simtime.py +59 -0
  26. inftools-2026.1/inftools/tistools/calc_transmission.py +78 -0
  27. inftools-2026.1/inftools/tistools/check_data.py +67 -0
  28. inftools-2026.1/inftools/tistools/collect_trainingset.py +136 -0
  29. inftools-2026.1/inftools/tistools/combine_results.py +122 -0
  30. inftools-2026.1/inftools/tistools/concatenate.py +118 -0
  31. inftools-2026.1/inftools/tistools/fener_histo.py +19 -0
  32. inftools-2026.1/inftools/tistools/flow.py +141 -0
  33. inftools-2026.1/inftools/tistools/flow2.py +93 -0
  34. inftools-2026.1/inftools/tistools/flow_op.py +47 -0
  35. inftools-2026.1/inftools/tistools/get_interfaces.py +242 -0
  36. inftools-2026.1/inftools/tistools/initial_paths.py +259 -0
  37. inftools-2026.1/inftools/tistools/max_op.py +50 -0
  38. inftools-2026.1/inftools/tistools/path_weights.py +127 -0
  39. inftools-2026.1/inftools/tistools/pcross_errors.py +101 -0
  40. inftools-2026.1/inftools/tistools/plot_ens.py +69 -0
  41. inftools-2026.1/inftools/tistools/plot_error.py +47 -0
  42. inftools-2026.1/inftools/tistools/plot_msg.py +129 -0
  43. inftools-2026.1/inftools/tistools/progress.py +127 -0
  44. inftools-2026.1/inftools/tistools/recalculate_order.py +107 -0
  45. inftools-2026.1/inftools/tistools/recalculate_traj.py +68 -0
  46. inftools-2026.1/inftools/tistools/recalculate_traj_ase.py +73 -0
  47. inftools-2026.1/inftools/tistools/shoot.py +127 -0
  48. inftools-2026.1/inftools/tistools/simacc.py +46 -0
  49. inftools-2026.1/inftools/tistools/store_txt.py +66 -0
  50. inftools-2026.1/inftools/tistools/trajtxt_conv.py +78 -0
  51. inftools-2026.1/inftools/xyz/center_xyz.py +43 -0
  52. inftools-2026.1/pyproject.toml +68 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 infretis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,94 @@
1
+ Metadata-Version: 2.4
2
+ Name: inftools
3
+ Version: 2026.1
4
+ Summary: Useful tools for infRETIS simulations
5
+ License: MIT
6
+ License-File: LICENSE
7
+ Keywords: simulation,retis,molecular-dynamics,path-sampling
8
+ Author: Daniel Zhang
9
+ Author-email: daniel.t.zhang@ntnu.no
10
+ Requires-Python: >=3.10,<3.14
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3.13
17
+ Requires-Dist: typer (>=0.19,<0.20)
18
+ Project-URL: Homepage, https://github.com/infretis/inftools
19
+ Project-URL: Repository, https://github.com/infretis/inftools
20
+ Description-Content-Type: text/markdown
21
+
22
+ # &infin;tools 🧰
23
+ 👷‍♂️ Work in progress python package that provide various &infin;RETIS tools for tasks like setting up simulations and analyzing data. 📈
24
+
25
+ 🤝 Contributions of tools and modifications are welcome – feel free to submit your enhancements! 🚀
26
+ ## Installation
27
+
28
+ 1. Clone the repository
29
+ 2. (Optional) Create a virtual environment
30
+ 3. Install with:
31
+ ```bash
32
+ python -m pip install -e .
33
+ ```
34
+ ## Usage
35
+ ```bash
36
+ inft -h
37
+ ```
38
+
39
+ #### `inft center_periodic`
40
+
41
+ The command `inft center_periodic` can be run to re-center an .xyz trajectory to a certain atom index. For example, to center the first atom `C` at index 0 in the `co2.xyz` frame in [`examples/co2.xyz`](examples/co2.xyz) with cubic box length of 12.4138, the following command can be ran:
42
+
43
+ ```bash
44
+ inft center_periodic -i co2.xyz -o co2_c.xyz -c 12.4138 -idx 0
45
+ ```
46
+
47
+ ## Development practice
48
+
49
+ Current CLI capabilities is powered by the [Typer](https://typer.tiangolo.com/) python library.
50
+
51
+ ### Python files
52
+
53
+ Any function `function_name` in a python file `*.py` with the following structure
54
+
55
+ ```python3
56
+ from typing import Annotated
57
+
58
+ def function_name(
59
+ args1: Annotated[str, typer.Option("-args1", help="var1")],
60
+ args2: Annotated[int, typer.Option("-args2", help="var2")],
61
+ ):
62
+ """
63
+ Function description
64
+ """
65
+ ```
66
+
67
+ added to the folders [`inftools/exercises`](inftools/exercises), [`inftools/tistools`](inftools/tistools) and [`inftools/xyz`](inftools/xyz) will automatically be callable via the terminal as
68
+
69
+ ```bash
70
+ inft function_name -args1 var1 -args2 var2
71
+ ```
72
+
73
+ ### Individual functions
74
+
75
+ Individual functions can also be added to the CLI library by including them in [`inftools/bin.py`](inftools/bin.py), as done for the wham function in the [`inftools/analysis`](inftools/analysis) folder:
76
+
77
+ ```python3
78
+ from inftools.analysis.wham import wham
79
+
80
+ MAPPER["wham"] = wham
81
+ ```
82
+
83
+ ### Testing
84
+
85
+ The CLI functions are tested by utilizing the [pytest](https://docs.pytest.org/en/stable/) python library.
86
+
87
+ The tests included in the [`inftools/test`](inftools/) folder can be ran by running the following command in the terminal:
88
+
89
+ ```bash
90
+ pytest
91
+ ```
92
+
93
+ We currently do not have a testing policy but please do include tests for the included CLI functions for higher coverage.
94
+
@@ -0,0 +1,72 @@
1
+ # &infin;tools 🧰
2
+ 👷‍♂️ Work in progress python package that provide various &infin;RETIS tools for tasks like setting up simulations and analyzing data. 📈
3
+
4
+ 🤝 Contributions of tools and modifications are welcome – feel free to submit your enhancements! 🚀
5
+ ## Installation
6
+
7
+ 1. Clone the repository
8
+ 2. (Optional) Create a virtual environment
9
+ 3. Install with:
10
+ ```bash
11
+ python -m pip install -e .
12
+ ```
13
+ ## Usage
14
+ ```bash
15
+ inft -h
16
+ ```
17
+
18
+ #### `inft center_periodic`
19
+
20
+ The command `inft center_periodic` can be run to re-center an .xyz trajectory to a certain atom index. For example, to center the first atom `C` at index 0 in the `co2.xyz` frame in [`examples/co2.xyz`](examples/co2.xyz) with cubic box length of 12.4138, the following command can be ran:
21
+
22
+ ```bash
23
+ inft center_periodic -i co2.xyz -o co2_c.xyz -c 12.4138 -idx 0
24
+ ```
25
+
26
+ ## Development practice
27
+
28
+ Current CLI capabilities is powered by the [Typer](https://typer.tiangolo.com/) python library.
29
+
30
+ ### Python files
31
+
32
+ Any function `function_name` in a python file `*.py` with the following structure
33
+
34
+ ```python3
35
+ from typing import Annotated
36
+
37
+ def function_name(
38
+ args1: Annotated[str, typer.Option("-args1", help="var1")],
39
+ args2: Annotated[int, typer.Option("-args2", help="var2")],
40
+ ):
41
+ """
42
+ Function description
43
+ """
44
+ ```
45
+
46
+ added to the folders [`inftools/exercises`](inftools/exercises), [`inftools/tistools`](inftools/tistools) and [`inftools/xyz`](inftools/xyz) will automatically be callable via the terminal as
47
+
48
+ ```bash
49
+ inft function_name -args1 var1 -args2 var2
50
+ ```
51
+
52
+ ### Individual functions
53
+
54
+ Individual functions can also be added to the CLI library by including them in [`inftools/bin.py`](inftools/bin.py), as done for the wham function in the [`inftools/analysis`](inftools/analysis) folder:
55
+
56
+ ```python3
57
+ from inftools.analysis.wham import wham
58
+
59
+ MAPPER["wham"] = wham
60
+ ```
61
+
62
+ ### Testing
63
+
64
+ The CLI functions are tested by utilizing the [pytest](https://docs.pytest.org/en/stable/) python library.
65
+
66
+ The tests included in the [`inftools/test`](inftools/) folder can be ran by running the following command in the terminal:
67
+
68
+ ```bash
69
+ pytest
70
+ ```
71
+
72
+ We currently do not have a testing policy but please do include tests for the included CLI functions for higher coverage.
@@ -0,0 +1,80 @@
1
+ import os
2
+ import numpy as np
3
+
4
+ def extract(trajfile, xcol, ycol=None):
5
+ # Read and process the file
6
+ traj = np.loadtxt(trajfile)
7
+ data = traj[1:-1, xcol] # remove first and last frames
8
+ if ycol is not None:
9
+ data = np.vstack((data, traj[1:-1, ycol]))
10
+ return data
11
+
12
+
13
+ def update_histogram(data, factor, histogram, Minx, Miny, dx, dy):
14
+ if Miny is not None and dy is not None:
15
+ x = data[0]
16
+ y = data[1]
17
+
18
+ ix = ((x - Minx) / dx).astype(int)
19
+ iy = ((y - Miny) / dy).astype(int)
20
+
21
+ np.add.at(histogram, (ix, iy), factor)
22
+
23
+ else:
24
+ x = data if data.ndim == 1 else data[:,0] # make sure x is one dimensional
25
+ ix = ((x - Minx) / dx).astype(int)
26
+ np.add.at(histogram, ix, factor)
27
+
28
+ return histogram
29
+
30
+
31
+ def calculate_free_energy(trajlabels, WFtot, Trajdir, outfolder, histo_stuff):
32
+ print("We are now going to perform the Landau Free Energy calculations")
33
+ Nbinsx, Nbinsy = histo_stuff["nbx"], histo_stuff["nby"]
34
+ Maxx, Minx = histo_stuff["maxx"], histo_stuff["minx"]
35
+ Maxy, Miny = histo_stuff["maxy"], histo_stuff["miny"]
36
+ xcol, ycol = histo_stuff["xcol"], histo_stuff["ycol"]
37
+
38
+ if any(var is None for var in [Nbinsy, Maxy, Miny, ycol]):
39
+ none_vars = [name for name, var in zip(["nby", "maxy", "miny", "ycol"], [Nbinsy, Maxy, Miny, ycol]) if var is None]
40
+ assert all(var is None for var in [Nbinsy, Maxy, Miny, ycol]), \
41
+ f"The following variables are None and should be set: {', '.join(none_vars)}"
42
+ if Nbinsy is not None:
43
+ histogram = np.zeros((Nbinsx, Nbinsy))
44
+ dy = (Maxy - Miny) / Nbinsy
45
+ yval = [Miny + 0.5 * dy + i * dy for i in range(Nbinsy)]
46
+ else:
47
+ histogram = np.zeros(Nbinsx)
48
+ dy = None
49
+ yval = None
50
+ dx = (Maxx - Minx) / Nbinsx
51
+ xval = [Minx + 0.5 * dx + i * dx for i in range(Nbinsx)]
52
+
53
+ h5file = histo_stuff.get("h5")
54
+ if h5file is not None and os.path.exists(h5file):
55
+ import h5py
56
+ with h5py.File(h5file, "r") as h5f:
57
+ for label, factor in zip(trajlabels, WFtot):
58
+ data = h5f[f"{label}/order.txt"]
59
+ if ycol is not None:
60
+ data = data[1:-1,[xcol,ycol]].T
61
+ else:
62
+ data = data[1:-1, xcol]
63
+ histogram = update_histogram(data, factor, histogram, Minx, Miny, dx, dy)
64
+ else:
65
+ for label, factor in zip(trajlabels, WFtot):
66
+ trajfile = Trajdir + "/" + str(label) + "/order.txt"
67
+ data = extract(trajfile, xcol, ycol)
68
+ histogram = update_histogram(data, factor, histogram, Minx, Miny, dx, dy)
69
+
70
+ # normalize such that the highest value equals 1
71
+ max_value = np.max(histogram)
72
+ histogram /= max_value
73
+
74
+ np.savetxt(os.path.join(outfolder, "histo_xval.txt"), xval)
75
+ if not yval is None:
76
+ np.savetxt(os.path.join(outfolder, "histo_yval.txt"), yval)
77
+ np.savetxt(os.path.join(outfolder, "histo_probability.txt"), histogram)
78
+
79
+ histogram = -np.log(histogram) # get Landau free energy in kBT units
80
+ np.savetxt(os.path.join(outfolder, "histo_free_energy.txt"), histogram)