Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometry Analysis and Coverage Dependence Part 1 #46

Open
wants to merge 183 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
eacd2ed
remove constraints in geom copies in structure comparison
mjohnson541 Dec 20, 2023
e7d2d84
allow acat surrogate_metal specification
mjohnson541 Dec 20, 2023
94c2a1c
make get_bond_lengths_sites use sites and site_adjacency rather than …
mjohnson541 Apr 24, 2024
f939f2d
add function for removing the slab representation and only leaving th…
mjohnson541 Apr 24, 2024
83f334b
add pluck_subgraph for grabbing a specific subgraph from an overall 2…
mjohnson541 Apr 24, 2024
18a95c3
add function for grabbing all bonds between labeled atoms
mjohnson541 Apr 24, 2024
5ee4ff5
add function for removing site information from a Molecule object
mjohnson541 Apr 24, 2024
e7d78dd
add function for reducing a Molecule object into pairs information
mjohnson541 Apr 24, 2024
d785508
add function for finding shortest path between two atoms
mjohnson541 Apr 24, 2024
de4ef7a
add function for splitting up adsorbed structures
mjohnson541 Apr 24, 2024
9d2d7f1
add function for telling if two sites are the same
mjohnson541 Apr 24, 2024
4c186db
add in-house function for extracting the occupied sites
mjohnson541 Apr 24, 2024
29e559f
add geometricanalysis.py file
mjohnson541 Apr 24, 2024
fcce05e
add function for generating 2D representation of surface
mjohnson541 Apr 24, 2024
d30f60f
add function for generating an initial 2D representation of adsorbate
mjohnson541 Apr 24, 2024
ab62c1c
add functions for iterative distributing electrons across bonds to ge…
mjohnson541 Apr 24, 2024
efbc24a
generate a 2D representation for an arbitrary adsorbate
mjohnson541 Apr 24, 2024
e77692b
add function for generating a 2D representation of a transition state
mjohnson541 Apr 24, 2024
26d10ff
add function for tagging sites with inert atoms
mjohnson541 Apr 24, 2024
80fcbd8
add function for generating 2D representations of reactants and produ…
mjohnson541 Apr 24, 2024
e8be0b3
add function for determining what molecular configurations (usually s…
mjohnson541 Apr 24, 2024
d9a00b4
add functions for picking best adsorbate sets
mjohnson541 Apr 24, 2024
0d506ca
add function for getting template index from ase index
mjohnson541 Apr 24, 2024
a8e9815
add function for extracting bond stretch factors from data
mjohnson541 Apr 24, 2024
b1eae1b
add functions for extracting adsorbate geometries
mjohnson541 Apr 24, 2024
50139ec
add function for getting the pairs from a 2D repr of a pair optimization
mjohnson541 Apr 24, 2024
759a39a
move get_adsorbate_energies and get_vibdata to geometricanalysis
mjohnson541 Apr 24, 2024
2c5d9b4
create coveragedependence.py file
mjohnson541 Apr 24, 2024
bb6cac6
add functions for extracting and copying over pair optimizations
mjohnson541 Apr 24, 2024
9c4011d
add function that generates all pairwise optimizations between two ad…
mjohnson541 Apr 24, 2024
df73a13
add functions for getting unique site pair indices
mjohnson541 Apr 24, 2024
7b4cefa
add function for setting up pair-wise optimizations for reactions
mjohnson541 Apr 24, 2024
8a2ccfb
add functions for extracting important TS and coadsorbate information…
mjohnson541 Apr 24, 2024
01d8731
add function for efficiently generating unique coadsorbed geometries
mjohnson541 Apr 24, 2024
2aef92b
add function for adding a coadsorbate to a 3D structure
mjohnson541 Apr 24, 2024
71baf00
add function for adding a coadsorbate to a 2D repr
mjohnson541 Apr 24, 2024
968a2ab
add function for generating xyzs for coadsorbed configurations
mjohnson541 Apr 24, 2024
6849f6d
add function for telling if a generated 2D coadsorbed configuration i…
mjohnson541 Apr 24, 2024
70740fb
add function for getting the best unique optimized adsorbate structur…
mjohnson541 Apr 24, 2024
c7620f1
add initial class for running Coverage Dependence
mjohnson541 Apr 24, 2024
16754ef
adapt to changes in get_bond_lengths_sites function
mjohnson541 Apr 25, 2024
636ce4d
adjust allowed_structure_site_structures handling
mjohnson541 Sep 9, 2024
f8e603d
adapt to PySIDT change
mjohnson541 Oct 3, 2024
94d96ac
check if 2D representations are the same when finding unique adsorbates
mjohnson541 Oct 8, 2024
39e63b0
fix
mjohnson541 Oct 8, 2024
266e1f8
enable pairs calculations of TSs
mjohnson541 Oct 8, 2024
a788b0a
properly handle firework generation for pairs calculations of TSs
mjohnson541 Oct 8, 2024
de6adb4
move CoverageDependence class to main.py
mjohnson541 Oct 9, 2024
962f71a
add adsorption_info and atoms_to_skip options to split_adsorbed_struc…
mjohnson541 Oct 10, 2024
2d976cd
add imports to coveragedependence.py
mjohnson541 Oct 10, 2024
c1fca93
add decomposition functions for SIDT
mjohnson541 Oct 10, 2024
cc7f2ae
add functions for computing energies and checking stability associate…
mjohnson541 Oct 10, 2024
46ad99f
add functions for training SIDTs for covdep association energy predic…
mjohnson541 Oct 10, 2024
47e2f3f
add functions for generating relevant sets of 2D configurations
mjohnson541 Oct 10, 2024
29a4a75
add functions for computing relevant lowest energies and configuratio…
mjohnson541 Oct 10, 2024
bef8ff7
add functions for processing completed covdep QM calculations
mjohnson541 Oct 10, 2024
9687536
add function for identifying configurations to calculate in covdep
mjohnson541 Oct 10, 2024
887a299
add function for generating 3D guesses for coadsorbed Adsorbate and T…
mjohnson541 Oct 10, 2024
be67995
start with pair-wise tree and move to triad_tree when enough data
mjohnson541 Oct 11, 2024
c0549a5
normalize group occurrences for each associated isolated configuration
mjohnson541 Oct 11, 2024
a88a98f
add firework for calculating 2D configuration energies
mjohnson541 Oct 12, 2024
2edb87c
tweaks
mjohnson541 Oct 14, 2024
43a0869
tweaks
mjohnson541 Oct 14, 2024
fb8ba99
adapt
mjohnson541 Oct 14, 2024
4183474
train covdep firework
mjohnson541 Oct 14, 2024
eac52f7
select covdep calculations firework
mjohnson541 Oct 14, 2024
f8669e9
adapt CoverageDependence workflow construction
mjohnson541 Oct 14, 2024
cb34584
handle site adjacency properly
mjohnson541 Oct 14, 2024
046110c
fix admol_structure_dict extraction
mjohnson541 Oct 14, 2024
95c8e8d
fix coad path handling
mjohnson541 Oct 14, 2024
ae852b6
pass nslab
mjohnson541 Oct 14, 2024
e7bda16
fix nslab calculation
mjohnson541 Oct 14, 2024
e5246ff
tweaks
mjohnson541 Oct 14, 2024
5655a1d
fix nslab handling
mjohnson541 Oct 14, 2024
c9994cf
remove nslab as input
mjohnson541 Oct 14, 2024
a41ee68
fix site loading
mjohnson541 Oct 14, 2024
c0c0b6a
remove try excepts
mjohnson541 Oct 14, 2024
487e62a
handle missing coad indexes
mjohnson541 Oct 14, 2024
7b3f21d
fix
mjohnson541 Oct 14, 2024
a29abc4
update get_unstable_pairs to handle TSs
mjohnson541 Oct 14, 2024
8f50bdd
fixes
mjohnson541 Oct 14, 2024
e521302
improve debug
mjohnson541 Oct 14, 2024
4b5d299
handle TSs in unstable pairs
mjohnson541 Oct 14, 2024
462df0d
testing debug
mjohnson541 Oct 14, 2024
f66e328
debug 2
mjohnson541 Oct 14, 2024
62f47bf
remove debug and fix
mjohnson541 Oct 14, 2024
775e094
fix
mjohnson541 Oct 14, 2024
4eecf73
debug
mjohnson541 Oct 14, 2024
332b9e0
more debug
mjohnson541 Oct 14, 2024
051ed91
fix bugs with adding 2D coadsorbates
mjohnson541 Oct 14, 2024
b705804
debug
mjohnson541 Oct 14, 2024
5b71744
debug
mjohnson541 Oct 14, 2024
573c97e
avoid issues with adjlists in pairs
mjohnson541 Oct 14, 2024
efe7285
fix
mjohnson541 Oct 14, 2024
64b5f71
fix
mjohnson541 Oct 14, 2024
1e51a10
add nslab in
mjohnson541 Oct 14, 2024
f70eca4
fixes
mjohnson541 Oct 14, 2024
33179a5
fixes
mjohnson541 Oct 14, 2024
174f7b8
fix
mjohnson541 Oct 14, 2024
f46f3ee
fix
mjohnson541 Oct 14, 2024
4a7173b
fix
mjohnson541 Oct 14, 2024
2510a24
fix
mjohnson541 Oct 14, 2024
183e77b
fix
mjohnson541 Oct 14, 2024
1206692
fixes
mjohnson541 Oct 14, 2024
c9b6d57
fixes
mjohnson541 Oct 14, 2024
4c99f16
tweaks
mjohnson541 Oct 14, 2024
db7d7e9
handling
mjohnson541 Oct 14, 2024
9b0b9fb
fix
mjohnson541 Oct 14, 2024
f094b84
tweaks
mjohnson541 Oct 14, 2024
2849a19
fix
mjohnson541 Oct 14, 2024
e727023
import Group objects
mjohnson541 Oct 14, 2024
563a0fe
fix
mjohnson541 Oct 14, 2024
3f9e33f
add split_triad function
mjohnson541 Oct 14, 2024
024f187
add max_iters
mjohnson541 Oct 14, 2024
4ece0e9
fix
mjohnson541 Oct 14, 2024
9943c83
fix
mjohnson541 Oct 14, 2024
4b79c9e
tweaks
mjohnson541 Oct 14, 2024
2ab87e2
collect calculation directories
mjohnson541 Oct 14, 2024
c7e1760
fix
mjohnson541 Oct 14, 2024
1612289
avoid need for node_uncertainties
mjohnson541 Oct 14, 2024
f54c271
extract configs of concern properly
mjohnson541 Oct 14, 2024
6b518b2
load correct files
mjohnson541 Oct 14, 2024
7a3bd55
remove timing
mjohnson541 Oct 14, 2024
8a76f9c
debug
mjohnson541 Oct 15, 2024
59394d3
fix
mjohnson541 Oct 15, 2024
d462fbf
move debug
mjohnson541 Oct 15, 2024
3f07532
add debug
mjohnson541 Oct 15, 2024
f6d42a5
debug
mjohnson541 Oct 15, 2024
a82c0f5
tweak
mjohnson541 Oct 15, 2024
e3c5b4b
fix remove debug
mjohnson541 Oct 15, 2024
214aca2
debug
mjohnson541 Oct 15, 2024
4d68ea3
tweak
mjohnson541 Oct 15, 2024
29c5750
debug
mjohnson541 Oct 15, 2024
728994e
avoid using Molecule objects as keys
mjohnson541 Oct 15, 2024
9715d58
syntax
mjohnson541 Oct 15, 2024
2d7e872
fix
mjohnson541 Oct 15, 2024
1d496f8
fix
mjohnson541 Oct 15, 2024
86e8d13
fix and debug
mjohnson541 Oct 15, 2024
2d3019e
additional debug
mjohnson541 Oct 15, 2024
d24043f
fix bug
mjohnson541 Oct 15, 2024
dd8d809
fix
mjohnson541 Oct 15, 2024
18fa879
fix calculation selection to avoid atom sorting...
mjohnson541 Oct 15, 2024
ce4eafa
fix
mjohnson541 Oct 15, 2024
272ed6d
fix
mjohnson541 Oct 15, 2024
6d7a342
fix
mjohnson541 Oct 15, 2024
ce0952a
update objects before subgraph isomorphism search
mjohnson541 Oct 15, 2024
6121035
allow opt jobs to terminate "complete" if ignore_errors is True so th…
mjohnson541 Oct 15, 2024
8485a33
try twice
mjohnson541 Oct 15, 2024
d0950a1
fix info.json writing
mjohnson541 Oct 15, 2024
ec3835d
avoid explicitly invoking sort_atoms flag
mjohnson541 Oct 15, 2024
e34e09d
fix
mjohnson541 Oct 15, 2024
dfa71ee
remove updating functions
mjohnson541 Oct 15, 2024
4e08ec2
tweak
mjohnson541 Oct 15, 2024
d03ba22
simplify
mjohnson541 Oct 15, 2024
fcbefe4
stuff
mjohnson541 Oct 15, 2024
0b9cfa5
fixes
mjohnson541 Oct 15, 2024
efea275
optimize pair groups first
mjohnson541 Oct 15, 2024
0692231
add debug asserts
mjohnson541 Oct 15, 2024
f5a8aa8
fix bug
mjohnson541 Oct 15, 2024
088e3e6
handle when geometry is available but vib file is not present
mjohnson541 Oct 18, 2024
c659a3d
handle failure in vibration calculations for TS
mjohnson541 Oct 18, 2024
38f6f27
tweak build
mjohnson541 Nov 1, 2024
a606f2f
adjust pyyaml version
mjohnson541 Nov 1, 2024
95409b0
tweak
mjohnson541 Nov 1, 2024
e100a5a
select adsorbate by lowest energy including ZPE
mjohnson541 Nov 2, 2024
5da107c
skip if no atoms
mjohnson541 Nov 21, 2024
3cae32d
clean up
mjohnson541 Nov 21, 2024
50f3fc4
clean up
mjohnson541 Nov 21, 2024
b55cda6
clean up
mjohnson541 Nov 21, 2024
9c5a6af
clean up
mjohnson541 Nov 21, 2024
8b10139
clean up
mjohnson541 Nov 21, 2024
77ba01d
fix get_configs_for_calculation
mjohnson541 Jan 6, 2025
8f49a91
read predicted lowest Ncoad energies back from file for use when sele…
mjohnson541 Jan 6, 2025
87a19c9
add new helper functions for decompositions
mjohnson541 Jan 6, 2025
549319f
partially deconstruct the pair-wise decomposition
mjohnson541 Jan 6, 2025
2f0681f
comment on now unused CoverageDependenceRegressor
mjohnson541 Jan 6, 2025
d9366fe
update SIDT regression function to use only the pair-wise decomposition
mjohnson541 Jan 6, 2025
c777e38
adapt SIDT regression training call in tasks.py
mjohnson541 Jan 6, 2025
e54bf27
loosen the site bond cutoff for "ontop" sites
mjohnson541 Jan 8, 2025
ec55b81
enable split_adsorbed_structures to return atom_mapping
mjohnson541 Jan 8, 2025
28ddf0b
enable fix_bond_orders to handle vdW bonds
mjohnson541 Jan 8, 2025
c5b8abb
enable vdW bond handling flags across geometric analysis functions th…
mjohnson541 Jan 8, 2025
b7fdc1b
handle vdW in coverage dependence 2D extraction functions
mjohnson541 Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: 3.8
miniforge-variant: Mambaforge
miniforge-variant: Miniforge3
channels: defaults,mjohnson541,conda-forge
channel-priority: true
activate-environment: pynta_env
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ dependencies:
- coverage
- liblapack !=3.9.0
- pysidt
- ruamel.yaml < 0.18
2,253 changes: 2,253 additions & 0 deletions pynta/coveragedependence.py

Large diffs are not rendered by default.

1,165 changes: 1,165 additions & 0 deletions pynta/geometricanalysis.py

Large diffs are not rendered by default.

210 changes: 207 additions & 3 deletions pynta/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from pynta.tasks import *
from pynta.mol import get_adsorbate, generate_unique_site_additions, generate_adsorbate_guesses, get_name,generate_unique_placements
from pynta.coveragedependence import *
from molecule.molecule import Molecule
import ase.build
from ase.io import read, write
Expand Down Expand Up @@ -41,7 +42,8 @@ def __init__(self,path,rxns_file,surface_type,metal,label,launchpad_path=None,fw
irc_mode="fixed", #choose irc mode: 'skip', 'relaxed', 'fixed'
lattice_opt_software_kwargs={'kpts': (25,25,25), 'ecutwfc': 70, 'degauss':0.02, 'mixing_mode': 'plain'},
reset_launchpad=False,queue_adapter_path=None,num_jobs=25,max_num_hfsp_opts=None,#max_num_hfsp_opts is mostly for fast testing
Eharmtol=3.0,Eharmfiltertol=30.0,Ntsmin=5,frozen_layers=2,fmaxopt=0.05,fmaxirc=0.1,fmaxopthard=0.05,c=None):
Eharmtol=3.0,Eharmfiltertol=30.0,Ntsmin=5,frozen_layers=2,fmaxopt=0.05,fmaxirc=0.1,fmaxopthard=0.05,c=None,
surrogate_metal=None):

