|
12 | 12 | build_fdmnes_inputfile, |
13 | 13 | build_orca_input_file, |
14 | 14 | build_qe_inputfile, |
| 15 | + fdmnes_molecule_to_crystal, |
15 | 16 | ) |
16 | 17 | from .models.models import ( |
17 | 18 | CrystalStructure, |
@@ -176,6 +177,11 @@ def submit_orca_simulation( |
176 | 177 | ) -> OrcaSimulation: |
177 | 178 | person = get_or_create_person(session, user_id) |
178 | 179 |
|
| 180 | + if not person.accepted_orca_eula: |
| 181 | + raise HTTPException( |
| 182 | + status_code=403, detail="User has not accepted the Orca EULA" |
| 183 | + ) |
| 184 | + |
179 | 185 | smodel = { |
180 | 186 | "person_id": person.id, |
181 | 187 | "simulation_type_id": 1, |
@@ -234,19 +240,28 @@ def get_fdmnes_simulation(session, id, user_id) -> FdmnesSimulation: |
234 | 240 | def get_orca_jobfile(session, id, user_id): |
235 | 241 | orca_simulation = get_orca_simulation(session, id, user_id) |
236 | 242 | structure = get_molecular_structure( |
237 | | - session, orca_simulation.crystal_structure_id, user_id |
| 243 | + session, orca_simulation.molecular_structure_id, user_id |
238 | 244 | ) |
239 | 245 |
|
240 | 246 | return build_orca_input_file(orca_simulation, structure) |
241 | 247 |
|
242 | 248 |
|
243 | 249 | def get_fdmnes_jobfile(session, id, user_id): |
244 | 250 | fdmnes_simulation = get_fdmnes_simulation(session, id, user_id) |
245 | | - structure = get_crystal_structure( |
246 | | - session, fdmnes_simulation.crystal_structure_id, user_id |
247 | | - ) |
248 | 251 |
|
249 | | - return build_fdmnes_inputfile(fdmnes_simulation, structure) |
| 252 | + if fdmnes_simulation.crystal_structure_id is not None: |
| 253 | + structure = get_crystal_structure( |
| 254 | + session, fdmnes_simulation.crystal_structure_id, user_id |
| 255 | + ) |
| 256 | + crystalIsMolecule = False |
| 257 | + else: |
| 258 | + molecule = get_molecular_structure( |
| 259 | + session, fdmnes_simulation.molecular_structure_id, user_id |
| 260 | + ) |
| 261 | + structure = fdmnes_molecule_to_crystal(molecule) |
| 262 | + crystalIsMolecule = True |
| 263 | + |
| 264 | + return build_fdmnes_inputfile(fdmnes_simulation, structure, crystalIsMolecule) |
250 | 265 |
|
251 | 266 |
|
252 | 267 | def get_fdmnes_output(session, id, user_id): |
@@ -341,6 +356,18 @@ def get_orca_xas(session, id, user_id): |
341 | 356 | return output |
342 | 357 |
|
343 | 358 |
|
| 359 | +def accept_orca_eula(session, user_id): |
| 360 | + person = get_user(session, user_id) |
| 361 | + |
| 362 | + person.accepted_orca_eula = True |
| 363 | + |
| 364 | + session.add(person) |
| 365 | + session.commit() |
| 366 | + session.refresh(person) |
| 367 | + |
| 368 | + return person |
| 369 | + |
| 370 | + |
344 | 371 | def get_user(session, user_id): |
345 | 372 | statement = select(Person).where(Person.identifier == user_id) |
346 | 373 | person = session.exec(statement).first() |
|
0 commit comments