Conversation
There was a problem hiding this comment.
Good work!
- I don't like having both
R_AlfvenandR_Alfven_basicmethods, do we really need both these numbers in the code? - I don't think that
truncateInnerRadiusis a good place to checkRm_definitionvalue, probably we need some abstract class with two child classes to implement Rm calculation and use dynamic dispatch to actually get it's value. It would be much faster and more idiomatic. I know that you can find this "bad" snippets in the code but they are legacy and I wouldn't introduce this into new code. - Please fix git merge conflict
- Please remove
freddibinary
cpp/src/ns/ns_evolution.cpp
Outdated
|
|
||
|
|
||
| double FreddiNeutronStarEvolution::R_Magn_bozzo18() const { | ||
| const double chi_oblique_rad = double(chioblique()) * M_PI / 180.; |
There was a problem hiding this comment.
Why do you need this double() casting here?
cpp/src/ns/ns_evolution.cpp
Outdated
|
|
||
| double FreddiNeutronStarEvolution::R_Magn_bozzo18() const { | ||
| const double chi_oblique_rad = double(chioblique()) * M_PI / 180.; | ||
| const double alpha = 0.5; // как его взять честно??? его надо откуда-то вызвать |
cpp/src/ns/ns_evolution.cpp
Outdated
| //const vecd& H = Height();//почему так нельзя? | ||
| const double H_to_R_temp = h2rbozzo(); //временно |
There was a problem hiding this comment.
const vecd& H = Height(); is ok in terms of C++ but Freddi has non-physical vertical structure for inner part of the disc
cpp/src/ns/ns_evolution.cpp
Outdated
|
|
||
| //const vecd& H = Height();//почему так нельзя? | ||
| const double H_to_R_temp = h2rbozzo(); //временно | ||
| const bool sign_at_inf = 1; //sign on unfunuty should be minus |
There was a problem hiding this comment.
I don't like implicit integer to boolean type casting here
cpp/src/ns/ns_evolution.cpp
Outdated
| const double xbozzo_0 = R()[first()] / RCorrot; | ||
| const double fxbozzo_0 = parametr_bozzo * ( (1. - std::pow(xbozzo_0, 1.5) ) * m::pow<2>(std::cos(chi_oblique_rad)) + H_to_R_temp * (8. - 5. * std::pow(xbozzo_0, 1.5)) * m::pow<2>(std::sin(chi_oblique_rad))) - std::pow(xbozzo_0 * parametr_thetta, 3.5); | ||
|
|
||
| if (std::signbit(fxbozzo_0) == sign_at_inf){ |
There was a problem hiding this comment.
Is sign_at_inf will still be compilation time constant in the future? If yes, I would prefer just writing
if (std::signbit(fxbozzo_0)){ with the proper comment
| const double fxbozzo_0 = parametr_bozzo * ( (1. - std::pow(xbozzo_0, 1.5) ) * m::pow<2>(std::cos(chi_oblique_rad)) + H_to_R_temp * (8. - 5. * std::pow(xbozzo_0, 1.5)) * m::pow<2>(std::sin(chi_oblique_rad))) - std::pow(xbozzo_0 * parametr_thetta, 3.5); | ||
|
|
||
| if (std::signbit(fxbozzo_0) == sign_at_inf){ | ||
| return 0. ; |
cpp/include/ns/ns_arguments.hpp
Outdated
| double Bx, double hotspotarea, | ||
| double epsilonAlfven, double inversebeta, double Rdead, | ||
| double Bx, | ||
| const std::string& Rm_definition, double h2r_bozzo, double chi_oblique, |
cpp/src/ns/ns_evolution.cpp
Outdated
| return; | ||
| } | ||
| //const int Rm_definition = 1; | ||
| std::string Rmdef = Rmdefinition(); |
There was a problem hiding this comment.
Unnecessary copy, use constant reference instead
cpp/src/ns/ns_evolution.cpp
Outdated
| } | ||
| } | ||
| if (jj == last() - 2){ | ||
| std::cout<<"cannot find a root for R magnetosphere which is kinda weird\n"; |
There was a problem hiding this comment.
Printing something into standard input is not enough here. If is a logical error you should raise an exception
There was a problem hiding this comment.
Probably you should raise RadiusCollapseException()
|
|
hombit
left a comment
There was a problem hiding this comment.
Thank you for this comment, please see comments to individual code lines
|
|
||
| #include <boost/math/tools/roots.hpp> | ||
|
|
||
| #include <fstream> |
There was a problem hiding this comment.
Fstream is here for debugging process.
cpp/src/ns/ns_arguments.cpp
Outdated
|
|
||
|
|
||
| std::pair<double, double> r = boost::math::tools::toms748_solve( | ||
| [RC, RA, chi_oblique_rad, parametr_bozzo, H_to_R_temp](double omega) { return parametr_bozzo * (m::pow<2>(std::cos(chi_oblique_rad)) * (1 - omega) + H_to_R_temp * (11 - 8 * omega) * m::pow<2>(std::sin(chi_oblique_rad)) ) * std::pow(RA/RC, 3.5) - 0.5 * std::pow(omega, 10./3.); }, |
There was a problem hiding this comment.
Please avoid implicit type casting: use 1.0, 11.0, 8.0, etc
Please use line width up to 120 if possible
| const double alpha = 0.5; //поправить потом это дело | ||
| const double chi_oblique_rad = chi_oblique * M_PI / 180.; | ||
| const double parametr_bozzo = 1. * m::pow<2>(0.2) / alpha; | ||
| const double H_to_R_temp = h2r_bozzo; |
There was a problem hiding this comment.
Is it about alpha or something else?
cpp/src/ns/ns_arguments.cpp
Outdated
| const double RC = std::cbrt(GM / m::pow<2>(2*M_PI * freqx)); | ||
| const double alpha = 0.5; //поправить потом это дело | ||
| const double chi_oblique_rad = chi_oblique * M_PI / 180.; | ||
| const double parametr_bozzo = 1. * m::pow<2>(0.2) / alpha; |
| boost::math::tools::eps_tolerance<double> tol(10); | ||
|
|
||
|
|
||
| std::pair<double, double> r = boost::math::tools::toms748_solve( |
| @@ -93,6 +98,15 @@ std::shared_ptr<FreddiNeutronStarEvolution::BasicKappaT> FreddiNeutronStarEvolut | |||
|
|
|||
| vecd FreddiNeutronStarEvolution::NeutronStarStructure::initialize_Fmagn(FreddiEvolution* evolution) const { | |||
There was a problem hiding this comment.
Please consider reimplementing "Rmtype" processing in these three functions:
- Please add "kluznyak" to the description of --Rmtype parameter in
ns_options.cpp - In these function check all supported parameters explicitly, see
initializeNsMdotFractionfor an example - Raise an exception if "Rmtype" value is not supported
- Please modify pyton test "FmagnDerivativesTestCase" to check if derivatives are correct. It is located in
/python/test/test_ns.py
| // const double R_0 = std::max(R_Magn_KR07(), R_x); не нужно сейчас | ||
| const double k = inverse_beta * m::pow<2>(mu_magn) / 9.; | ||
| double brackets1, brackets2; | ||
| double Fmagn; |
There was a problem hiding this comment.
Please do not introduce uninitialized variables when possible
| public: | ||
| NeutronStarStructure(const NeutronStarArguments& args_ns, FreddiEvolution* evolution); | ||
| double R_Magn_KR07(FreddiEvolution* evolution) const; | ||
| double F_Magn_KR07(const double R) const; |
There was a problem hiding this comment.
You don't need const double specifier here, just double is fine
|
|
||
| if (Rmtype() == "Kluzniak" || Rmtype() == "kluzniak"){ | ||
| R_magnetic = std::max(R_Magn_KR07(), R_Mdot_slope_KR07()); | ||
| } |
There was a problem hiding this comment.
Please check explicitly if unknown Rmtype is used and raise and exception in this case. BTW, the better solution would be implementing it as a virtual class with subclasses and using a dynamical dispatch instead of string comparison. See *KappaT classes for an example
cpp/src/ns/ns_evolution.cpp
Outdated
| new_F_in = kappa_t(R_m) * m::pow<2>(mu_magn()) / m::pow<3>(R_m); | ||
| } | ||
| } else { | ||
| new_F_in = 0; |
There was a problem hiding this comment.
Why do we need it now? Was it broken before?
No description provided.