Skip to content

Commit

Permalink
Make it possible to simulate LJ mixtures with attractive and repulsiv…
Browse files Browse the repository at this point in the history
…e interactions
  • Loading branch information
lorenzo-rovigatti committed Oct 31, 2024
1 parent 208049d commit 3ad9bb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Interactions/LJInteraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ void LJInteraction::get_settings(input_file &inp) {
getInputNumber(&inp, "LJ_epsilon[1]", _epsilon + 1, 0);
getInputNumber(&inp, "LJ_epsilon[2]", _epsilon + 2, 0);

getInputBool(&inp, "LJ_only_repulsive[0]", _only_repulsive, 0);
getInputBool(&inp, "LJ_only_repulsive[1]", _only_repulsive + 1, 0);
getInputBool(&inp, "LJ_only_repulsive[2]", _only_repulsive + 2, 0);

if(getInputNumber(&inp, "LJ_sigma[2]", _sigma + 2, 0) == KEY_FOUND) {
_sigma[1] = 0.5 * (1. + _sigma[2]);
}
Expand All @@ -53,7 +57,7 @@ void LJInteraction::init() {
}

for(int i = 0; i < 3; i++) {
number rcut = _rcut * _sigma[i];
number rcut = (_only_repulsive[i]) ? pow(2.0, 1. / _n[i]) * _sigma[i] : _rcut * _sigma[i];
_sqr_LJ_rcut[i] = SQR(rcut);
_E_cut[i] = 4. * _epsilon[i] * (pow(_sigma[i] / rcut, (number) 2 * _n[i]) - pow(_sigma[i] / rcut, (number) _n[i]));
_sqr_sigma[i] = SQR(_sigma[i]);
Expand Down
1 change: 1 addition & 0 deletions src/Interactions/LJInteraction.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class LJInteraction: public BaseInteraction {
number _sqr_sigma[3];
number _epsilon[3];
number _sqr_LJ_rcut[3];
bool _only_repulsive[3] = {false, false, false};

inline number _lennard_jones(BaseParticle *p, BaseParticle *q, bool update_forces);

Expand Down

0 comments on commit 3ad9bb7

Please sign in to comment.