Skip to content

oblique#48

Open
lisdanil wants to merge 11 commits intohombit:masterfrom
lisdanil:dev
Open

oblique#48
lisdanil wants to merge 11 commits intohombit:masterfrom
lisdanil:dev

Conversation

@lisdanil
Copy link

No description provided.

@hombit hombit self-requested a review November 8, 2021 17:06
Copy link
Owner

@hombit hombit left a comment

Choose a reason for hiding this comment

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

Good work!

  1. I don't like having both R_Alfven and R_Alfven_basic methods, do we really need both these numbers in the code?
  2. I don't think that truncateInnerRadius is a good place to check Rm_definition value, 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.
  3. Please fix git merge conflict
  4. Please remove freddi binary



double FreddiNeutronStarEvolution::R_Magn_bozzo18() const {
const double chi_oblique_rad = double(chioblique()) * M_PI / 180.;
Copy link
Owner

Choose a reason for hiding this comment

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

Why do you need this double() casting here?

Choose a reason for hiding this comment

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

done


double FreddiNeutronStarEvolution::R_Magn_bozzo18() const {
const double chi_oblique_rad = double(chioblique()) * M_PI / 180.;
const double alpha = 0.5; // как его взять честно??? его надо откуда-то вызвать
Copy link
Owner

Choose a reason for hiding this comment

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

args().basic->alpha

Choose a reason for hiding this comment

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

done

Comment on lines 517 to 518
//const vecd& H = Height();//почему так нельзя?
const double H_to_R_temp = h2rbozzo(); //временно
Copy link
Owner

Choose a reason for hiding this comment

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

const vecd& H = Height(); is ok in terms of C++ but Freddi has non-physical vertical structure for inner part of the disc


//const vecd& H = Height();//почему так нельзя?
const double H_to_R_temp = h2rbozzo(); //временно
const bool sign_at_inf = 1; //sign on unfunuty should be minus
Copy link
Owner

Choose a reason for hiding this comment

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

I don't like implicit integer to boolean type casting here

Choose a reason for hiding this comment

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

done

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){
Copy link
Owner

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

done

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. ;
Copy link
Owner

Choose a reason for hiding this comment

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

Does zero Rmagn have any sense?

Choose a reason for hiding this comment

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

i wrote a comment

double Bx, double hotspotarea,
double epsilonAlfven, double inversebeta, double Rdead,
double Bx,
const std::string& Rm_definition, double h2r_bozzo, double chi_oblique,
Copy link
Owner

Choose a reason for hiding this comment

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

Consider to rename to Rm_type

Copy link
Owner

Choose a reason for hiding this comment

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

BTW, is it actually used?

Choose a reason for hiding this comment

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

done

return;
}
//const int Rm_definition = 1;
std::string Rmdef = Rmdefinition();
Copy link
Owner

Choose a reason for hiding this comment

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

Unnecessary copy, use constant reference instead

}
}
if (jj == last() - 2){
std::cout<<"cannot find a root for R magnetosphere which is kinda weird\n";
Copy link
Owner

Choose a reason for hiding this comment

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

Printing something into standard input is not enough here. If is a logical error you should raise an exception

Copy link
Owner

Choose a reason for hiding this comment

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

Probably you should raise RadiusCollapseException()

Choose a reason for hiding this comment

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

done

@hombit
Copy link
Owner

hombit commented Nov 12, 2021

R_Alfven_basic -> R_Alfven
R_Alfven -> something like R_magn

Copy link
Owner

@hombit hombit left a comment

Choose a reason for hiding this comment

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

Thank you for this comment, please see comments to individual code lines


#include <boost/math/tools/roots.hpp>

#include <fstream>
Copy link
Owner

Choose a reason for hiding this comment

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

Why do you need fstream here?

Copy link
Author

Choose a reason for hiding this comment

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

Fstream is here for debugging process.



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.); },
Copy link
Owner

Choose a reason for hiding this comment

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

Please avoid implicit type casting: use 1.0, 11.0, 8.0, etc

Please use line width up to 120 if possible

Copy link
Author

Choose a reason for hiding this comment

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

Done.

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;
Copy link
Owner

Choose a reason for hiding this comment

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

Why do you need this variable?

Copy link
Author

Choose a reason for hiding this comment

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

Is it about alpha or something else?

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;
Copy link
Owner

Choose a reason for hiding this comment

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

Please comment this "1. * "

Copy link
Author

Choose a reason for hiding this comment

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

It has been removed.

boost::math::tools::eps_tolerance<double> tol(10);


std::pair<double, double> r = boost::math::tools::toms748_solve(
Copy link
Owner

Choose a reason for hiding this comment

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

Could be const

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@@ -93,6 +98,15 @@ std::shared_ptr<FreddiNeutronStarEvolution::BasicKappaT> FreddiNeutronStarEvolut

vecd FreddiNeutronStarEvolution::NeutronStarStructure::initialize_Fmagn(FreddiEvolution* evolution) const {
Copy link
Owner

Choose a reason for hiding this comment

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

Please consider reimplementing "Rmtype" processing in these three functions:

  1. Please add "kluznyak" to the description of --Rmtype parameter in ns_options.cpp
  2. In these function check all supported parameters explicitly, see initializeNsMdotFraction for an example
  3. Raise an exception if "Rmtype" value is not supported
  4. 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;
Copy link
Owner

Choose a reason for hiding this comment

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

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;
Copy link
Owner

Choose a reason for hiding this comment

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

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());
}
Copy link
Owner

Choose a reason for hiding this comment

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

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

new_F_in = kappa_t(R_m) * m::pow<2>(mu_magn()) / m::pow<3>(R_m);
}
} else {
new_F_in = 0;
Copy link
Owner

Choose a reason for hiding this comment

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

Why do we need it now? Was it broken before?

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.

3 participants