choreo.NBodySyst.Set_inter_law#
- NBodySyst.Set_inter_law(self, inter_law=None, inter_law_str=None, inter_law_param_dict=None)#
Sets the interaction law of the system.
There are several ways to set the interaction law:
- Through inter_law. This argument can be:
- A C function with signature
void (double, double *, void *)
. The first argument denotes the squared inter-body distance : \(\Delta x^2 = \sum_{i=0}^{\text{geodim}-1} \Delta x_i^2\)
The second argument denotes an array of
numpy.float64
with 3 elements. The function should write the value of the interaction, its first, and its second derivative to the first, second, and third elements of this array respectively. WARNING : These derivatives should be understood with respect to the variable \(\Delta x^2\), namely the squared inter-body distance.The third argument denotes a pointer to parameters that can be used during the computation.
- A C function with signature
A Python function that will be compiled to a C function using Numba if available on the user’s system. For performance reasons, using pure Python functions is not allowed. The arguments are similar to the ones defined above in the case of a C function. For instance, the following function defines the Newtonian gravitational potential:
def inter_law(xsq, res, ptr): a = xsq ** (-2.5) b = xsq*a res[0] = -xsq*b res[1]= 0.5*b res[2] = (-0.75)*a
- Through inter_law_str, whose possible values are:
"gravity_pot"
: the potential is the classical Newtonian gravitational potential: \(V(x) = \frac{1}{x}\)"power_law_pot"
: the potential is a power law : \(V(x) = x^n\). Its parameters should be given through thedict
inter_law_param_dict with key “n”.A string defining a Python function to be compiled with Numba . The process is similar to passing a Python function directly as described above.
If both inter_law and inter_law_str are
None
, the interaction law is the classical gravitational potential.
- Parameters:
inter_law (optional) – Function defining the interaction law, by default
None
.inter_law_str (
str
, optional) – Description of the interaction law dictating the dynamics of the system, by defaultNone
.inter_law_param_dict (
dict
, optional) – Parameters pertaining to the interaction law, by defaultNone
.