1
+ """Module for pyiron job based on the RRmodel module"""
1
2
from pyiron_base .utils .error import ImportAlarm
2
3
from pyiron_base .jobs .job .template import TemplateJob
3
- import h5py
4
- import numpy as np
5
4
from pyiron_base .jobs .job .jobtype import JobType
5
+ import h5io
6
6
try :
7
7
from RobinRollandModel .main import RRModel
8
8
from RobinRollandModel .datautils import TipGenerator
9
9
except ImportError :
10
10
import_alarm = ImportAlarm ("Unable to import RobinRollandmodel" )
11
11
12
+
12
13
class RRModelAPTjob (TemplateJob ):
14
+ """pyiron job class for RRModelAPT simulation"""
15
+
13
16
def __init__ (self , project , job_name ):
14
17
super ().__init__ (project , job_name )
15
- self .input [' e_field' ] = 4
16
- self .input [' tip_height' ] = 80
17
- self .input [' tip_radius' ] = 20
18
- self .input [' z_height' ] = 50
19
- self .input [' tip_shank_angle' ] = None
20
- self .input [' basic_structure' ] = None
21
- self .input [' num_atoms' ] = 5 # number of atoms to evaporate
18
+ self .input [" e_field" ] = 4
19
+ self .input [" tip_height" ] = 80
20
+ self .input [" tip_radius" ] = 20
21
+ self .input [" z_height" ] = 50
22
+ self .input [" tip_shank_angle" ] = None
23
+ self .input [" basic_structure" ] = None
24
+ self .input [" num_atoms" ] = 5 # number of atoms to evaporate
22
25
23
26
def create_input_structure (self ):
24
- tip_generator = TipGenerator (structure = self .input .basic_structure ,
25
- h = self .input .tip_height ,
26
- ah = self .input .tip_radius ,
27
- alpha = self .input .tip_shank_angle ,
28
- zheight = self .input .z_height )
29
- self .input ['structure' ] = tip_generator .create_tip_pyiron (self .project ) # structure of the tip
27
+ """Creates the tip structure"""
28
+ tip_generator = TipGenerator (
29
+ structure = self .input .basic_structure ,
30
+ h = self .input .tip_height ,
31
+ ah = self .input .tip_radius ,
32
+ alpha = self .input .tip_shank_angle ,
33
+ zheight = self .input .z_height ,
34
+ )
35
+ self .input ["structure" ] = tip_generator .create_tip_pyiron (
36
+ self .project
37
+ ) # structure of the tip
30
38
return tip_generator
31
39
32
- def run_static (self ,** kwargs ):
40
+ def run_static (self , ** kwargs ):
33
41
tip_generator = self .create_input_structure ()
34
- #self.input['structure']= tip_generator.create_tip_pyiron(self.project)
35
- job = RRModel (tip_generator = tip_generator ,
36
- structure = self .input .structure ,
37
- e_field = self .input .e_field )
38
- job .run_evaporation (num_atoms = self .input .num_atoms ,path = self .working_directory ,** kwargs )
42
+ # self.input['structure']= tip_generator.create_tip_pyiron(self.project)
43
+ job = RRModel (
44
+ tip_generator = tip_generator ,
45
+ structure = self .input .structure ,
46
+ e_field = self .input .e_field ,
47
+ )
48
+ job .run_evaporation (
49
+ num_atoms = self .input .num_atoms , path = self .working_directory , ** kwargs
50
+ )
39
51
self .collect_output ()
40
-
41
- self .status .finished = True
42
52
53
+ self .status .finished = True
43
54
44
55
def collect_output (self , path = None ):
45
56
if path is None :
46
57
path = self .working_directory
47
-
48
- fin_evapos = {}
49
- with h5py .File (f'{ path } /fin_evapos.h5' ,'r' ) as output :
50
- for varname in output .keys ():
51
- atom = float (str (varname ).replace ('step=' ,'' ))
52
- fin_evapos [atom ] = np .asarray (output [varname ])
53
- self .output ['evaporation_trajectories' ] = fin_evapos
54
-
55
- tip_pos = {}
56
- with h5py .File (f'{ path } /tip_pos.h5' ,'r' ) as output :
57
- for varname in output .keys ():
58
- atom = float (str (varname ).replace ('step=' ,'' ))
59
- tip_pos [atom ] = np .asarray (output [varname ])
60
- self .output ['tip_structures' ] = tip_pos
61
-
62
- tip_pos_charge = {}
63
- with h5py .File (f'{ path } /tip_pos_charge.h5' ,'r' ) as output :
64
- for varname in output .keys ():
65
- atom = float (str (varname ).replace ('step=' ,'' ))
66
- tip_pos_charge [atom ] = np .asarray (output [varname ])
67
- self .output ['equilibrium_charges' ] = tip_pos_charge
68
-
69
- tip_surf_ind = {}
70
- with h5py .File (f'{ path } /tip_surf_ind.h5' ,'r' ) as output :
71
- for varname in output .keys ():
72
- atom = float (str (varname ).replace ('step=' ,'' ))
73
- tip_surf_ind [atom ] = np .asarray (output [varname ])
74
- self .output ['surface_indices' ] = tip_surf_ind
75
- #self.to_hdf() #is a duplication of output to job hdf5 file
76
58
77
- JobType .register (RRModelAPTjob )
59
+ fin_evapos = h5io .read_hdf5 (f'{ path } /fin_evapos.h5' )
60
+ tip_pos = h5io .read_hdf5 (f'{ path } /tip_pos.h5' )
61
+ tip_pos_charge = h5io .read_hdf5 (f'{ path } /tip_pos_charge.h5' )
62
+ tip_surf_ind = h5io .read_hdf5 (f'{ path } /tip_surf_ind.h5' )
63
+ self .output ["evaporation_trajectories" ] = fin_evapos
64
+ self .output ["tip_structures" ] = tip_pos
65
+ self .output ["equilibrium_charges" ] = tip_pos_charge
66
+ self .output ["surface_indices" ] = tip_surf_ind
67
+ self .to_hdf () #is a duplication of output to job hdf5 file
68
+
69
+
70
+ JobType .register (RRModelAPTjob )
0 commit comments