Skip to content

Commit

Permalink
Updates for dt_save with unperturbed tracing.
Browse files Browse the repository at this point in the history
  • Loading branch information
ejpaul committed Sep 24, 2024
1 parent 6c34b2e commit 93309dc
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/simsopt/field/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def trace_particles_boozer(field: BoozerMagneticField, stz_inits: RealArray,
res_ty, res_zeta_hit = sopp.particle_guiding_center_boozer_tracing(
field, stz_inits[i, :],
m, charge, speed_total[i], speed_par[i], tmax, vacuum=(mode == 'gc_vac'),
noK=(mode == 'gc_nok'), zetas=zetas, omegas=omegas, vpars=vpars, stopping_criteria=stopping_criteria, dt_save=dt_save,
noK=(mode == 'gc_nok'), zetas=zetas, omegas=omegas, stopping_criteria=stopping_criteria, dt_save=dt_save, vpars=vpars,
**options)
if not forget_exact_path:
res_tys.append(np.asarray(res_ty))
Expand Down
8 changes: 4 additions & 4 deletions src/simsoptpp/python_tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ void init_tracing(py::module_ &m){
py::arg("omegas")=vector<double>{},
py::arg("stopping_criteria")=vector<shared_ptr<StoppingCriterion>>{},
py::arg("dt_save")=1e-6,
py::arg("forget_exact_path")=false,
py::arg("axis")=0,
py::arg("predictor_step")=true,
py::arg("vpars")=vector<double>{},
py::arg("zetas_stop")=false,
py::arg("vpars_stop")=false,
py::arg("vpars")=vector<double>{}
py::arg("forget_exact_path")=false,
py::arg("axis")=0,
py::arg("predictor_step")=true
);

m.def("particle_guiding_center_boozer_perturbed_tracing", &particle_guiding_center_boozer_perturbed_tracing<xt::pytensor>,
Expand Down
14 changes: 8 additions & 6 deletions src/simsoptpp/tracing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,15 +1201,14 @@ particle_guiding_center_boozer_tracing(
shared_ptr<BoozerMagneticField<T>> field, array<double, 3> stz_init,
double m, double q, double vtotal, double vtang, double tmax, double dt, double abstol, double reltol, double roottol,
bool vacuum, bool noK, bool solveSympl, vector<double> zetas, vector<double> omegas,
vector<shared_ptr<StoppingCriterion>> stopping_criteria, double dt_save, bool forget_exact_path, int axis, bool predictor_step,
bool zetas_stop, bool vpars_stop, vector<double> vpars)
vector<shared_ptr<StoppingCriterion>> stopping_criteria, double dt_save, vector<double> vpars,
bool zetas_stop, bool vpars_stop, bool forget_exact_path, int axis, bool predictor_step)
{
typename BoozerMagneticField<T>::Tensor2 stz({{stz_init[0], stz_init[1], stz_init[2]}});
field->set_points(stz);
double modB = field->modB()(0);
double vperp2 = vtotal*vtotal - vtang*vtang;
double mu = vperp2/(2*modB);

array<double, 4> y;

double G0 = std::abs(field->G()(0));
Expand Down Expand Up @@ -1273,6 +1272,9 @@ particle_guiding_center_boozer_perturbed_tracing<xt::pytensor>(
double omega, int Phim, int Phin, double phase, bool forget_exact_path, int axis, vector<double> vpars);

template
tuple<vector<array<double, 5>>, vector<array<double, 6>>>
particle_guiding_center_boozer_tracing<xt::pytensor>(
shared_ptr<BoozerMagneticField<xt::pytensor>> field, array<double, 3> stz_init, double m, double q, double vtotal, double vtang, double tmax, double dt, double abstol, double reltol, double roottol, bool vacuum, bool noK, bool solveSympl, vector<double> zetas, vector<double> omegas, vector<shared_ptr<StoppingCriterion>> stopping_criteria, double dt_save, bool forget_exact_path, int axis, bool predictor_step, bool zetas_stop, bool vpars_stop, vector<double> vpars);
tuple<vector<array<double, 5>>, vector<array<double, 6>>> particle_guiding_center_boozer_tracing<xt::pytensor>(
shared_ptr<BoozerMagneticField<xt::pytensor>> field, array<double, 3> stz_init,
double m, double q, double vtotal, double vtang, double tmax, double dt, double abstol, double reltol, double roottol,
bool vacuum, bool noK, bool solveSympl, vector<double> zetas, vector<double> omegas,
vector<shared_ptr<StoppingCriterion>> stopping_criteria, double dt_save,
vector<double> vpars, bool zetas_stop, bool vpars_stop, bool forget_exact_path, int axis, bool predictor_step);
14 changes: 6 additions & 8 deletions src/simsoptpp/tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ particle_guiding_center_boozer_perturbed_tracing(
double alphahat=0, double omega=0, int alpham=0, int alphan=0, double phase=0,
bool forget_exact_path=false, int axis=0, vector<double> vpars={});

template<template<class, std::size_t, xt::layout_type> class T>
tuple<vector<array<double, 5>>, vector<array<double, 6>>>
particle_guiding_center_boozer_tracing(
shared_ptr<BoozerMagneticField<T>> field, array<double, 3> stz_init,
template<template<class, std::size_t, xt::layout_type> class T>
tuple<vector<array<double, 5>>, vector<array<double, 6>>>
particle_guiding_center_boozer_tracing(
shared_ptr<BoozerMagneticField<T>> field, array<double, 3> stz_init,
double m, double q, double vtotal, double vtang, double tmax, double dt, double abstol, double reltol, double roottol,
bool vacuum, bool noK, bool solveSympl, vector<double> zetas, vector<double> omegas, vector<shared_ptr<StoppingCriterion>> stopping_criteria, double dt_save = 1e-6,
bool forget_exact_path=false, int axis=0, bool predictor_step=true,
bool zetas_stop=false, bool vpars_stop=false, vector<double> vpars={});

bool vacuum, bool noK, bool solveSympl, vector<double> zetas, vector<double> omegas,
vector<shared_ptr<StoppingCriterion>> stopping_criteria, double dt_save, vector<double> vpars, bool zetas_stop=false, bool vpars_stop=false, bool forget_exact_path=false, int axis=0, bool predictor_step=true);

0 comments on commit 93309dc

Please sign in to comment.