MLFF of eutectic molten salt with magnetic impurities

To share experience including discussions about scientific questions.


Moderators: Moderator, Global Moderator

Post Reply
Message
Author
henry_ezeaku
Newbie
Newbie
Posts: 8
Joined: Fri Feb 21, 2025 7:39 pm

MLFF of eutectic molten salt with magnetic impurities

#1 Post by henry_ezeaku » Thu Jul 30, 2026 10:41 pm

Good day VASP team,
I hope you are doing well.

Please, I have a question regarding the best approach of training an MLFF for a molten salt system with Cr (magnetic element) as impurity. The Cr can exist as Cr0, Cr2+, and Cr3+ in the melt. So, I intend generating an MLFF that covers these three oxidation states. The approach I tried did not work and I want to know if this task is feasible using the VASP MLFF.

My Approach
- My target temperature is 900 K; therefore, I did a heating run from 750 to 1150 K, using NPT and also the ICONST file avaliable. My training steps:
a) I trained on eutectic NaCl-MgCl2 + Cr0. For the Cr0, I added just 2 Cr atoms to a representative atomic configuration of a eutectic NaCl-MgCl2:
Na Mg Cl Cr
14 10 34 2
This is the INCAR file I used, where I specified an initial guess of 5 as the MAGMOM for Cr0.
# ---------- Electronic / accuracy ----------
ALGO = Normal # SCF algorithm (robust choice for MD runs)
PREC = Accurate # Precision; 'Accurate' improves force quality (important for ML training)
NELM = 100 # Max number of electronic SCF steps per ionic move
ISMEAR = 0 # Gaussian smearing (good for insulators / ionic liquids)
SIGMA = 0.1 # Smearing width in eV
ENCUT = 550 # Plane-wave energy cutoff (basis set size)
EDIFF = 1E-05 # Electronic SCF convergence criterion (tighter = more accurate forces)
LASPH = .TRUE. # Include non-spherical corrections inside PAW spheres
LREAL = Auto # Projection operators evaluated in real space automatically (faster)
LWAVE = .FALSE. # Don't write WAVECAR (saves disk during MD/ML runs)
LCHARG = .FALSE. # Don't write CHGCAR (saves disk during MD/ML runs)

# ---------- MD (NVT) ----------
IBRION = 0 # Molecular dynamics mode (no ionic relaxation)
ISIF = 3 # Change positions AND cell shape/volume dynamically
ISYM = 0 # Turn symmetry off
ISPIN = 2 # Non-spin-polarized run
MAGMOM = 14*0.0 10*0.0 34*0.0 2*5.0

MDALGO = 3 # Langevin thermostat for NPT sampling
LANGEVIN_GAMMA = 10 10 10 10 # Thermal friction per species (ps^-1)
LANGEVIN_GAMMA_L = 5 # Lattice friction coefficient (ps^-1) for barostat
PMASS = 1000 # Fictitious lattice mass (amu) - paper used 1000
PSTRESS = 0.001 # Target pressure in kbar (0.001 kbar = 1 bar)

TEBEG = 750 # Starting temperature (K)
TEEND = 1150 # Target temperature at end of run
NSW = 30000 # Number of MD steps
POTIM = 1 # Time step (in fs)

NCORE = 2 # Parallelization control

# ---------- (optional) Dispersion corrections ----------
GGA = ML # vdW-DF2 functional base (when using ML-type GGA = "ML")
AGGAC = 0.0 # Exchange parameter for vdW-DF2
LUSE_VDW = .TRUE. # Enable nonlocal vdW-DF2 correction
ZAB_VDW = -1.8867 # Kernel parameter (specific to vdW functional)

# ---------- MLFF: enable on-the-fly training ----------
ML_LMLFF = .TRUE. # Switch on the MLFF framework
ML_MODE = train # Training mode: ab-initio + ML hybrid MD (For vasp 6.4.2>)
ML_MCONF = 5000
ML_MB = 6000

b) After training, I used the ML_AB file to continue the training on eutectic + (Cr2+) system (that is having CrCl2 + configuration of eutectic salt):
Na Mg Cl Cr
14 10 38 2
For this case, I used MAGMOM = 14*0.0 10*0.0 38*0.0 2*4.0 (4 for the Cr2+).

