Hi there,
I’ve been using LAMMPS a lot for my research and it has been quite useful for simulating partially ionized plasmas !!
Now I’m interested in simulating a partially ionized plasma with variable ionization over time, this is, ionizing neutral atoms while running a simulation.
This is, the simulation starts with two species 1 and 2 using the same script I’ve always used (and it works) but this time I’ve modified the fix_nve.cpp in order to change the atom type from 2 to 1 (from neutral to ions), after the integration, with some hard-coded probability. The idea in the future is to include a MCC module with the ionization cross section if this simple test work.
I’ve only changed the final_integrate function in the fix_nve.cpp file as follows:
void FixNVE::final_integrate()
{
double dtfm;
// update v of atoms in group
double **v = atom->v;
double **f = atom->f;
double *q = atom->q;
double *rmass = atom->rmass;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
if (rmass) {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
dtfm = dtf / rmass[i];
v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2];
}
} else {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
dtfm = dtf / mass[type[i]];
v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2];
**if (type[i]==2){**
**double r = dis(gen);**
**double qe = 1.60217662e-19;**
**if(r<0.00002){**
**type[i] = 1;**
**q[i] = qe;**
}
}
}
}
atom->map_init();
atom->map_set();
}
and apparently it works… but not exactly as I’d like…
if I dump a file with the id, type and velocities of all the atoms I do see an decrease in #neutrals and an increase in #ions but at some point, after a few thousand timesteps I get this error:
Out of range atoms - cannot compute PPPM (…/pppm.cpp:1891)
Also if I compare the values of the kinetic energy computed by lammps for each species is different from the values I get computing it from the velocities for each species in the dump file.
I’m not sharing the script since is the same as before I did this change and it worked before, I’m probably not changing everything I need to in the .cpp file in order to “ionize” correctly or maybe I should write a separate fix file but I’m not sure on how to do it and what type of fix should it be…
If you can help me with this I’ll really appreciate it!
Thanks,
Marco