lasp-ase 0.0.1__py3-none-any.whl

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.
lasp_ase/__init__.py ADDED
File without changes
lasp_ase/lasp.py ADDED
@@ -0,0 +1,75 @@
1
+ """
2
+ This module defines a FileIOCalculator for LASP
3
+ Only support define the calculator and call the binary, input generation
4
+ and output analysis don't support yet.
5
+ """
6
+
7
+ import os
8
+ import numpy as np
9
+ from ase.calculators.calculator import FileIOCalculator
10
+
11
+
12
+ class Lasp(FileIOCalculator):
13
+ if 'ASE_LASP_COMMAND' in os.environ:
14
+ command = os.environ['ASE_LASP_COMMAND']
15
+ else:
16
+ command = 'mpirun -np 2 lasp'
17
+
18
+ implemented_properties = ['energy', 'forces']
19
+
20
+ def __init__(self, restart=None,
21
+ ignore_bad_restart_file=FileIOCalculator._deprecated,
22
+ label='lasp', atoms=None, **kwargs):
23
+
24
+ self.lines = None
25
+ self.atoms = None
26
+ self.atoms_input = None
27
+ self.do_forces = False
28
+ self.outfilename = 'lasp.out'
29
+
30
+ FileIOCalculator.__init__(self, restart, ignore_bad_restart_file,
31
+ label, atoms,self.command,
32
+ **kwargs)
33
+
34
+ def write_input(self, atoms, properties=None, system_changes=None):
35
+ from ase.io import write
36
+ if properties is not None:
37
+ if 'forces' in properties or 'stress' in properties:
38
+ self.do_forces = True
39
+ FileIOCalculator.write_input(
40
+ self, atoms, properties, system_changes)
41
+ write(os.path.join(self.directory, 'input.arc'), atoms,
42
+ parallel=False)
43
+ # self.atoms is none until results are read out,
44
+ # then it is set to the ones at writing input
45
+ self.atoms_input = atoms
46
+ self.atoms = None
47
+
48
+ def read_results(self):
49
+
50
+ with open(os.path.join(self.directory, 'allfor.arc'), 'r') as fd:
51
+ self.lines = fd.readlines()
52
+
53
+ self.atoms = self.atoms_input
54
+ energy = float(self.lines[0].split()[3])
55
+ self.results['energy'] = energy
56
+ if self.do_forces:
57
+ forces = self.read_forces()
58
+ self.results['forces'] = forces
59
+
60
+ def read_forces(self):
61
+
62
+ gradients = []
63
+ for i in range(2,len(self.atoms)+2): #self.lines)-1):
64
+ tmp = []
65
+ for j in range(0,3):
66
+ tmp.append(float(self.lines[i].split()[j]))
67
+ gradients.append(tmp)
68
+
69
+ return np.array(gradients)
70
+
71
+
72
+
73
+
74
+
75
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 PJ
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,28 @@
1
+ Metadata-Version: 2.2
2
+ Name: lasp_ase
3
+ Version: 0.0.1
4
+ Summary: ASE calculator for LASP
5
+ Home-page: https://github.com/renpj/lasp_ase
6
+ Author:
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Operating System :: OS Independent
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: ase
13
+ Dynamic: classifier
14
+ Dynamic: description
15
+ Dynamic: description-content-type
16
+ Dynamic: home-page
17
+ Dynamic: requires-dist
18
+ Dynamic: summary
19
+
20
+ # lasp_ase
21
+ ASE calculator for LASP (http://www.lasphub.com)
22
+
23
+
24
+ ## run example
25
+ ```bash
26
+ cd example
27
+ bash run_ase.sh
28
+ ```
@@ -0,0 +1,7 @@
1
+ lasp_ase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ lasp_ase/lasp.py,sha256=WQnoWo4V1F43h6GEl5LBVhnCyX3ctg1GJbHLkapoV-s,2291
3
+ lasp_ase-0.0.1.dist-info/LICENSE,sha256=gy1aaulB2GMZ2ku-VLu2shfwLBQk2Gd2nFTQ0nTP5L4,1059
4
+ lasp_ase-0.0.1.dist-info/METADATA,sha256=RIO_bdmX227Mq9xfN4BlxfXNf5MhZ5r1sEE-mox_a0A,617
5
+ lasp_ase-0.0.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
6
+ lasp_ase-0.0.1.dist-info/top_level.txt,sha256=RXNI5-63yJ1iIyiWglgwjBpQv-E8L4gWyYqa9Tba-VQ,9
7
+ lasp_ase-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.8.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ lasp_ase