GraviDy  1.0
Gravitational Dynamics N-body integrator
NbodyUtils.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016
3  *
4  * Cristián Maureira-Fredes <cmaureirafredes@gmail.com>
5  *
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright
16  * notice, this list of conditions and the following disclaimer in the
17  * documentation and/or other materials provided with the distribution.
18  *
19  * 3. The name of the author may not be used to endorse or promote
20  * products derived from this software without specific prior written
21  * permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
24  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
27  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
31  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
32  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
33  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35  */
36 #ifndef NBODYUTILS_HPP
37 #define NBODYUTILS_HPP
38 #include "../common.hpp"
39 #include "../NbodySystem.hpp"
40 
41 
49 class NbodyUtils {
50  public:
52  ~NbodyUtils();
53 
55  // Variables
56  float ratio;
59 
62  std::vector<Distance> radii;
63 
65  std::vector<double> layers_radii;
66 
67  void nbody_attributes();
68  void get_radii();
69  void get_layers();
70  void lagrange_radii();
71 
72  double get_virial_radius(double energy);
73  double get_close_encounter_radius(double r_virial);
74  double get_close_encounter_timestep(double r_cl);
75  double get_core_radius();
77  double get_crossing_time(double r_virial);
78  double get_halfmass_radius();
79  double get_magnitude(double x, double y, double z);
80  double get_timestep_normal(unsigned int i, float ETA);
81  double normalize_dt(double new_dt, double old_dt, double t, unsigned int i);
82 
83  double get_potential();
84  double get_kinetic();
85  double get_energy(double ext = 0);
86 
88 };
89 
90 #endif
void lagrange_radii()
Lagrange radii calculation.
Definition: NbodyUtils.cpp:265
~NbodyUtils()
Destructor.
Definition: NbodyUtils.cpp:50
double get_close_encounter_timestep(double r_cl)
Close encounter timestep calculation.
Definition: NbodyUtils.cpp:105
Class in charge of the general aspects of the N-body integrator.
Definition: NbodySystem.hpp:51
void get_layers()
Layers of the Lagrange radii calculation.
Definition: NbodyUtils.cpp:303
std::vector< Distance > radii
Radii array related to the center of density, and related to the percentage distribution that we want...
Definition: NbodyUtils.hpp:62
double3 cod
Center of density.
Definition: NbodyUtils.hpp:58
double3 get_center_of_density()
Center of density calculation.
Definition: NbodyUtils.cpp:165
double normalize_dt(double new_dt, double old_dt, double t, unsigned int i)
Normalization of the timestep.
Definition: NbodyUtils.cpp:374
double get_timestep_normal(unsigned int i, float ETA)
Time step calculation.
Definition: NbodyUtils.cpp:340
NbodySystem * ns
Definition: NbodyUtils.hpp:54
double get_magnitude(double x, double y, double z)
Vector magnitude calculation.
Definition: NbodyUtils.cpp:334
double get_kinetic()
Kinetic energy calculation.
Definition: NbodyUtils.cpp:495
double get_energy(double ext=0)
Kinetic and Potential energy calculation.
Definition: NbodyUtils.cpp:430
void nbody_attributes()
General method to get many N-body attributes.
Definition: NbodyUtils.cpp:59
float ratio
Definition: NbodyUtils.hpp:56
double get_close_encounter_radius(double r_virial)
Close encounter radius calculation.
Definition: NbodyUtils.cpp:99
NbodyUtils(NbodySystem *ns)
Constructor.
Definition: NbodyUtils.cpp:39
double get_core_radius()
Core radius calculation using CORE_MASS as limit point, and respect the center of mass of the system...
Definition: NbodyUtils.cpp:113
Defining the «double3» structure based on the CUDA definition for the CPU version, which not include the CUDA headers.
Definition: common.hpp:74
double get_virial_radius(double energy)
Virial radius calculation.
Definition: NbodyUtils.cpp:81
std::vector< double > layers_radii
values of the radii of the different layers
Definition: NbodyUtils.hpp:65
Class in charge of the different properties of the system.
Definition: NbodyUtils.hpp:49
double get_potential()
Potential energy calculation.
Definition: NbodyUtils.cpp:468
double get_crossing_time(double r_virial)
Crossing time calculation.
Definition: NbodyUtils.cpp:88
double get_halfmass_radius()
Half mass radius calculation.
Definition: NbodyUtils.cpp:225
double get_half_mass_relaxation_time()
Half mass relaxation time calculation.
Definition: NbodyUtils.cpp:151
void get_radii()
Radii respect the center of density calculation, to be able to calculate the layers of the Lagrange r...
Definition: NbodyUtils.cpp:285