Skip to content

Added switch to change mixing rule for MW relaxation time. Fixing issue #310 - #311

Open
capriatim wants to merge 15 commits into
mutationpp:masterfrom
capriatim:master
Open

Added switch to change mixing rule for MW relaxation time. Fixing issue #310#311
capriatim wants to merge 15 commits into
mutationpp:masterfrom
capriatim:master

Conversation

@capriatim

Copy link
Copy Markdown
Collaborator

No description provided.

@capriatim
capriatim requested a review from grgbellasvki June 26, 2026 06:43
@mgoodson-cvd

Copy link
Copy Markdown
Collaborator

I've tested this and it seems to work as intended.

I have a few comments on the code, which I will post shortly. Nothing major though.

Comment thread src/transfer/MillikanWhite.cpp Outdated
// 1: Gnoffo, 1989
static int i_model = 0;

void setMillikanWhiteModel(int model)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be const int model

Comment thread src/transfer/MillikanWhite.cpp Outdated

// 0: orginal, default
// 1: Gnoffo, 1989
static int i_model = 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer enumerators here to make it more clear which is which, but not necessary.

Comment thread src/transfer/MillikanWhite.cpp Outdated
const Eigen::Map<const Eigen::ArrayXd> Xh(
thermo.X()+(thermo.hasElectrons() ? 1 : 0), thermo.nHeavy());

const Eigen::Map<const Eigen::ArrayXd> Yh(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yh is only used for imodel == 0, so I would move this inside the if statement to avoid unnecessary work when imodel == 1.

Comment thread src/transfer/MillikanWhite.cpp Outdated
const double tau_park = 1.0/(ni * ci * m_data.limitingCrossSection(thermo.T()));
double tau = 0;

if (i_model == 0) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While this approach works, it might be slow in practice because the if on imodel will have to be checked every time the Millikan-White term is needed. In a CFD code, where this is called for every cell on every iteration, this could be quite costly.

One alternative is to adopt the approach taken throughout M++, and use an object-oriented approach. Make an abstract base class for the Millikan-White model, with two concrete classes for the original and Gnoffo models. Then you can use a factory to construct the desired model.

Comment thread src/transfer/MillikanWhite.h Outdated
/// Set Millikan–White relaxation-time model
/// 0 = original (default)
/// 1 = Gnoffo (1989)
void setMillikanWhiteModel(int model);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be const.

Comment thread src/transfer/MillikanWhite.cpp Outdated

// 0: orginal, default
// 1: Gnoffo, 1989
static int i_model = 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be best to avoid floating static int for imodel. Could this be stored inside the MillikanWhiteModelData class instead?

Comment thread tests/c++/test_MillikanWhite.cpp Outdated
Mixture mix(opts);

const double thetav = 3408.464;
setMillikanWhiteModel(1); // Use Gnoffo (1989)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great that this still passes. Can you add a test for the original model?

@capriatim
capriatim requested a review from jbscoggi July 23, 2026 09:19
@capriatim

Copy link
Copy Markdown
Collaborator Author

Hi @jbscoggi,
I updated the CHANGELOG file to include changes from the last few years.
Could you please double-check that it is consistent with Mutation++ history?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants