Skip to content
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

Momentum Diffusion #444

Merged
merged 7 commits into from
Oct 23, 2023
Merged

Conversation

lukasmerten
Copy link
Member

This is a rewrite of the content of PR #279, which will be closed.

The module introduces a momentum diffusion module, that allows to treat 2nd order Fermi acceleration in the ensemble averaged picture. It is meant to be used together with the DiffusionSDE module. In the future the module can be extended to include more complicated dependencies of the momentum diffusion scalar.

Unit tests and documentation / example code are included.

@lukasmerten lukasmerten mentioned this pull request Oct 17, 2023
return; // Only charged particles
}

double p = c->current.getEnergy()/c_light; // Note we use E=p/c (relativistic limit)
Copy link
Member

Choose a reason for hiding this comment

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

add spaces:
getEnergy() / c_light

double BScal = calculateBScalar();

double dp = AScal * dt + BScal * domega;
c->current.setEnergy((p + dp)*c_light);
Copy link
Member

Choose a reason for hiding this comment

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

Add spaces between parenthesis and c_light.

}

double ConstantMomentumDiffusion::calculateAScalar(double p) const {
double a = + 2./p * Dpp;
Copy link
Member

Choose a reason for hiding this comment

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

Follow CRPropa convention and add white spaces around /

std::string ConstantMomentumDiffusion::getDescription() const {
std::stringstream s;
s << "limit: " << limit << "\n";
s << "Dpp: " << Dpp / (meter*meter/second) << " m^2/s";
Copy link
Member

Choose a reason for hiding this comment

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

Add white spaces, following CRPropa's convention.

using namespace crpropa;

ConstantMomentumDiffusion::ConstantMomentumDiffusion(double Dpp) {
setLimit(0.1);
Copy link
Member

Choose a reason for hiding this comment

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

Wouldn't it make sense to allow the user to control the limit, as done in the other modules?

@rafaelab
Copy link
Member

Hi @lukasmerten
Thanks for this update. It runs just fine in my laptop, and so does the example notebook.
I left a few (very minor) comments regarding CRPropa's style convention.
I also left a comment about the limit option in this module, if we want to leave it as a keyword argument with default value as in other modules.

@lukasmerten
Copy link
Member Author

@rafaelab I adressed all your style convention comments and added a new constructor that allows for direct setting of the limit parameter. Let me know if there is anything else that needs to be done.

@rafaelab rafaelab merged commit 2c7e55b into CRPropa:master Oct 23, 2023
1 of 3 checks passed
@lukasmerten lukasmerten deleted the ConstantMomentumDiffusion branch November 8, 2023 08:43
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