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

Add Wrapper for Atomsk Structure Creation #260

Merged
merged 15 commits into from
Sep 16, 2021
Merged

Add Wrapper for Atomsk Structure Creation #260

merged 15 commits into from
Sep 16, 2021

Conversation

pmrv
Copy link
Contributor

@pmrv pmrv commented Jun 29, 2021

It turned out to be quite simple, so I've added it here instead of a new repo. I'll brush up the docstrings a bit and add examples and tests I got from @zhuochengXIE, but the main funtionality is there.

@pmrv pmrv added the enhancement New feature or request label Jun 29, 2021
@pmrv pmrv requested a review from liamhuber June 29, 2021 08:04
@samwaseda
Copy link
Member

Nice! Is there a way to include dislocations? doesn't have to be this PR.

@coveralls
Copy link

coveralls commented Jun 29, 2021

Pull Request Test Coverage Report for Build 1237696022

  • 33 of 74 (44.59%) changed or added relevant lines in 2 files are covered.
  • 712 unchanged lines in 14 files lost coverage.
  • Overall coverage increased (+0.3%) to 68.184%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pyiron_atomistics/atomistics/structure/factory.py 3 7 42.86%
pyiron_atomistics/atomistics/structure/factories/atomsk.py 30 67 44.78%
Files with Coverage Reduction New Missed Lines %
pyiron_atomistics/atomistics/structure/analyse.py 2 98.9%
pyiron_atomistics/lammps/units.py 2 97.14%
pyiron_atomistics/atomistics/structure/has_structure.py 5 85.0%
pyiron_atomistics/atomistics/job/structurecontainer.py 6 77.22%
pyiron_atomistics/vasp/outcar.py 7 90.34%
pyiron_atomistics/atomistics/structure/neighbors.py 14 97.01%
pyiron_atomistics/vasp/interactive.py 20 42.11%
pyiron_atomistics/table/funct.py 21 59.48%
pyiron_atomistics/atomistics/structure/periodic_table.py 26 83.5%
pyiron_atomistics/atomistics/master/murnaghan.py 32 72.15%
Totals Coverage Status
Change from base Build 979303097: 0.3%
Covered Lines: 11116
Relevant Lines: 16303

💛 - Coveralls

@pmrv
Copy link
Contributor Author

pmrv commented Jun 29, 2021

Nice! Is there a way to include dislocations? doesn't have to be this PR.

Yes, it's not properly documented yet, but all atomsk flags are supported. For dislocations it would be something like

pr.create.structure.atomsk.create('fcc', 3.6, 'Cu').duplicate(5, 1, 5).dislocation('0.498*box',  '0.500*box', 'edge_add', 'Y', 'Z', 3.6, 0.217).build()

where the last two numbers are the burgers vector and poisson ratio.

@pmrv
Copy link
Contributor Author

pmrv commented Jun 29, 2021

Nice! Is there a way to include dislocations? doesn't have to be this PR.

Yes, it's not properly documented yet, but all atomsk flags are supported. For dislocations it would be something like

pr.create.structure.atomsk.create('fcc', 3.6, 'Cu').duplicate(5, 1, 5).dislocation('0.498*box',  '0.500*box', 'edge_add', 'Y', 'Z', 3.6, 0.217).build()

where the last two numbers are the burgers vector and poisson ratio.

The pattern is that all method calls on AtomskBuilder are translated like
method_call(a1, a2, ...) -> -method-call a1 a2 ...

Copy link
Member

@liamhuber liamhuber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice, I'm happy (a) this happened so quickly, and (b) that you found an easy and direct way to bind things. A few discussion points follow.