self.surface_type = surface_type
if launchpad_path:
Expand All @@ -64,6 +66,10 @@ def __init__(self,path,rxns_file,surface_type,metal,label,launchpad_path=None,fw
self.facet = metal + surface_type
self.fws = []
self.metal = metal
if surrogate_metal is None:
self.surrogate_metal = metal
else:
self.surrogate_metal = surrogate_metal
self.adsorbate_fw_dict = dict()
self.software_kwargs = software_kwargs
self.irc_mode = irc_mode
Expand Down Expand Up @@ -171,7 +177,7 @@ def analyze_slab(self):
full_slab = self.slab
cas = SlabAdsorptionSites(full_slab, self.surface_type,allow_6fold=False,composition_effect=False,
label_sites=True,
surrogate_metal=self.metal)
surrogate_metal=self.surrogate_metal)

self.cas = cas

Expand Down Expand Up @@ -496,7 +502,7 @@ def setup_transition_states(self,adsorbates_finished=False):
"gratom_to_molecule_atom_maps":{sm: {str(k):v for k,v in d.items()} for sm,d in self.gratom_to_molecule_atom_maps.items()},
"gratom_to_molecule_surface_atom_maps":{sm: {str(k):v for k,v in d.items()} for sm,d in self.gratom_to_molecule_surface_atom_maps.items()},
"nslab":self.nslab,"Eharmtol":self.Eharmtol,"Eharmfiltertol":self.Eharmfiltertol,"Ntsmin":self.Ntsmin,
"max_num_hfsp_opts":self.max_num_hfsp_opts})
"max_num_hfsp_opts":self.max_num_hfsp_opts, "surrogate_metal":self.surrogate_metal})
reactants = rxn["reactant_names"]
products = rxn["product_names"]
parents = []
Expand Down Expand Up @@ -572,3 +578,201 @@ def execute_from_initial_ad_guesses(self):


