Skip to content

Commit

Permalink
Symprec parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
AndresOrtegaGuerrero committed Sep 22, 2024
1 parent 5ce3116 commit 2fe138b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/aiidalab_qe_vibroscopy/app/workchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_builder(codes, structure, parameters):
"supercell_matrix": supercell_matrix,
},
"dielectric": {"scf": deepcopy(parameters["advanced"])},
"symmetry:": {"symprec": parameters["vibronic"]["symmetry_symprec"]},
"symmetry": {"symprec": parameters["vibronic"]["symmetry_symprec"]},
}

# Update code information with resource configurations
Expand Down
17 changes: 12 additions & 5 deletions src/aiidalab_qe_vibroscopy/workflows/vibroworkchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,12 @@ def get_builder_from_protocol(
)
else:
builder.phonopy_bands_dict = Dict(dict=PhononProperty.BANDS.value)
builder.phonopy_bands_dict["symmetry_tolerance"] = overrides[
"symmetry"
]["symprec"]
builder.phonopy_pdos_dict = Dict(
dict={
"symmetry_tolerance": overrides["symmetry"]["symprec"],
"pdos": "auto",
"mesh": 150, # 1000 is too heavy
"write_mesh": False,
Expand All @@ -491,6 +495,7 @@ def get_builder_from_protocol(

builder.phonopy_thermo_dict = Dict(
dict={
"symmetry_tolerance": overrides["symmetry"]["symprec"],
"tprop": True,
"mesh": 200, # 1000 is too heavy
"write_mesh": False,
Expand Down Expand Up @@ -552,9 +557,8 @@ def get_builder_from_protocol(
builder_phonon.phonopy.settings = Dict(dict={"keep_phonopy_yaml": True})

# MBO: I do not understand why I have to do this, but it works
symmetry = builder_phonon.pop("symmetry")
builder.phonon = builder_phonon
builder.phonon.symmetry = symmetry
builder.phonon.symmetry = overrides["symmetry"]

# Adding the bands and pdos inputs.
if structure.pbc != (True, True, True):
Expand Down Expand Up @@ -624,8 +628,12 @@ def get_builder_from_protocol(
)
else:
builder.phonopy_bands_dict = Dict(dict=PhononProperty.BANDS.value)
builder.phonopy_bands_dict["symmetry_tolerance"] = overrides[
"symmetry"
]["symprec"]
builder.phonopy_pdos_dict = Dict(
dict={
"symmetry_tolerance": overrides["symmetry"]["symprec"],
"pdos": "auto",
"mesh": 150, # 1000 is too heavy
"write_mesh": False,
Expand All @@ -634,6 +642,7 @@ def get_builder_from_protocol(

builder.phonopy_thermo_dict = Dict(
dict={
"symmetry_tolerance": overrides["symmetry"]["symprec"],
"tprop": True,
"mesh": 200, # 1000 is too heavy
"write_mesh": False,
Expand All @@ -649,12 +658,10 @@ def get_builder_from_protocol(
**kwargs,
)

# MBO: I do not understand why I have to do this, but it works. maybe related with excludes.
symmetry = builder_dielectric.pop("symmetry")
if structure.pbc != (True, True, True):
builder_dielectric.pop("kpoints_parallel_distance", None)
builder.dielectric = builder_dielectric
builder.dielectric.symmetry = symmetry
builder.dielectric.symmetry = overrides["symmetry"]
builder.dielectric.property = dielectric_property

# Deleting the not needed parts of the builder:
Expand Down
24 changes: 19 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,15 @@ def _fixture_code(entry_point_name):
def generate_structure_data():
"""generate a `StructureData` object."""

def _generate_structure_data(name="silicon", pbc=(True, True, True)):
def _generate_structure_data(name="silicon"):
if name == "silicon":
structure = orm.StructureData(
cell=[
[3.84737, 0.0, 0.0],
[1.923685, 3.331920, 0.0],
[1.923685, 1.110640, 3.141364],
]
],
pbc=(True, True, True),
)
structure.append_atom(position=(0.0, 0.0, 0.0), symbols="Si")
structure.append_atom(position=(1.923685, 1.110640, 0.785341), symbols="Si")
Expand All @@ -65,7 +66,8 @@ def _generate_structure_data(name="silicon", pbc=(True, True, True)):
[4.18, 0.0, 0.0],
[0.0, 4.18, 0.0],
[0.0, 0.0, 2.66],
]
],
pbc=(True, True, True),
)
structure.append_atom(position=(0.0, 0.0, 0.0), symbols="Si")
structure.append_atom(position=(2.09, 2.09, 1.33), symbols="Si")
Expand All @@ -88,11 +90,23 @@ def _generate_structure_data(name="silicon", pbc=(True, True, True)):
["O", "O", (0, 0, 10.201532881212)],
["Li", "Li", (0, 0, 6.9018028772754)],
]
structure = orm.StructureData(cell=cell)
structure = orm.StructureData(cell=cell, pbc=(True, True, True))

for site in sites:
structure.append_atom(position=site[2], symbols=site[0], name=site[1])
structure.pbc = pbc

elif name == "2D-xy-arsenic":
cell = [[3.61, 0, 0], [-1.80, 3.13, 0], [0, 0, 21.3]]
structure = orm.StructureData(cell=cell, pbc=(True, True, False))
structure.append_atom(
position=(1.804, 1.042, 11.352), symbols="As", name="As"
)
structure.append_atom(position=(0, 2.083, 9.960), symbols="As", name="As")

elif name == "1D-x-carbon":
cell = [[4.2, 0, 0], [0, 20, 0], [0, 0, 20]]
structure = orm.StructureData(cell=cell, pbc=(True, False, False))
structure.append_atom(position=(0, 0, 0), symbols="C", name="C")

return structure

Expand Down
28 changes: 28 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,31 @@ def test_settings():
parameters = configure_step.settings["vibronic"].get_panel_value()
assert parameters["simulation_mode"] == 1
assert parameters["supercell_selector"] == [2, 2, 2]


@pytest.mark.usefixtures("sssp")
def test_xy_settings(generate_structure_data):
"""Test the settings of the vibroscopy app."""

from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep

configure_step = ConfigureQeAppWorkChainStep()
structure = generate_structure_data("2D-xy-arsenic")
configure_step.input_structure = structure
configure_step.workchain_settings.properties["vibronic"].run.value = True
parameters = configure_step.settings["vibronic"].get_panel_value()
assert parameters["supercell_selector"] == [2, 2, 1]


@pytest.mark.usefixtures("sssp")
def test_x_settings(generate_structure_data):
"""Test the settings of the vibroscopy app."""

from aiidalab_qe.app.configuration import ConfigureQeAppWorkChainStep

configure_step = ConfigureQeAppWorkChainStep()
structure = generate_structure_data("1D-x-carbon")
configure_step.input_structure = structure
configure_step.workchain_settings.properties["vibronic"].run.value = True
parameters = configure_step.settings["vibronic"].get_panel_value()
assert parameters["supercell_selector"] == [2, 1, 1]
5 changes: 3 additions & 2 deletions tests/test_submit/test_create_builder_default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,19 @@ codes:
nodes: 1
ntasks_per_node: 1
pw:
cpus: 10
cpus: 8
cpus_per_task: 1
max_wallclock_seconds: 43200
nodes: 1
ntasks_per_node: 10
ntasks_per_node: 8
parallelization: {}
vibronic:
simulation_mode: 1
supercell_selector:
- 2
- 2
- 2
symmetry_symprec: 1.0e-05
workchain:
electronic_type: metal
properties:
Expand Down

0 comments on commit 2fe138b

Please sign in to comment.