-
Notifications
You must be signed in to change notification settings - Fork 15
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
Fix of mixing rules #333
Fix of mixing rules #333
Conversation
The central change is introducing a map of Mixingrules as storage and also USE them later in the Comp2Params
Sorry I don't fully understand what is the problem here. Can you clarify? |
For now, the LB rule is used in the general calculations in Comp2Params: ls1-mardyn/src/molecules/Comp2Param.cpp Lines 65 to 66 in 4f5b49f
Since other rules might be introduced later, this is not ideal and it would be better to do something like (note the lambda expressions): if (mixingrule->getType() == "LB") {
eta = mixingrule->getParameters().at(0);
xi = mixingrule->getParameters().at(1);
auto mixingSigma = [&](double epsi, double epsj) { return xi * sqrt(epsi * epsj); }
auto mixingEpsilon = [&](double epsi, double epsj) { return xi * sqrt(epsi * epsj); }
// #ifndef NDEBUG
Log::global_log->info() << "Mixing : cid+1(compi)=" << compi+1 << " <--> cid+1(compj)=" << compj+1 << ": xi=" << xi << ", eta=" << eta << std::endl;
// #endif
} else {
Log::global_log->error() << "Mixing: Only LB rule supported" << std::endl;
Simulation::exit(1);
} and later in the calculations
instead of the current (LB-specific) implementation. But with this, the lambda expressions are just defined in the scope of the |
Ah ok so you want to store functions in the variables and later use them to get the actual mixing coefficients, correct? You could do something like this: std::function<double(double, double)> mixingEpsilon;
std::function<double(double, double)> mixingSigma;
if (mixingrule->getType() == "LB") {
// ...
mixingSigma = [=](double epsi, double epsj) { return xi * sqrt(epsi * epsj); };
mixingEpsilon = [=](double epsi, double epsj) { return xi * sqrt(epsi * epsj); };
} Note the use of taking I've almost never used the |
Thank you! I have used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the cpp
files? Usually the headers should only contain declarations and the implementations go into the cpp
s
Co-authored-by: FG-TUM <[email protected]>
Co-authored-by: FG-TUM <[email protected]>
Co-authored-by: FG-TUM <[email protected]>
Co-authored-by: FG-TUM <[email protected]>
Co-authored-by: FG-TUM <[email protected]>
Co-authored-by: FG-TUM <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just some unnecessary copies then we are good to merge!
Co-authored-by: FG-TUM <[email protected]>
Description
The mixing rules are kind of messed up for now, see issues:
#73
neededCoeffs
check should be multiplied by two (if(dmixcoeff.size() < neededCoeffs){
) and this should probably be an==
Domain::_mixcoeff
andEnsembleBase::_mixingrules
Comp2Param::initialize
is symmetric? --> the classical modified Lorentz-Berthelot rule (the present one) is symmetric. No other rule is implemented so far and probably will never be..._mixcoeff
inSimulation.cpp:250
error prone#74
cid1
andcid2
values#75
#331
<mixing>
have no effectThere was already an attempt #76 for a fix but it was not merged but closed.
It would be elegant to use a lambda function for the application of the (here and here) rule to make it more generic. Unfortunately, I wasn't able to make it work due to the scopes here. Help is appreciated 😉The open points above would also be solved by applying the LB-specific lambda function in the Comp2Param.
Done