with tempfile.TemporaryDirectory() as temp_dir:
if self._structure is not None:
write(os.path.join(temp_dir, "input.exyz"), self._structure, format="extxyz")
proc = subprocess.run(["atomsk", *" ".join(self._options).split()],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to do something about the dependencies. Is it sufficient to conda-install atomsk to get this running, or would I further need to modify the command line name after installation? Is atomsk available across all architectures? How can we ImportAlarm something that's not a python package? Since we're working in atomistics and not contrib I'd like to get at least some of these answered before we merge...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Installing the conda package is enough, but there's only a linux build on conda, not sure if a windows build is possible. Using ImportAlarm is not possible since it's not a python package, but I could modify the StructureFactory to only export atomsk if it is found in the PATH.

pbc: [ True True True]
cell:
Cell([10.2, 3.6, 3.6])
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copypasta examples to unit tests folder? Will need to be excluded from the CI until we get the dependencies better sorted, but should at least be there for local machines to run.

@pmrv
Copy link
Contributor Author

pmrv commented Jun 30, 2021

Tests and docstrings are in, so this is done from my side.

@zhuochengXIE @LVC14C15 Can you have a look if this meets your needs (or is understandable at all)?

pmrv and others added 3 commits June 30, 2021 20:32
Co-authored-by: Liam Huber <liam.huber@gmail.com>
@stale
Copy link

stale bot commented Jul 15, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 15, 2021
@pmrv pmrv removed the stale label Jul 16, 2021
@jan-janssen
Copy link
Member

Nice! Is there a way to include dislocations? doesn't have to be this PR.

Did not you do this in https://github.com/eisenforschung/pyiron_mpie/blob/master/pyiron_mpie/interactive/dislocation.py already? I thought we already had an atomsk wrapper, did not we?

@pmrv
Copy link
Contributor Author

pmrv commented Jul 27, 2021

I found one place in pyiron_mpie that uses atomsk before here. The reason to add the wrapper here was not just dislocations though, but that Eric's group is using it generally a lot.

@stale
Copy link

stale bot commented Aug 10, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added stale and removed stale labels Aug 10, 2021
@pmrv
Copy link
Contributor Author

pmrv commented Aug 11, 2021

Previously I used a feature introduced here that is not yet available in the conda version. I have therefore rewritting the part calling atomsk to avoid it.

This is now done from my side, unless there's additional feature requests.

@jan-janssen
Copy link
Member

Previously I used a feature introduced here that is not yet available in the conda version. I have therefore rewritting the part calling atomsk to avoid it.

To be future proof I would suggest to update the conda package - I opened a corresponding pull request here conda-forge/atomsk-feedstock#14 - the issues is that they no longer publish tagged releases on Github https://github.com/pierrehirel/atomsk/tags so in case anybody is in contact with the developer that is maybe something we can ask them for.

@jan-janssen
Copy link
Member

I updated the conda package 0.11 and asked the developer to update their tags on Github pierrehirel/atomsk#35

from pyiron_atomistics._tests import TestWithProject
from pyiron_atomistics.atomistics.structure.factories.atomsk import AtomskFactory, AtomskError

if shutil.which("atomsk") is not None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little uncomfortable hard-coding the executable name (e.g. what if someone has multiple atomsk versions installed and renames them accordingly?) but I don't think it needs to stop the merge.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, ideally this would somehow reuse the Executable class that we have already for jobs, so you'd be able to configure your particular atomsk, but I'm drawing a blank how to actually do it right now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair!

@stale
Copy link

stale bot commented Sep 3, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Sep 3, 2021
@pmrv pmrv removed the stale label Sep 3, 2021
@pmrv
Copy link
Contributor Author

pmrv commented Sep 6, 2021

Latest version is up on conda now.

This will ensure it's only available when installed
@pmrv pmrv requested a review from liamhuber September 8, 2021 10:28
@pmrv
Copy link
Contributor Author

pmrv commented Sep 8, 2021

I've made it so now, that the code is only exported in the StructureFactory when the atomsk executable is available.

@pmrv pmrv merged commit 3b7f9b6 into master Sep 16, 2021
@delete-merged-branch delete-merged-branch bot deleted the atomsk branch September 16, 2021 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants