Comments (10)
I think an easy way would be to add an optional flag to this that dictates whether elements should be assigned or the name taken as is.
from foyer.
It could be as easy as changing
element = elem.Element.getBySymbol(mb_particle.name)
to
try:
element = elem.Element.getBySymbol(mb_particle.name)
except KeyError:
element = mb_particle.name
From some quick testing it looks that openmm Atoms can have arbitrary element names.
from foyer.
True, but we don't want to fail silently.
from foyer.
We could include a flag in the except block that raises a warning after the topology has been built that warns the user that the element names for some particles could not be interpreted
from foyer.
That should also be ok. Make sure you actually create a new OpenMM Atom object though instead of just using the string.
Also I would recommend adding a little cache like here so that the user doesn't get spammed with warnings for every instance of a missing atom name.
from foyer.
Right, I was planning on just providing a single warning after the topology has been built.
from foyer.
Any ideas on how to load a force field with atomtypes that contain non-periodic table element names? I think I've almost got it working if I can figure that part out.
It looks like atomtypes are loaded using this function, which calls a function of the same name in OpenMM. Currently if an atomtype is not one of those in the periodic table, then a KeyError is generated when a periodic table look-up is attempted by OpenMM.
My current line of thinking is doing something like this
def registerAtomType(self, parameters):
actual_element = parameters['element']
parameters['element'] = 'H'
super(Forcefield, self).registerAtomType(parameters)
# Somehow access the atomtype we just loaded in and change the element name to actual_element
I'm just not sure how to access the atomtype that has just been loaded to change the element name.
from foyer.
This is the OpenMM function where that happens. You can either replicate this function entirely on our end and remove the super()
or see if you can edit self._atomTypes
and change the name of the specific one after creation.
from foyer.
Cool, yeah it looks like editing self._atomTypes[parameters['name']].element
should do the trick
from foyer.
Preliminarily implemented
from foyer.
Related Issues (20)
- Edge case when scaling factors are 0 HOT 1
- Getting an error when using Porebuilder and foyer/mbuild, maybe in the box vectors. HOT 1
- Windows built is failing HOT 1
- Parametrized structure has non-zero charge. HOT 1
- ParmEd residue matching assumes ordered residues
- Atom typing triangular water fails HOT 3
- Improper dihedral coefficients in oplsaa.xml HOT 7
- The General Forcefield will not work with GMSO dev branch. HOT 1
- Foyer not working when installed using `conda` but works with `mamba` HOT 4
- Dihedrals not found HOT 13
- deep copy in nbfix doesn't preserve all structure attributes
- CI stops running because tests are using too much memory. #1090
- Update Github action
- Failed Docker build HOT 1
- Error when foyer is imported HOT 9
- Failing CI tests on main
- Question on Retaining Manual Atomtype Modifications Post apply Method in Foyer HOT 2
- Sigma value for alcohol hydrogen in OPLSAA xml HOT 1
- Contradictory info about supported versions of Python HOT 4
- Quickstart example fails HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from foyer.