self.launch()

class CoverageDependence:
def __init__(self,path,metal,surface_type,repeats,pynta_run_directory,software,software_kwargs,label,sites,site_adjacency,coad_stable_sites,adsorbates=[],transition_states=dict(),coadsorbates=[],
max_dist=3.0,frozen_layers=2,fmaxopt=0.05,Ncalc_per_iter=6,TS_opt_software_kwargs=None,launchpad_path=None,
fworker_path=None,queue=False,njobs_queue=0,reset_launchpad=False,queue_adapter_path=None,
num_jobs=25,surrogate_metal=None,concern_energy_tol=None,max_iters=np.inf):
self.path = path
self.metal = metal
self.repeats = repeats
self.nslab = np.product(repeats)
self.pynta_run_directory = pynta_run_directory
self.pairs_directory = os.path.join(self.path,"pairs")
self.slab_path = os.path.join(self.pynta_run_directory,"slab.xyz")
self.adsorbates_path = os.path.join(self.pynta_run_directory,"Adsorbates")
self.coad_stable_sites = coad_stable_sites
self.software = software
self.software_kwargs = software_kwargs
self.surface_type = surface_type
self.facet = metal + surface_type
self.sites = sites
self.site_adjacency = site_adjacency
self.Ncalc_per_iter = Ncalc_per_iter
self.software_kwargs_TS = deepcopy(software_kwargs)
self.concern_energy_tol = concern_energy_tol
if TS_opt_software_kwargs:
for key,val in TS_opt_software_kwargs.items():
self.software_kwargs_TS[key] = val

