-
Notifications
You must be signed in to change notification settings - Fork 82
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 the create_magnetic_configuration
function
#640
Conversation
I have a high-level question that might be slightly off-topic, so apologies in advance: The underlying issue here is that QE requires each magnetic moment to be specified as a separate kind. However, the AiiDA I have to admit I didn't think this through (so it's probably a bad idea), I'm mostly interested in your thoughts on how to split the interface between generic and QE-specific parts. |
Actually, I think your suggestion makes sense. While working on this, I was thinking it would be great if the Originally the So, at this point I'm leaning in favour of your suggestion to move this logic into the One thing I just thought of: what if the user provides the To comment some more on splitting QE-specific and generic parts: Isn't the reliance of |
just a quick side note: non-collinear magnetism ( |
Another note: If we push the |
And yet another note: QE has a hard-coded limit on the number of kinds that is allowed ( |
Just to put it into context. We decided that e.g. the degrees of freedom when doing relaxations should not go into the For the magnetics it goes deeper. As you know, the symmetry also changes when introducing magnetic moments. So then the question maybe becomes more, what is |
Just trying to answer the historical part. An additional note: it's always possible to go in a well-defined and unique way from a description with kinds + sites, to a description with only sites (just assign all kind properties to each site with that kind name). The reverse, unfortunately, is not always possible (it's similar to the issue you have, of deciding a threshold to determine when to consider two sites being of the same species or not. So, from a design point of view, and also for simplicity, I would keep the current design with kinds, unless there are obvious problems (that I don't see). Now, whatever you do, you will still have some issues in some cases, so I don't think there is a perfect solution:
A different question is whether to add information on magnetisation or not in StructureData. In the original design, I decided to keep StructureData simple and not do it, with the ideas that:
Now: when I made this decision, I wasn't 100% sure it was the perfect, and I am still not (even if I'm still 85-90% positive that's OK :-) ). So if you are all convinced it's better to move magnetic information in StructureData I won't oppose to it (but you need to balance the advantage - as mentioned above, it's going to require a change in all plugins that need to get the information from there and convert it to something the code understands, with the risk that some codes might not be able to convert in a well-definite way. One way, if you really want to do it (maybe the only reason I see now is the discussion above on the symmetry of the system when sites have different magnetisation, but also there one could think to pass an optional parameter with the magnetisation to any symmetry-detection function, together with the structure), is to have a subclass that extends StructureData in MagneticStructureData or something like this, so that it does not break existing code. To conclude: considering the amount of work that might be needed to do any change, involving all plugins, I would be personally hesitant to do changes to StructureData unless the benefits outweigh the issues. If it's really important to do a change, I would open an issue just to discuss that, and make sure the majority of active plugin developers can discuss if it's more of an improvement or a of burden for them. |
Just my 2 cents: I've also recently struggled with the fact that In view of improving interoperability between ASE and AiiDA going forward, I would personally highly welcome if the information that can be stored in an ASE |
Fair point and one that we hear more often from users, especially if they have worked with Not sure how much you have been involved in the discussions surrounding this topic, but we should of course not forget that the AiiDA data structures are fundamentally quite different from those in ASE, as in they are immutable. Not saying that they are therefore incompatible, but we always find out the hard way that the immutability of AiiDA's datastructures makes working with these objects way more complex than with the ASE analogue which can cause frustration. For example, if we were to incorporate the |
Well this depends. It can be argued that symmetry is a much more fundamental concept than applied chemistry/physics. So if we base something on chemistry and physical principles, it should definitively obey symmetry. If not, there should be very good arguments for not doing this (and it should be clear to the users why that is). In my view we should have a representation of points in space, within a domain. This is somewhat what I think, as has been discussed before, it is probably a good time to start to relax the connection of the datastructure and AiiDA core and give the existing ones a bit more context. E.g. put the |
Hi Espen, thanks. Let me try just to summarise here some discussions we had recently in the team about moving out these classes. While I think most people agree that moving StructureData and similar in a different package is a good idea in principle, we've been discussing this multiple times in the various AiiDA meetings and it's not clear if the benefits outweigh the amount of work to make it happen. It's not just moving the code out, it's really making sure that everything works fine also in an intermediate situation, without cyclic dependencies between packages etc. E.g. now in 1.6 one could move it out and make AiiDA depend on the new package for now, so as to make sure all code continue working when you do In addition, moving out the plugins does not solve the real problem. These discussions will still have to take place before deciding possible extensions (and among the same people) with the additional disadvantage that if we change something, now we could still make a migration to "fix" things, but once it's in an external package, we can't touch the data anymore. For all these reasons, it's still not clear to us if it's worth investing so much energy in moving them out at this stage, considering there is other work to do in the code that might have a much larger impact. This is just to explain why this has not happened yet, and what are the technical details that make it complex (that might not be obvious when one first thinks about it). |
Thanks @giovannipizzi. Maybe it would make sense to continue this discussion on the discussion boards of AiiDA, but I will just quickly reply to your comment. Yes, I fully understand this is a complex undertaking, but the longer we wait the more complex it is going to be. Also it only pertains to the domain specific data types. It is nice to see in the docs that the domain specific types are now covered in their own section. In my view there are three paths into the future: (i) leave it as is, (ii) leave as is, but start the development of other data types that are put into dedicated plugins and recommend users to use those (iii) try to approach the task of separating out the material science data types now. With respect to this not really addressing the true problem, in some ways it will as it will give additional freedom to set more specific bounds what the data types are supposed to describe/represent. Now, it is not so easy to define this as it would maybe be difficult to define what Also, with respect to the definitions of the data types, I personally think we should focus on this being as portable as possible given that the ontology is still pretty floating. |
I would like to also express my view on the matter.
Personally, I don't think the ability to enable/disable a certain feature is a to-be-considered argument when we are talking about a class. I think one of the points of working with objects is to assign to it the properties, which by nature belong to it. To me, magnetization is the feature of a structure, so I would vote to add it there. Additionally, a code can decide not to use magnetization that is coming from the structure.
I think that magnetization is also a factor that influences the structure of a material (remember that the structures of ferro or antiferro iron are different).
I don't think we need to request plugin developers to change anything if we add the magnetic moment attribute and we don't remove kinds. I believe the atomic kinds can and should stay there to cover the corner cases when certain elements of the same type should be considered differently. Finally, from my point of view it would be nice to add s = StructureData(...)
allotrope = s.create_allotrope(properties = ['mass', 'magnetic_moment'])
# The content of the allotrope.
{
kinds = [ 'Fe1', 'Fe2'],
properties: {
'Fe1': {'magmom': 1},
'Fe2': {'magmom': -1},
},
} |
14011a2
to
79e3cda
Compare
79e3cda
to
7629d8b
Compare
0b4eacd
to
30c97e0
Compare
30c97e0
to
4121070
Compare
4121070
to
8910821
Compare
@sphuber after seeing a copy of this code in the Although the discussion here is important in the context of aiidateam/team-compass#21, it's clear that this switch to a new If you agree, I'll add some documentation and we can finally merge this one. |
@mbercx Agreed. If you can update the branch making sure tests pass and add some minimal docs, I will approve. Thanks! |
Tests failing seem to be related to the same issue that caused the nightly build to fail. It seems to be a E pydantic.errors.ConfigError: duplicate validator function "aiida_quantumespresso.common.hubbard.HubbardParameters.check_manifolds"; if this is intended, set `allow_reuse=True` But that seems strange... The nightly build also succeeded when I ran it for Python 3.10, see https://github.com/aiidateam/aiida-quantumespresso/actions/runs/5052086649 |
I think the issue was related to pydantic/pydantic#5821, i.e. a bug in Will open a PR to restrict our |
8910821
to
69e3fc7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mbercx . It has been a long time coming this one 😄 Let's get this things merged
Hold it, still working on the documentation. 😅 |
a6f1789
to
9d50cbb
Compare
Blocked since built on #946 |
9d50cbb
to
b1db40c
Compare
b1db40c
to
e311fdf
Compare
create_magnetic_allotrope
functioncreate_magnetic_configuration
function
@sphuber I've still made a few changes/additions as I was working on the documentation for this:
Things (potentially) left to do:
|
In order to pass on the magnetic configuration between calculations, the structure used for the follow-up calculation needs to have the right magnetic kinds to be able to properly assign the magnetisation to each site. Here we add a calculation function that, based on the structure and magnetic moments, returns a new `StructureData` with the required magnetic kinds, as well as a `Dict` with the corresponding magnetic moments for each kind.
e311fdf
to
159d67c
Compare
Fixes #639
In order to pass on the magnetic configuration between calculations, the
structure used for the follow-up calculation needs to have the right kinds
to be able to properly assign the magnetization to each site.
Here we add a calculation function that, based on the structure and
magnetic moments, returns a new
StructureData
with the requiredmagnetic kinds, as well as a
Dict
with the corresponding magneticmoments for each kind.
To create the new list of kinds, the algorithm loops over all the elements
in the structure and makes a list of the sites with that element and their
corresponding magnetic moment. Next, it splits this list in three lists:
lower than
ztol
The algorithm then sorts the positive and negative lists from large to small
absolute value, and loops over each list. New magnetic kinds will be created
when the absolute difference between the magnetic moment of the current
kind and the site exceeds
atol
.The positive and negative magnetic moments are handled separately to
avoid assigning two sites with opposite signs in their magnetic moment to
the same kind and make sure that each kind has the correct magnetic
moment, i.e. the largest magnetic moment in absolute value of the sites
corresponding to that kind.