zulissimeta commited on
Commit
57ae296
·
1 Parent(s): 03ec9ab

add logic for catalysis demo

Browse files
Files changed (1) hide show
  1. simulation_scripts.py +28 -8
simulation_scripts.py CHANGED
@@ -42,6 +42,24 @@ MAX_ATOMS = os.environ.get("MAX_ATOMS", 2000)
42
  INFERENCE_ENDPOINT_URL = os.environ["INFERENCE_ENDPOINT_URL"]
43
 
44
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  def validate_ase_atoms_and_login(
46
  structure_file: dict | str,
47
  login_button_value: str,
@@ -85,9 +103,17 @@ def validate_ase_atoms_and_login(
85
  gr.Button(interactive=False),
86
  f"Structure file contains {len(atoms)}, which is more than {MAX_ATOMS} atoms. Please use a smaller structure for this demo, or run this on a local machine!",
87
  )
88
- elif (hash_file(structure_file) not in EXAMPLE_FILE_HASHES) and (
89
- (oauth_token is None) or not validate_uma_access(oauth_token=oauth_token)
 
 
90
  ):
 
 
 
 
 
 
91
  return (
92
  gr.Button(interactive=False),
93
  gr.Button(interactive=False),
@@ -97,12 +123,6 @@ To use your own structures, you need access to the [gated UMA model repository](
97
  Note that uploaded structure will be stored by this demo to analyze model usage and identify domains where model accuracy can be improved.
98
  """,
99
  )
100
- else:
101
- return (
102
- gr.Button(interactive=True),
103
- gr.Button(interactive=True),
104
- "",
105
- )
106
 
107
 
108
  def load_check_ase_atoms(structure_file):
 
42
  INFERENCE_ENDPOINT_URL = os.environ["INFERENCE_ENDPOINT_URL"]
43
 
44
 
45
+ def check_catalysis_example(atoms):
46
+ # Simple check for the catalysis tutorial structures (extremely simple C/O/H structures on Ni)
47
+ element_counts = {}
48
+ for symbol in atoms.get_chemical_symbols():
49
+ if symbol not in element_counts:
50
+ element_counts[symbol] = 0
51
+ element_counts[symbol] += 1
52
+
53
+ if (
54
+ set(element_counts.keys()).issubset(set(["Ni", "C", "O", "H"]))
55
+ and (element_counts.get("C", 0) <= 1)
56
+ and (element_counts.get("O", 0) <= 1)
57
+ ):
58
+ return True
59
+ else:
60
+ return False
61
+
62
+
63
  def validate_ase_atoms_and_login(
64
  structure_file: dict | str,
65
  login_button_value: str,
 
103
  gr.Button(interactive=False),
104
  f"Structure file contains {len(atoms)}, which is more than {MAX_ATOMS} atoms. Please use a smaller structure for this demo, or run this on a local machine!",
105
  )
106
+ elif (
107
+ check_catalysis_example(atoms)
108
+ or (hash_file(structure_file) in EXAMPLE_FILE_HASHES)
109
+ or ((oauth_token is not None) or validate_uma_access(oauth_token=oauth_token))
110
  ):
111
+ return (
112
+ gr.Button(interactive=True),
113
+ gr.Button(interactive=True),
114
+ "",
115
+ )
116
+ else:
117
  return (
118
  gr.Button(interactive=False),
119
  gr.Button(interactive=False),
 
123
  Note that uploaded structure will be stored by this demo to analyze model usage and identify domains where model accuracy can be improved.
124
  """,
125
  )
 
 
 
 
 
 
126
 
127
 
128
  def load_check_ase_atoms(structure_file):