if adsorbates != []:
raise ValueError("Not implemented yet")
self.adsorbates = adsorbates
self.transition_states = transition_states
self.coadsorbates = coadsorbates
self.max_dist = max_dist
self.frozen_layers = frozen_layers
self.layers = self.repeats[2]
self.freeze_ind = int((self.nslab/self.layers)*self.frozen_layers)
self.fmaxopt = fmaxopt
self.label = label
self.max_iters = max_iters

if launchpad_path:
launchpad = LaunchPad.from_file(launchpad_path)
else:
launchpad = LaunchPad()

if reset_launchpad:
launchpad.reset('', require_password=False)
self.launchpad = launchpad

self.fworker_path = fworker_path
if fworker_path:
self.fworker = FWorker.from_file(fworker_path)
else:
self.fworker = FWorker()

self.queue = queue
self.njobs_queue = njobs_queue
self.reset_launchpad = reset_launchpad
if queue:
self.qadapter = load_object_from_file(queue_adapter_path)
self.num_jobs = num_jobs

if surrogate_metal is None:
self.surrogate_metal = metal
else:
self.surrogate_metal = surrogate_metal

self.pairs_fws = []
self.fws = []

def setup_pairs_calculations(self):
tsdirs = [os.path.join(self.pynta_run_directory,t,ind) for t,ind in self.transition_states.items()]
outdirs_ad,outdirs_ts = setup_pair_opts_for_rxns(self.path,tsdirs,self.coadsorbates,self.surrogate_metal,self.surface_type,max_dist=self.max_dist)

for d in outdirs_ad:
fwopt = optimize_firework(d,
self.software,"weakopt",
opt_method="MDMin",opt_kwargs={'dt': 0.05,"trajectory": "weakopt.traj"},software_kwargs=self.software_kwargs,order=0,
run_kwargs={"fmax" : 0.5, "steps" : 30},parents=[],
constraints=["freeze up to {}".format(self.freeze_ind)],
ignore_errors=True, metal=self.metal, facet=self.surface_type, priority=3)
fwopt2 = optimize_firework(os.path.join(os.path.split(d)[0],"weakopt.xyz"),
self.software,"out",
opt_method="QuasiNewton",opt_kwargs={"trajectory": "out.traj"},software_kwargs=self.software_kwargs,order=0,
run_kwargs={"fmax" : self.fmaxopt, "steps" : 70},parents=[fwopt],
constraints=["freeze up to {}".format(self.freeze_ind)],
ignore_errors=True, metal=self.metal, facet=self.surface_type, priority=2)

fwvib = vibrations_firework(os.path.join(os.path.split(d)[0],"out.xyz"),
self.software,"vib",software_kwargs=self.software_kwargs,parents=[fwopt2],
constraints=["freeze up to "+str(self.nslab)])
self.pairs_fws.append(fwopt)
self.pairs_fws.append(fwopt2)
self.pairs_fws.append(fwvib)

