pyiron / pyiron_atomistics

pyiron_atomistics - an integrated development environment (IDE) for atomistic simulation in computational materials science.
https://pyiron-atomistics.readthedocs.io
BSD 3-Clause "New" or "Revised" License
43 stars 15 forks source link

Cannot change lattice parameter for the same sqs job #683

Closed Vishwa-adi closed 2 years ago

Vishwa-adi commented 2 years ago

Summary

from pyiron import Project
pr = Project("scratch")
n_repeat = 4
lat_const = 2.8643214219521034
concentration = 10
fraction = concentration / 100
def get_B2NiAl_structure(n_repeat, lat_const, concentration, solute_species, pr=pr):
    """
    Ni and Al simple cubic sub lattice combined to form bcc unit cell i.e B2 NiAl and 
    an option to have sqs of solute species with given concentration.

    Keyword arguments:
    n_repeat (int): Number of repeat for the super cell.
    concentration (int): Concentration of the solute species (Eg: 10 for 10%)
    solute_species (str): Element name in string (Eg: "Pt", "Pd")
    lat_const (float): Lattice constant parameter.
    pr: Project class

    Returns:
    Gives the B2 NiAl structure with an option of solute species sqs with concentration of choice. 
    """

    Ni_sc_structure = pr.create.structure.bulk("Ni", crystalstructure= "sc", a=lat_const, cubic=True)
    Al_sc_structure = pr.create.structure.bulk("Al", crystalstructure= "sc", a=lat_const, cubic=True)
    Ni_sc_structure_repeat = Ni_sc_structure.repeat(n_repeat)
    Al_sc_structure_repeat = Al_sc_structure.repeat(n_repeat)
    Al_sc_structure_repeat_shift = Al_sc_structure_repeat.copy()
    Al_sc_structure_repeat_shift.positions += lat_const / 2
    if concentration == 0:

        return Ni_sc_structure_repeat + Al_sc_structure_repeat_shift

    job_sqs = pr.create.job.SQSJob(("NiSqs", n_repeat, concentration, solute_species))
    job_sqs.structure = Ni_sc_structure_repeat
    fraction = concentration / 100
    job_sqs.input.mole_fractions = {"Ni": 1 - fraction * 2, solute_species: fraction * 2}
    job_sqs.run()

    return job_sqs.get_structure() + Al_sc_structure_repeat_shift
B2NiAl_Pt_sqs = get_B2NiAl_structure(n_repeat, lat_const=lat_const, concentration=concentration, solute_species='Pt')
# After running murnaghan job and getting the new lattice parameter
eq_lat_const = 2.939179031767603
eq_B2NiAl_Pt_sqs = get_B2NiAl_structure(n_repeat, lat_const=eq_lat_const, concentration=concentration, solute_species='Pt')

This gives a warning: /u/system/SLES12/soft/pyiron/dev/anaconda3/lib/python3.8/site-packages/pyiron_atomistics/atomistics/structure/atoms.py:2021: UserWarning: You are adding structures with different cell shapes. Taking the cell and pbc of the first structure:Cell([11.457285687808415, 11.457285687808415, 11.457285687808415]) warnings.warn(

It should make the supercell with the equilibrium lattice constant i.e 2.939179031767603 instead of the first structure (as mentioned by the warning) i.e 2.864321421952104

pyiron Version and Platform

Pyiron version 0.4.6

TYPE = Postgres HOST = NAME = pyiron USER = PASSWD = JOB_TABLE = jobs_cmmc TOP_LEVEL_DIRS = /cmmc/u VIEWERUSER = cmmc_view VIEWERPASSWD = VIEWER_TABLE = jobs_cmmc_admin RESOURCE_PATHS = /u/system/SLES12/soft/pyiron/dev/pyiron-resources-cmmc

Expected Behavior

Should provide the supercell with a new lattice parameter(i.e equilibrium lattice constant).

Actual Behavior Provides the supercell with the lattice parameter given in the beginning.

jan-janssen commented 2 years ago

pyiron saves your calculation in the database pr.job_table() so the second time you execute this function, it just reloads the job from the database. To change this behavior you can by adding the parameter delete_existing_job=True to the run() function.

Vishwa-adi commented 2 years ago

pyiron saves your calculation in the database pr.job_table() so the second time you execute this function, it just reloads the job from the database. To change this behavior you can by adding the parameter delete_existing_job=True to the run() function.

I would like to have the same structure for future calculations. By using delete_existing_job=True, it would give me a new structure.

jan-janssen commented 2 years ago

If you only want to change the lattice constant, but not redo the SQS calculation, you can also use the set_cell() function of the atomistic structure.

Vishwa-adi commented 2 years ago

If you only want to change the lattice constant, but not redo the SQS calculation, you can also use the set_cell() function of the atomistic structure.

The set_cell() function changes the cell size. Even if I use scale_atoms=True, the distance between the adjacent atoms are same as used in the beginning.

B2NiAl_Pt_sqs.set_cell([eq_lat_const*n_repeat, eq_lat_const*n_repeat, eq_lat_const*n_repeat], scale_atoms=True)
B2NiAl_Pt_sqs.get_distance(B2NiAl_Pt_sqs.positions[0], B2NiAl_Pt_sqs.positions[1])
jan-janssen commented 2 years ago

The cell should be 3x3 so I would use:

B2NiAl_Pt_sqs.set_cell([[eq_lat_const*n_repeat, 0, 0], [0, eq_lat_const*n_repeat, 0], [0,0, eq_lat_const*n_repeat]], scale_atoms=True)
B2NiAl_Pt_sqs.get_distance(B2NiAl_Pt_sqs.positions[0], B2NiAl_Pt_sqs.positions[1])
Vishwa-adi commented 2 years ago

The cell should be 3x3 so I would use:

B2NiAl_Pt_sqs.set_cell([[eq_lat_const*n_repeat, 0, 0], [0, eq_lat_const*n_repeat, 0], [0,0, eq_lat_const*n_repeat]], scale_atoms=True)
B2NiAl_Pt_sqs.get_distance(B2NiAl_Pt_sqs.positions[0], B2NiAl_Pt_sqs.positions[1])

It's still giving the lattice constant used in the beginning i.e 2.8...

pmrv commented 2 years ago

The cell should be 3x3 so I would use:

B2NiAl_Pt_sqs.set_cell([[eq_lat_const*n_repeat, 0, 0], [0, eq_lat_const*n_repeat, 0], [0,0, eq_lat_const*n_repeat]], scale_atoms=True)
B2NiAl_Pt_sqs.get_distance(B2NiAl_Pt_sqs.positions[0], B2NiAl_Pt_sqs.positions[1])

It's still giving the lattice constant used in the beginning i.e 2.8...

Make sure that you didn't call set_cell previously with scale_atoms=True by accident. I've checked just now that set_cell(scale_atoms=True) does correctly move atoms accordingly.

As a side note: I'd recommend using apply_strain(a0_new/a0_old - 1) or something similar, since it harder to get wrong.

Vishwa-adi commented 2 years ago

The cell should be 3x3 so I would use:

B2NiAl_Pt_sqs.set_cell([[eq_lat_const*n_repeat, 0, 0], [0, eq_lat_const*n_repeat, 0], [0,0, eq_lat_const*n_repeat]], scale_atoms=True)
B2NiAl_Pt_sqs.get_distance(B2NiAl_Pt_sqs.positions[0], B2NiAl_Pt_sqs.positions[1])

It's still giving the lattice constant used in the beginning i.e 2.8...

Make sure that you didn't call set_cell previously with scale_atoms=True by accident. I've checked just now that set_cell(scale_atoms=True) does correctly move atoms accordingly.

As a side note: I'd recommend using apply_strain(a0_new/a0_old - 1) or something similar, since it harder to get wrong.

apply_strain function did work perfectly. Thanks 👍