-
Notifications
You must be signed in to change notification settings - Fork 69
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
Uf23 #490
Merged
Merged
Uf23 #490
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ca66f94
first version
MichaelUnger f658083
units
MichaelUnger c8d8b3e
tests
MichaelUnger fba3a8c
example of how to initialize UF23 field (commented)
MichaelUnger 8fcce26
Lukas' suggestions
MichaelUnger 1d723d0
Merge branch 'master' into UF23
lukasmerten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
#ifndef _UF23Field_h_ | ||
#define _UF23Field_h_ | ||
|
||
#include <vector> | ||
#include "crpropa/magneticField/MagneticField.h" | ||
|
||
namespace crpropa { | ||
/** | ||
* \addtogroup MagneticFields | ||
* @{ | ||
*/ | ||
|
||
|
||
/** | ||
@class UF23Field | ||
@brief UF23Field Galactic magnetic field model | ||
|
||
Implements the eight coherent magnetic field models of UF23 | ||
See: M. Unger and G.R. Farrar, arXiv:2311.12120 | ||
|
||
Assumes a galactocentric coordinate system with the Galactic center | ||
at the origin, the x-axis pointing in the opposite direction of the | ||
Sun, and the z-axis pointing towards Galactic North. | ||
|
||
*/ | ||
|
||
class UF23Field : public MagneticField { | ||
public: | ||
/// model variations (see Tab.2 of UF23 paper) | ||
enum ModelType { | ||
base, | ||
neCL, | ||
expX, | ||
spur, | ||
cre10, | ||
synCG, | ||
twistX, | ||
nebCor | ||
}; | ||
|
||
|
||
public: | ||
/** | ||
@brief constructor | ||
@param mt model type (see Tab.2 of UF23 paper) | ||
@param maxRadiusInKpc maximum radius of field in kpc | ||
*/ | ||
UF23Field(const ModelType mt); | ||
/// no default constructor | ||
UF23Field() = delete; | ||
|
||
Vector3d getField(const Vector3d& pos) const; | ||
|
||
private: | ||
|
||
/** | ||
@brief calculate coherent magnetic field at a given position | ||
@param posInKpc position with components given in kpc | ||
@return coherent field in microgauss | ||
*/ | ||
Vector3d operator()(const Vector3d& posInKpc) const; | ||
|
||
/// model parameters, see Table 3 of UF23 paper | ||
enum EPar { | ||
eDiskB1 = 0, | ||
eDiskB2, | ||
eDiskB3, | ||
eDiskH, | ||
eDiskPhase1, | ||
eDiskPhase2, | ||
eDiskPhase3, | ||
eDiskPitch, | ||
eDiskW, | ||
ePoloidalA, | ||
ePoloidalB, | ||
ePoloidalP, | ||
ePoloidalR, | ||
ePoloidalW, | ||
ePoloidalZ, | ||
ePoloidalXi, | ||
eSpurCenter, | ||
eSpurLength, | ||
eSpurWidth, | ||
eStriation, | ||
eToroidalBN, | ||
eToroidalBS, | ||
eToroidalR, | ||
eToroidalW, | ||
eToroidalZ, | ||
eTwistingTime, | ||
eNpar | ||
}; | ||
|
||
/// model type given in constructor | ||
const ModelType fModelType; | ||
/// maximum galacto-centric radius beyond which B=0 | ||
const double fMaxRadiusSquared; | ||
|
||
// parameters are stored in array | ||
double fParameters[eNpar] = { 0 }; | ||
// references to parameters for convience | ||
double& fDiskB1 = fParameters[eDiskB1]; | ||
double& fDiskB2 = fParameters[eDiskB2]; | ||
double& fDiskB3 = fParameters[eDiskB3]; | ||
double& fDiskH = fParameters[eDiskH]; | ||
double& fDiskPhase1 = fParameters[eDiskPhase1]; | ||
double& fDiskPhase2 = fParameters[eDiskPhase2]; | ||
double& fDiskPhase3 = fParameters[eDiskPhase3]; | ||
double& fDiskPitch = fParameters[eDiskPitch]; | ||
double& fDiskW = fParameters[eDiskW]; | ||
double& fPoloidalA = fParameters[ePoloidalA]; | ||
double& fPoloidalB = fParameters[ePoloidalB]; | ||
double& fPoloidalP = fParameters[ePoloidalP]; | ||
double& fPoloidalR = fParameters[ePoloidalR]; | ||
double& fPoloidalW = fParameters[ePoloidalW]; | ||
double& fPoloidalZ = fParameters[ePoloidalZ]; | ||
double& fPoloidalXi = fParameters[ePoloidalXi]; | ||
double& fSpurCenter = fParameters[eSpurCenter]; | ||
double& fSpurLength = fParameters[eSpurLength]; | ||
double& fSpurWidth = fParameters[eSpurWidth]; | ||
double& fStriation = fParameters[eStriation]; | ||
double& fToroidalBN = fParameters[eToroidalBN]; | ||
double& fToroidalBS = fParameters[eToroidalBS]; | ||
double& fToroidalR = fParameters[eToroidalR]; | ||
double& fToroidalW = fParameters[eToroidalW]; | ||
double& fToroidalZ = fParameters[eToroidalZ]; | ||
double& fTwistingTime = fParameters[eTwistingTime]; | ||
|
||
// some pre-calculated derived parameter values | ||
double fSinPitch = 0; | ||
double fCosPitch = 0; | ||
double fTanPitch = 0; | ||
|
||
/// major field components | ||
Vector3d getDiskField(const Vector3d& pos) const; | ||
Vector3d getHaloField(const Vector3d& pos) const; | ||
|
||
/// sub-components depending on model type | ||
/// -- Sec. 5.2.2 | ||
Vector3d getSpiralField(const double x, const double y, const double z) const; | ||
/// -- Sec. 5.2.3 | ||
Vector3d getSpurField(const double x, const double y, const double z) const; | ||
/// -- Sec. 5.3.1 | ||
Vector3d getToroidalHaloField(const double x, const double y, const double z) const; | ||
/// -- Sec. 5.3.2 | ||
Vector3d getPoloidalHaloField(const double x, const double y, const double z) const; | ||
/// -- Sec. 5.3.3 | ||
Vector3d getTwistedHaloField(const double x, const double y, const double z) const; | ||
|
||
}; | ||
/** @} */ | ||
} // namespace crpropa | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You probably chose to not provide a default model because none of the models yielded a significantly better fit than the others, right?
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.
Yes, I think that not providing a default model makes the user aware that this is a collection of 8 models to choose from.