Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
35 changes: 26 additions & 9 deletions web-conexs-api/src/web_conexs_api/jobfilebuilders.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import math
import io
import re

import numpy as np
from pymatgen.core import Molecule
from pymatgen.core import Lattice, Molecule

from .models.models import (
ConductivityType,
Expand Down Expand Up @@ -86,7 +86,7 @@ def build_orca_input_file(
jobfile += " OPT "

if orca_simulation.solvent is not None:
jobfile += "CPCM(" + orca_simulation.solvent + ") "
jobfile += " CPCM(" + orca_simulation.solvent.value + ") "

jobfile += "\n"

Expand Down Expand Up @@ -158,6 +158,17 @@ def build_qe_inputfile(qe_simulation: QESimulation, structure: CrystalStructure)

n_type = len(element_set) + 1

lattice = Lattice.from_parameters(
a=structure.a,
b=structure.b,
c=structure.c,
alpha=structure.alpha,
beta=structure.beta,
gamma=structure.gamma,
)

matrix = lattice.matrix

jobfile = "&CONTROL \n"
jobfile += " calculation = 'scf'\n"
jobfile += " etot_conv_thr = 1.0000000000d-05\n"
Expand All @@ -172,12 +183,7 @@ def build_qe_inputfile(qe_simulation: QESimulation, structure: CrystalStructure)
jobfile += "/ \n\n"

jobfile += "&SYSTEM \n"
jobfile += " A = " + str(structure.a) + "\n"
jobfile += " B = " + str(structure.b) + "\n"
jobfile += " C = " + str(structure.c) + "\n"
jobfile += " cosBC = " + str(math.cos(math.radians(structure.alpha))) + "\n"
jobfile += " cosAC = " + str(math.cos(math.radians(structure.beta))) + "\n"
jobfile += " cosAB = " + str(math.cos(math.radians(structure.gamma))) + "\n"
jobfile += " ibrav = 0\n"

if qe_simulation.conductivity == ConductivityType.metallic:
occupations = "smearing"
Expand Down Expand Up @@ -251,6 +257,17 @@ def build_qe_inputfile(qe_simulation: QESimulation, structure: CrystalStructure)
jobfile += "1 1 1 0 0 0\n"
jobfile += "\n\n"

jobfile += "CELL_PARAMETERS {angstrom}\n"

print(np.array2string(matrix))
s = io.BytesIO()

np.savetxt(s, matrix)

jobfile += s.getvalue().decode()

jobfile += "\n"

return (
jobfile,
qe_simulation.absorbing_atom,
Expand Down
11 changes: 8 additions & 3 deletions web-conexs-api/tests/test_jobfile_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
MolecularStructure,
OrcaCalculation,
OrcaSimulation,
OrcaSolvent,
QEEdge,
QESimulation,
Simulation,
Expand All @@ -37,10 +38,14 @@ def test_orca_xas_filebuilder():

jobfile = build_orca_input_file(test_model, test_structure)

print(jobfile)

assert "%tddft" in jobfile

test_model.solvent = OrcaSolvent.Water

jobfile = build_orca_input_file(test_model, test_structure)

assert "CPCM(Water)" in jobfile


def test_orca_opt_filebuilder():
test_simulation = Simulation(n_cores=1)
Expand Down Expand Up @@ -89,7 +94,7 @@ def test_qe_filebuilder():
test_model, test_structure
)

assert "cosAB" in jobfile
assert "CELL_PARAMETERS" in jobfile


def test_fdmnes_crystal_filebuilder():
Expand Down