for d in outdirs_ts:
fwopt = optimize_firework(d,
self.software,"out", sella=True,
opt_kwargs={"trajectory": "out.traj"},software_kwargs=self.software_kwargs_TS,
order=1,
run_kwargs={"fmax" : self.fmaxopt, "steps" : 70},parents=[],
constraints=["freeze up to {}".format(self.freeze_ind)],
ignore_errors=True, metal=self.metal, facet=self.surface_type, priority=3)

fwvib = vibrations_firework(os.path.join(os.path.split(d)[0],"out.xyz"),
self.software,"vib",software_kwargs=self.software_kwargs,parents=[fwopt],
constraints=["freeze up to "+str(self.nslab)])
self.pairs_fws.append(fwopt)
self.pairs_fws.append(fwvib)

self.fws.extend(self.pairs_fws)

def setup_active_learning_loop(self):
admol_name_path_dict = {k: os.path.join(self.pynta_run_directory,k,v,"opt.xyz") for k,v in self.transition_states.items()}
admol_name_structure_dict = dict()
ads = self.adsorbates
allowed_structure_site_structures = generate_allowed_structure_site_structures(os.path.join(self.pynta_run_directory,"Adsorbates"),self.sites,self.site_adjacency,self.nslab,max_dist=np.inf)

for ts in self.transition_states.keys():
info_path = os.path.join(self.pynta_run_directory,ts,"info.json")
with open(info_path) as f:
info = json.load(f)
mol = Molecule().from_adjacency_list(info["adjlist"])
keep_binding_vdW_bonds=False
keep_vdW_surface_bonds=False
for bd in mol.get_all_edges():
if bd.order == 0:
if bd.atom1.is_surface_site() or bd.atom2.is_surface_site():
keep_binding_vdW_bonds = True
m = mol.copy(deep=True)
b = m.get_bond(m.atoms(mol.atoms.index(bd.atom1)),m.atoms[mol.atoms.index(bd.atom2)])
m.remove_bond(b)
out = m.split()
if len(out) == 1: #vdW bond is not only thing connecting adsorbate to surface
keep_vdW_surface_bonds = True

