-
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
PwRelaxWorkChain
: Revisit meta iterations and final SCF
#705
Comments
Additional (historical) note: the final SCF (with printing the stress and forces turned on) would allow to have an indication, in the provenance, of the forces and stresses (if they are below a certain threshold, we are allowed by the license to publish the data). |
Some more investigations on this, looking at 2510 work chains from the MC3D that ran 3 meta-convergence First some statistics. Out of 2510 work chains:
I'll focus on looking at the ones with 3 meta-convergence steps, then we can simply look at step 2. A couple of reasons why a third step could be necessary:
To proceed, I would have exit code 501 restart the calculation with aiida-quantumespresso/aiida_quantumespresso/parsers/pw.py Lines 211 to 216 in 93e3499
Since the reason why the forces/stresses can be different is because the basis set is incomplete for the new unit cell, which is caught by the final SCF since afaik the basis set is regenerated before this static run. The meta convergence can remain, but I would add a feature as discussed in #733, i.e. do a first run with much looser precision settings. |
Thanks for the analysis @mbercx . Good to know that the meta-convergence still has a true raison d'être. I don't think I understand why you think the comment in the parser you highlight is incorrect. The basis sets are recomputed and so the computed forces/stress may indeed very well be different if the basis set changes a lot with respect to the one used in the vc-relax cycle. At the time I decided to not handle the |
I'm not 100% sure that "this is not necessarily a problem". If the basis set turned out to be incomplete due to the change in unit cell, isn't the final structure incorrect? The only case which I can think of where |
Define "incorrect". Yes, if you were to rerun the calculation with same settings, but just do SCF (instead of a relax) you would find that the stress and or forces actually exceed the requested thresholds. But it seems that we agree. I also can see this error just being handled in the base by restarting. Since the restart should be fast, maybe there is no harm in doing it always. As you say, my solution relies on going through the |
@sphuber since I'm planning to (re)run a bunch of relaxation for the MC3D again shortly, I wanted to finally tackle the logic of the PwRelaxWorkChain as described in this issue. In summary:
Happy to hear your thoughts! Also pinging @mkotiuga @giovannipizzi @unkcpz @qiaojunfeng @bastonero to hear what they think. To still come back to this:
Exactly. And in case this is true for the final meta-iteration, the PwRelaxWorkChain will not have fully relaxed the structure, e.g.:
The final structure here is not converged within the thresholds specified by the user. The main purpose of the PwRelaxWorkChain is to take care of this, else the user might as well just run a PwBaseWorkChain. I'll admit this case is rather rare, a lot of times the second meta-iteration does finish with exit code zero. But not always, and in a lot of cases the second iteration is run when it is not necessary. |
I think a pre-relax could make sense as long as it is optional. Were you thinking of just a single
This is already the case, I believe. A handler exists for
Agreed.
Historically, there were two reasons for this I believe:
If this a complete list of the reasons (I might be forgetting some arguments), then it would indeed make sense to get rid of the final scf in the
This is actually strange isn't it? If the first 501 is most likely because the initial structure changed a lot during the |
Yes, exactly that. Just a single (optional) run with looser convergence parameters. I'm still wondering if it should be run by default. If not, we'd still want a protocol for this initial relaxation, I think.
Does it? I can only find a reference to the aiida-quantumespresso/src/aiida_quantumespresso/workflows/pw/relax.py Lines 257 to 265 in 37d2a14
And there it is simply used to allow this exit code, i.e. it doesn't make the work chain exit with The context variable
aiida-quantumespresso/src/aiida_quantumespresso/workflows/pw/relax.py Lines 267 to 273 in 37d2a14
aiida-quantumespresso/src/aiida_quantumespresso/workflows/pw/relax.py Lines 290 to 293 in 37d2a14
aiida-quantumespresso/src/aiida_quantumespresso/workflows/pw/relax.py Lines 295 to 311 in 37d2a14
There is still the comment from @giovannipizzi above. I.e. we want to have "proof" that the license conditions are met. This is a bit tricky with the pre-relax approach: continuing from the "pre-relaxed" structure, there is no guarantee that on the first SCF from the "proper" the forces and stresses will be lower than these thresholds. I guess it does point to the somewhat arbitrary nature of these conditions, since they will obviously depend on the chosen computational parameters. Frankly, I would not let the structure of the
I'd have to find it again (I tried, but too many projects 😅). To be clear, these instances are rare. In the vast majority of the cases, the volume change is a good indicator that you might have Pulay stresses. But now that QE runs a final SCF for each |
Found the example
There were only a few ionic steps, and the volume didn't change much:
So it technically hasn't converged, but only by a hair's breadth. ^^ I still think using the |
Currently, the
PwRelaxWorkChain
performs several relaxations (meta iterations) in case the change in volume of the relaxation is above 1%:aiida-quantumespresso/aiida_quantumespresso/workflows/pw/relax.py
Lines 305 to 330 in da94161
One possible motivation for this could be the (isotropic?) Pulay stress: checking the volume change and repeating the calculation in case it is above a certain threshold would be a viable fix for this problem. There could be other reasons though, so we have to carefully check for some runs that this is indeed the case.
If the only motivation is the Pulay stress, I think we can remove this meta-convergence and simply rely on the error handler in the
PwBaseWorkChain
that checks if the pressure obtained from the final SCF with a regenerated basis set is still below the threshold. In case the pressure is converged to the threshold in thevc-relax
, the resulting pressure from this final SCF should be exactly the Pulay stress (plus-minus the threshold, of course).Regarding the final SCF: an important historical use case for this was the fact that some structures came from databases where the license has restrictions on making the structures publicly available. Since the original structures are stored in the provenance, the extra SCF is important to cut off the published provenance at this point.
Conclusion - TODO
vc-relax
should be run.The text was updated successfully, but these errors were encountered: