Automatic detection for electrode etypes

This commit is contained in:
Ludwig Ahrens
2022-08-19 15:15:50 +02:00
parent 8edcc3381e
commit 0388913241
11 changed files with 1697 additions and 1680 deletions

View File

@ -45,8 +45,8 @@ Syntax
*couple group-ID value*
group-ID = group of atoms treated as additional electrode
value = electric potential or charge on this electrode
*etypes values = atom types*
specify atom types exclusive to the electrode for optimized neighbor lists
*etypes*
construct optimized neighbor lists (types of the electrode must be exclusive to them)
*ffield on/off*
turn on/off finite-field implementation
*write_mat filename*

View File

@ -4,7 +4,7 @@
boundary p p p # ffield uses periodic z-boundary and no slab
include settings.mod # styles, groups, computes and fixes
fix conp bot electrode/conp -1.0 1.805132 couple top 1.0 symm on ffield yes etypes 6*7
fix conp bot electrode/conp -1.0 1.805132 couple top 1.0 symm on ffield yes etypes
thermo 50
thermo_style custom step temp c_ctemp epair etotal c_qtop c_qbot c_qztop c_qzbot

View File

@ -6,7 +6,7 @@
boundary p p p # ffield uses periodic z-boundary and no slab
include settings.mod # styles, groups, computes and fixes
fix conp bot electrode/conp -1.0 1.805132 couple top 1.0 symm on ffield yes etypes 6*7
fix conp bot electrode/conp -1.0 1.805132 couple top 1.0 symm on ffield yes etypes
fix_modify conp tf 6 1.0 18.1715745
fix_modify conp tf 7 1.0 18.1715745

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@ boundary p p f # slab calculation
include settings.mod # styles, groups, computes and fixes
kspace_modify slab 3.0
fix conq bot electrode/conq -1.0 1.979 couple top 1.0 etypes 5 # conq doesn't take symm option
fix conq bot electrode/conq -1.0 1.979 couple top 1.0 etypes # conq doesn't take symm option
thermo 50
thermo_style custom step temp c_ctemp epair etotal c_qbot c_qtop f_conq[1] f_conq[2]

View File

@ -5,7 +5,7 @@ boundary p p f # slab calculation
include settings.mod # styles, groups, computes and fixes
kspace_modify slab 3.0
fix conp bot electrode/conp v_vbot 1.979 couple top v_vtop etypes 5
fix conp bot electrode/conp v_vbot 1.979 couple top v_vtop etypes
variable qex_bot equal -1.0-f_conp[1][1] # difference between desired and 0V charge
variable qex_top equal 1.0-f_conp[2][1] # difference between desired and 0V charge

View File

@ -5,7 +5,7 @@ boundary p p f # slab calculation
include settings.mod # styles, groups, computes and fixes
kspace_modify slab 3.0
fix conp bot electrode/conp -1.0 1.979 couple top 1.0 symm on etypes 5
fix conp bot electrode/conp -1.0 1.979 couple top 1.0 symm on etypes
thermo 50
thermo_style custom step temp c_ctemp epair etotal c_qbot c_qtop

View File

@ -4,7 +4,7 @@
boundary p p p # ffield uses periodic z-boundary and no slab
include settings.mod # styles, groups, computes and fixes
fix conp bot electrode/conp -1.0 1.979 couple top 1.0 symm on etypes 5 ffield yes
fix conp bot electrode/conp -1.0 1.979 couple top 1.0 symm on etypes ffield yes
thermo 50
thermo_style custom step temp c_ctemp epair etotal c_qbot c_qtop

View File

@ -6,7 +6,7 @@ include settings.mod # styles, groups, computes and fixes
kspace_modify slab 3.0
variable v equal ramp(2,4)
fix conp bot electrode/conp 0.0 1.979 couple top v_v symm on etypes 5
fix conp bot electrode/conp 0.0 1.979 couple top v_v symm on etypes
thermo 50
thermo_style custom step temp c_ctemp epair etotal c_qbot c_qtop v_v

View File

@ -6,9 +6,9 @@ include settings.mod # styles, groups, computes and fixes
kspace_modify slab 3.0
unfix nvt # remove NVT thermostat included from "settings.mod"
fix conpthermo bot electrode/thermo -1.0 1.979 couple top 1.0 etypes 5 temp 500 100 7 # temp tau rng
fix conpthermo bot electrode/thermo -1.0 1.979 couple top 1.0 etypes temp 500 100 7 # temp tau rng
# to compare to regular constant potential, switch previous line to this:
#fix conp bot electrode/conp -1.0 1.979 couple top 1.0 etypes 5 symm on
#fix conp bot electrode/conp -1.0 1.979 couple top 1.0 etypes symm on
fix nve electrolyte nve
# note ionic liquid does not reach 500K immediately

View File

@ -202,10 +202,6 @@ FixElectrodeConp::FixElectrodeConp(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR, "Illegal fix electrode/conp command with read");
}
} else if ((strcmp(arg[iarg], "etypes") == 0)) {
if (iarg + 2 > narg) error->all(FLERR, "Need one argument after etypes command");
int ilo, ihi;
utils::bounds(FLERR, arg[++iarg], 1, atom->ntypes, ilo, ihi, error);
for (int i = ilo; i <= ihi; ++i) etypes.push_back(i);
etypes_neighlists = true;
} else if ((strcmp(arg[iarg], "temp") == 0)) {
if (iarg + 4 > narg) error->all(FLERR, "Need three arguments after temp command");
@ -1172,6 +1168,25 @@ void FixElectrodeConp::read_from_file(const std::string &input_file, double **ar
void FixElectrodeConp::request_etypes_neighlists()
{
int const ntypes = atom->ntypes;
// construct etypes
int *mask = atom->mask;
int *type = atom->type;
auto elec = std::vector<int>(ntypes, 0);
auto elyt = std::vector<int>(ntypes, 0);
for (int i = 0; i < atom->nlocal; i++) {
if (mask[i] & groupbit)
elec[type[i] - 1] += 1;
else
elyt[type[i] - 1] += 1;
}
MPI_Allreduce(MPI_IN_PLACE, &elec.front(), ntypes, MPI_INT, MPI_SUM, world);
MPI_Allreduce(MPI_IN_PLACE, &elyt.front(), ntypes, MPI_INT, MPI_SUM, world);
etypes.clear();
for (int i = 0; i < ntypes; i++) {
if (!elec[i] == !elyt[i]) error->all(FLERR, "Types overlap, cannot use etypes keyword");
if (elec[i]) etypes.push_back(i + 1);
}
// construct skip arrays
int *iskip_mat = new int[ntypes + 1];
int *iskip_vec = new int[ntypes + 1];
int **ijskip_mat;