c) After step b, I continued the training on eutectic + (Cr3+) system (that is CrCl3 + configuration of eutectic salt):
Na Mg Cl Cr
14 10 40 2
For this case, I used MAGMOM = 14*0.0 10*0.0 40*0.0 2*3.0 (3 for Cr3+).

After the sequential training, I did a refit and generated my MLFF. This is my training error:
# ERR nstep rmse_energy rmse_force rmse_stress
# ERR 2 3 4 5
# ERR ######################################################################
ERR 0 5.98130425E-03 4.91795177E-02 4.22210045E-01

Now, I have a 20 ps AIMD NVT run for eutectic + Cr0 at 900 K. I picked the POSCAR and ran a 20ps prediction-only run at 900 K using the MLFF. When I compare the RDF from AIMD and MLFF, I get this attached plot:

Cr.png

The generated MLFF reproduces the bulk salt RDFs but failed to reproduce those of Cr-Cl against AIMD. This behavior also happens for Cr2+ and Cr3+ production runs. Please, what might be causing this? Or maybe, is there a more robust way of training this kind of system using the VASP MLFF. Thank you.

Best regards,
Henry

You do not have the required permissions to view the files attached to this post.

ferenc_karsai
Global Moderator
Global Moderator
Posts: 588
Joined: Mon Nov 04, 2019 12:44 pm

Re: MLFF of eutectic molten salt with magnetic impurities

#2 Post by ferenc_karsai » Fri Aug 07, 2026 8:49 am

Your error in energy looks quite high. You get 5.98 meV/atom. I am usually below 1 meV/atom.
The error in forces looks ok.

Maybe first focus on the neutral system. That means train only on that system and evaluate the RDF with that. After fixing that you can move on to the charged ones.

I would need your ML_AB, ML_LOGFILE, OUTCAR, OSZICAR, XDATCAR, POSCAR, POTCAR, INCAR and KPOINTS file for the training of that.

Important questions are:
How is the magnetic moment during the on-the-fly calculation? Does it stay at a reasonable value?
Is 30 ps long enough (probably not)?
Is the structure stable during MD (did you look at the XDATCAR file)?


henry_ezeaku
Newbie
Newbie
Posts: 8
Joined: Fri Feb 21, 2025 7:39 pm

Re: MLFF of eutectic molten salt with magnetic impurities

#3 Post by henry_ezeaku » Mon Aug 10, 2026 9:22 pm

Good day Karsai,
I appreciate your response.

The training files for the Cr0, Cr2, and Cr3, can be found via this link: https://drive.google.com/drive/folders/ ... sp=sharing
It has the files you requested for the respective systems.

The magnetic moments are mostly stable during the training, and the structures I checked look stable. This can be checked via the attached XDATCAR files (found through the link).

Based on your recommendation, just to be sure I got you: It might not be feasible to have one MLFF trained on the three oxidations states of chromium in the salt right? That's Cr0, Cr2+, and Cr3+. Rather, it should be a separate MLFF for each oxidation state?
Thank you so much for the continued help.

Best regards,
Henry


ferenc_karsai
Global Moderator
Global Moderator
Posts: 588
Joined: Mon Nov 04, 2019 12:44 pm

Re: MLFF of eutectic molten salt with magnetic impurities

#4 Post by ferenc_karsai » Thu Aug 13, 2026 3:25 pm

The magnetic moments. Are not stable, they seem to vanish after some time:

if I call "grep mag OSZICAR" I get the following:

Code: Select all

...    ...   ...
   8432 T=   893. E= -.96445902E+02 F= -.10372177E+03 E0= -.10372177E+03  EK= 0.72759E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     10.000
   8442 T=   969. E= -.96102626E+02 F= -.10399233E+03 E0= -.10399233E+03  EK= 0.78897E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     10.000
   8452 T=  1078. E= -.94915012E+02 F= -.10369265E+03 E0= -.10369265E+03  EK= 0.87776E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     10.000
   8462 T=  1079. E= -.94424039E+02 F= -.10320923E+03 E0= -.10320923E+03  EK= 0.87852E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     10.000
   8472 T=  1096. E= -.94202783E+02 F= -.10312973E+03 E0= -.10312973E+03  EK= 0.89270E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     10.000
   8482 T=  1026. E= -.94738334E+02 F= -.10309170E+03 E0= -.10309170E+03  EK= 0.83534E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     10.000
   8492 T=   905. E= -.95296297E+02 F= -.10266507E+03 E0= -.10266506E+03  EK= 0.73688E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     10.000
   8502 T=   829. E= -.95738211E+02 F= -.10249270E+03 E0= -.10249270E+03  EK= 0.67545E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     10.000
... ... ...
  21252 T=  1026. E= -.91806278E+02 F= -.10016057E+03 E0= -.10016048E+03  EK= 0.83543E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.001
  21262 T=  1049. E= -.91810398E+02 F= -.10035512E+03 E0= -.10035380E+03  EK= 0.85447E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.013
  21272 T=  1209. E= -.90999711E+02 F= -.10084319E+03 E0= -.10083812E+03  EK= 0.98435E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.063
  21282 T=  1155. E= -.91311583E+02 F= -.10071823E+03 E0= -.10071131E+03  EK= 0.94066E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.091
  21292 T=  1009. E= -.91963153E+02 F= -.10018330E+03 E0= -.10017423E+03  EK= 0.82201E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.124
  21302 T=   893. E= -.92439296E+02 F= -.99710416E+02 E0= -.99702857E+02  EK= 0.72711E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.091
  21346 T=  1123. E= -.92481571E+02 F= -.10162397E+03 E0= -.10161668E+03  EK= 0.91424E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.011
  21356 T=   938. E= -.93356809E+02 F= -.10099255E+03 E0= -.10098258E+03  EK= 0.76357E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.020
  21366 T=   929. E= -.93199451E+02 F= -.10076575E+03 E0= -.10075692E+03  EK= 0.75663E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.025
  21376 T=   946. E= -.93283390E+02 F= -.10098337E+03 E0= -.10097627E+03  EK= 0.77000E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.027
  21386 T=   969. E= -.93103077E+02 F= -.10099147E+03 E0= -.10098433E+03  EK= 0.78884E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.030
  21396 T=   933. E= -.93087973E+02 F= -.10068619E+03 E0= -.10067637E+03  EK= 0.75982E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.023
  21406 T=   906. E= -.92712104E+02 F= -.10008900E+03 E0= -.10007543E+03  EK= 0.73769E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.002
  21416 T=   862. E= -.92771757E+02 F= -.99791241E+02 E0= -.99776781E+02  EK= 0.70195E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.048
  21426 T=   904. E= -.92789167E+02 F= -.10015223E+03 E0= -.10013756E+03  EK= 0.73631E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.103
  21436 T=  1002. E= -.92593368E+02 F= -.10075500E+03 E0= -.10074116E+03  EK= 0.81616E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.107
  21450 T=  1097. E= -.92271608E+02 F= -.10120818E+03 E0= -.10120290E+03  EK= 0.89366E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.030
  21460 T=   975. E= -.92661298E+02 F= -.10059842E+03 E0= -.10059662E+03  EK= 0.79371E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.004
  21470 T=   954. E= -.92358928E+02 F= -.10012833E+03 E0= -.10012536E+03  EK= 0.77694E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.011
  21480 T=  1011. E= -.92154168E+02 F= -.10038347E+03 E0= -.10037930E+03  EK= 0.82293E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.010
  21490 T=  1027. E= -.91987423E+02 F= -.10035400E+03 E0= -.10034946E+03  EK= 0.83666E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.003
  21500 T=   950. E= -.92725509E+02 F= -.10046026E+03 E0= -.10045649E+03  EK= 0.77348E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.003
  21510 T=   930. E= -.93142526E+02 F= -.10071354E+03 E0= -.10071117E+03  EK= 0.75710E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.009
  21520 T=   959. E= -.93140803E+02 F= -.10095353E+03 E0= -.10095229E+03  EK= 0.78127E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.007
  21530 T=  1014. E= -.92941521E+02 F= -.10120125E+03 E0= -.10120086E+03  EK= 0.82597E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.003
  21540 T=  1054. E= -.92959240E+02 F= -.10154041E+03 E0= -.10154036E+03  EK= 0.85812E+01 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.000
