Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ASE LAMMPSlib Calculator #63

Open
stefanbringuier opened this issue Dec 9, 2023 · 2 comments
Open

Adding ASE LAMMPSlib Calculator #63

stefanbringuier opened this issue Dec 9, 2023 · 2 comments

Comments

@stefanbringuier
Copy link

stefanbringuier commented Dec 9, 2023

Was wondering if you have any guidance on how might be able to proceed with using ASE LAMMPSlib. I tried to simply pass the ASE LAMMPSlib calculator object but got deepcopy errors.

Heres the source to the ASE LAMMPSlib implementation:

https://wiki.fysik.dtu.dk/ase/_modules/ase/calculators/lammpslib.html#LAMMPSlib

@jochym
Copy link
Owner

jochym commented Dec 9, 2023

I nevere tried other calculators but it should be possible. The siesta support was implemented by the otside contributor. The problem with LAMMPS is that it is an internal calculator not an external one (like vasp or abinit). You should be able to get around this problem by actually making a new objects for the deformed structures. Please post the error messages. Maybe I will be able to help.

@stefanbringuier
Copy link
Author

I think I have an approach that will work for LAMMPSlib and possibly other internal calculators, it would only enable a serial execution thought. The implementation based on

def ParCalculate(systems,calc,cleanup=True,block=True,prefix="Calc_"):

Would look something like this:

def SerialCalculate(systems,calc,prefix="Calc_"):

    if type(systems) != type([]) :
        sysl=[systems]
    else :
        sysl=systems
    basedir=os.getcwd()
    res=[]
    for n,s in enumerate(sysl):
        if isinstance(calc, LAMMPSlib):
            s.set_calculator(calc)
        else:
            s.set_calculator(deepcopy(calc))
        s.get_calculator().block=False
        place=tempfile.mkdtemp(prefix=prefix, dir=basedir)
        os.chdir(place)
        s.get_calculator().working_dir=place
        s.get_potential_energy()
        os.chdir(basedir)
        time.sleep(0.2)
        res.append([n,s])

    return [r for ns,s in enumerate(sysl) for nr,r in res if nr==ns]

It seems to work, but I've only tested on a single LAMMPSlib example, would want to try ASE internal EMT and EAM calculators.

...
systems = get_elementary_deformations(structure, n=10, d=0.1)
result = SerialCalculate(systems, calculator)
cij, _ = get_elastic_tensor(structure, systems=result)

Can create a pull request if you think it makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants