Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

MDSuite.py 2.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  1. import matplotlib.pyplot as plt
  2. import mdsuite as mds
  3. import pandas as pd
  4. from zntrack import Node, dvc, zn
  5. from . import LammpsSimulator
  6. class MDSuiteDB(Node):
  7. simulator: LammpsSimulator = zn.deps()
  8. project_path = dvc.outs("mdsuite")
  9. def __init__(self, simulator: LammpsSimulator = None, **kwargs):
  10. super().__init__(**kwargs)
  11. self.simulator = simulator
  12. def run(self):
  13. project = mds.Project(self.project_path)
  14. project.add_experiment(
  15. name="NaCl_example_data",
  16. timestep=self.simulator.parameters.timestep,
  17. temperature=self.simulator.parameters.temperature,
  18. units="metal",
  19. simulation_data=self.simulator.dump_file,
  20. )
  21. class EinsteinDiffusionNode(Node):
  22. project: MDSuiteDB = zn.deps(MDSuiteDB)
  23. analysis = zn.metrics()
  24. data_range = zn.params(100)
  25. correlation_time = zn.params(1)
  26. def run(self):
  27. project = mds.Project(self.project.project_path)
  28. data = project.run.EinsteinDiffusionCoefficients(
  29. plot=False,
  30. data_range=self.data_range,
  31. correlation_time=self.correlation_time,
  32. )
  33. self.analysis = {
  34. "[Na] diffusion_coefficient * 10^9": data["NaCl_example_data"]["Na"][
  35. "diffusion_coefficient"
  36. ]
  37. * 10 ** 9,
  38. "[Na] uncertainty * 10^9": data["NaCl_example_data"]["Na"]["uncertainty"]
  39. * 10 ** 9,
  40. "[Cl] diffusion_coefficient * 10^9": data["NaCl_example_data"]["Cl"][
  41. "diffusion_coefficient"
  42. ]
  43. * 10 ** 9,
  44. "[Cl] uncertainty * 10^9": data["NaCl_example_data"]["Cl"]["uncertainty"]
  45. * 10 ** 9,
  46. }
  47. class RadialDistributionFunctionNode(Node):
  48. project: MDSuiteDB = zn.deps(MDSuiteDB)
  49. plot = dvc.outs_no_cache("rdf.png")
  50. rdf: pd.DataFrame = zn.plots(x="r", x_label="distance r", y_label="g(r)")
  51. def run(self):
  52. project = mds.Project(self.project.project_path)
  53. data = project.run.RadialDistributionFunction(
  54. plot=False,
  55. )
  56. fig, ax = plt.subplots()
  57. ax.plot(
  58. data["NaCl_example_data"]["Na_Cl"]["x"],
  59. data["NaCl_example_data"]["Na_Cl"]["y"],
  60. )
  61. fig.savefig(self.plot)
  62. self.rdf = pd.DataFrame({"g(r)": data["NaCl_example_data"]["Na_Cl"]["y"]})
  63. self.rdf.index = data["NaCl_example_data"]["Na_Cl"]["x"]
  64. self.rdf.index.name = "r"
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...