... ... ...
  27402 T=  1224. E= -.91413254E+02 F= -.10138217E+03 E0= -.10138217E+03  EK= 0.99689E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27412 T=  1296. E= -.91078569E+02 F= -.10163309E+03 E0= -.10163309E+03  EK= 0.10555E+02 SP= 0.00E+00 SK= 0.00E+00 mag=     -0.000
  27422 T=  1285. E= -.91225745E+02 F= -.10169056E+03 E0= -.10169056E+03  EK= 0.10465E+02 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27432 T=  1173. E= -.92060675E+02 F= -.10161523E+03 E0= -.10161523E+03  EK= 0.95546E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27442 T=  1124. E= -.91963596E+02 F= -.10111784E+03 E0= -.10111784E+03  EK= 0.91542E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27452 T=  1006. E= -.92882890E+02 F= -.10107437E+03 E0= -.10107437E+03  EK= 0.81915E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27462 T=  1156. E= -.92058604E+02 F= -.10147148E+03 E0= -.10147147E+03  EK= 0.94129E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27472 T=  1179. E= -.91868452E+02 F= -.10147100E+03 E0= -.10147093E+03  EK= 0.96026E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27482 T=  1081. E= -.92229084E+02 F= -.10103157E+03 E0= -.10103148E+03  EK= 0.88025E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27492 T=  1098. E= -.91904541E+02 F= -.10084794E+03 E0= -.10084787E+03  EK= 0.89434E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27502 T=  1151. E= -.91339755E+02 F= -.10071571E+03 E0= -.10071533E+03  EK= 0.93760E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27521 T=  1021. E= -.92314415E+02 F= -.10062763E+03 E0= -.10062439E+03  EK= 0.83132E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.000
  27531 T=  1016. E= -.92439446E+02 F= -.10071505E+03 E0= -.10071035E+03  EK= 0.82756E+01 SP= 0.00E+00 SK= 0.00E+00 mag=      0.002

1) You can see that the magnetic momen vanishes more or less after some time. I think this can make big problems for on-the-fly trajectories.
I would suggest using [url}https://vasp.at/wiki/NUPDOWN[/url] which constraints the magnetic moment in your calculation.

2) Another thing is to use https://vasp.at/wiki/MAXDIS and set it to a small value. I saw that the atoms in your system quite strongly diffuse. If they travel a lot and in the training during on-the-fly many dft steps are skipped, then the previous dft charge density is not a good starting point any more for the next dft step. MAXDIS sets a distance and if any of the atoms travelled further than this distance then superposition of atomic densities are chosen as a starting density rather than the charge density from the last dft step.

3) The on-the-fly unnesserily samples too much since the automatic threshold determination fails. We have seen that this can happen.
Here I plot the maximum bayesian error of forces and the threshold (grep BEEF ML_LOGFILE) at every MD step:
Image

You see that at too many steps the error is above the threshold. I've experienced already a few times and it looks like that our current automatic threshold determination does not always work. To counter this you need to manually set the threshold. Looking at your plot the majority of errors is around 0.2 to 03.
I would set the thresholds between 0.35 and 0.5 (I would start with 0.5):

Code: Select all

ML_ICRITERIA = 0 # enables constant threshold
ML_CTIFOR = 0.5 # value for threshold

Setting a higher threshold, would result in less frequent sampling and you could run longer trajectories for training.
I would run around 100 to 200 ps for training.

Regarding different oxidation states: It depends on the use case. If you want to describe different oxidation states in the structure, you would need to distinguish different Cr types in the structure. That means each Cr with a different state would be identified as a different element (be careful elements in VASP only have two characters). These elements would be also need to be distinguished already on the training level.

You do not have the required permissions to view the files attached to this post.

Post Reply