atoms = read(admol_name_path_dict[ts])
st,_,_ = generate_TS_2D(atoms, info_path, self.metal, self.surface_type, self.sites, self.site_adjacency, self.nslab,
max_dist=np.inf, allowed_structure_site_structures=allowed_structure_site_structures,
keep_binding_vdW_bonds=keep_binding_vdW_bonds,keep_vdW_surface_bonds=keep_vdW_surface_bonds)
admol_name_structure_dict[ts] = st
with open(info_path,"r") as f:
info = json.load(f)
for name in info["species_names"]+info["reverse_names"]:
if name not in ads:
ads.append(name)

for ad in ads:
p = os.path.join(self.pynta_run_directory,"Adsorbates",ad)
with open(os.path.join(p,"info.json")) as f:
info = json.load(f)

mol = Molecule().from_adjacency_list(info["adjlist"])

if mol.contains_surface_site():
keep_binding_vdW_bonds=False
keep_vdW_surface_bonds=False
for bd in mol.get_all_edges():
if bd.order == 0:
if bd.atom1.is_surface_site() or bd.atom2.is_surface_site():
keep_binding_vdW_bonds = True
m = mol.copy(deep=True)
b = m.get_bond(m.atoms(mol.atoms.index(bd.atom1)),m.atoms[mol.atoms.index(bd.atom2)])
m.remove_bond(b)
out = m.split()
if len(out) == 1: #vdW bond is not only thing connecting adsorbate to surface
keep_vdW_surface_bonds = True

ad_xyz = get_best_adsorbate_xyz(p,self.sites,self.nslab)
admol_name_path_dict[ad] = ad_xyz
atoms = read(ad_xyz)
st,_,_ = generate_adsorbate_2D(atoms, self.sites, self.site_adjacency, self.nslab, max_dist=np.inf, allowed_structure_site_structures=allowed_structure_site_structures,
keep_binding_vdW_bonds=keep_binding_vdW_bonds,keep_vdW_surface_bonds=keep_vdW_surface_bonds)
admol_name_structure_dict[ad] = st

calculation_directories = [] #identify pairs directories
for p1 in os.listdir(os.path.join(self.path,"pairs")):
for p2 in os.listdir(os.path.join(self.path,"pairs",p1)):
calculation_directories.append(os.path.join(self.path,"pairs",p1,p2))


fw = train_covdep_model_firework(self.path,admol_name_path_dict,admol_name_structure_dict,self.sites,self.site_adjacency,
self.pynta_run_directory, self.metal, self.surface_type, self.slab_path, calculation_directories, self.coadsorbates[0],
self.coad_stable_sites, self.software, self.software_kwargs, self.software_kwargs_TS, self.freeze_ind, self.fmaxopt,
parents=self.fws, max_iters=self.max_iters,
Ncalc_per_iter=self.Ncalc_per_iter,iter=0,concern_energy_tol=self.concern_energy_tol,ignore_errors=True)

self.fws.append(fw)


def execute(self,run_pairs=True,run_active_learning=False):
if run_pairs:
self.setup_pairs_calculations()
if run_active_learning:
self.setup_active_learning_loop()
wf = Workflow(self.fws, name=self.label)
self.launchpad.add_wf(wf)
Loading
Loading