Models

class models.Model.EnergyNet(dim, neurons, layers, batch_size)

Bases: Module

forward(x)

The forward function takes an input x, applies a series of dense and activation layers, and returns the output.

Parameters:

x – The parameter x represents the input to the neural network. It is passed through the input dense layer, followed by a softplus activation function. Then, it is passed through a series of hidden layers, each followed by a softplus activation function. Finally, the output is obtained by passing through the output layer.

Returns:

The output of the forward pass through the neural network model.

class models.Model.TensorNet(dim, neurons, layers, batch_size)

Bases: Module

forward(x)

The forward function takes an input tensor, applies a series of operations including dense layers and activation functions, and returns an output tensor.

Parameters:

x – The parameter x is the input to the forward function.

Returns:

the variable “output”.

class models.Model.JacVectorNet(dim, neurons, layers, batch_size)

Bases: Module

forward(inp)

The forward function takes an input, applies a series of operations to it, and returns the product of the output and the gradient of the Cassimir term with respect to the input, as well as the Cassimir term itself.

Parameters:

inp – The inp parameter represents the input to the forward method. It is the input data that will be passed through the neural network

Returns:

two values: multi * cass_grad and cass.

class models.RigidBody.RigidBody(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha, T=100, verbose=False)

Bases: object

energy_x()

The function calculates the energy of an object in the x-direction. :return: the value of 0.5 times the square of the variable self.mx, divided by the variable self.Ix.

energy_y()

The function calculates the energy of an object in the y-direction. :return: the value of the expression 0.5*self.my*self.my/self.Iy.

energy_z()

The function calculates the energy of an object rotating around the z-axis. :return: the value of the expression 0.5*self.mz*self.mz/self.Iz.

energy()

The function calculates the kinetic energy of an object based on its mass and moments of inertia. :return: the kinetic energy of the object.

omega_x()

The function calculates the angular velocity around the x-axis. :return: The value of self.mx/self.Ix is being returned.

omega_y()

The function calculates the omega_y value by dividing my by Iy. :return: the value of self.my divided by self.Iy.

omega_z()

The function calculates the angular velocity around the z-axis. :return: the value of self.mz/self.Iz.

m2()

The function calculates the square of the magnitude of a vector. :return: the square of the magnitude of a vector.

mx2()

The function mx2 returns the value of mx squared. :return: the value of mx^2.

my2()

The function my2 returns the square of the value of self.my. :return: the square of the value of the variable “my”.

mz2()

The function mz2 returns the square of the value of mz. :return: the square of the value of mz.

m_magnitude()

The function returns the magnitude of a vector. :return: The magnitude of the vector, represented by the variable “m”.

Ein()

The function returns the normalized internal energy. :return: the normalized internal energy.

Ein_s()

The function returns the normalized derivative of internal energy with respect to entropy. :return: the normalized derivative of internal energy with respect to entropy (inverse temperature).

ST(T)

The function calculates the entropy of a Copper body with a characteristic volume equal to one (Debye) at a given temperature.

Parameters:

T – T is the temperature of the Copper body in Kelvin (K)

Returns:

the entropy of a Copper body with a characteristic volume equal to one (Debye) at a given temperature T.

Etot()

The function Etot returns the sum of the energy and the input energy. :return: the sum of the energy and the input energy, both of which are being calculated by other methods.

Sin()

The intenral entropy function returns the normalized internal entropy. :return: the normalized internal entropy.

S_x()

The function calculates the kinetic entropy for rotation around the x-axis. :return: the kinetic entropy for rotation around the x-axis.

S_z()

The function calculates the kinetic entropy for rotation around the z-axis. :return: the kinetic entropy for rotation around the z-axis.

Phi_x()

The function Phi_x returns the sum of the energy and the S_x potential for rotation around the x-axis. :return: the sum of the energy and the S_x value.

Phi_z()

The function Phi_z returns the sum of the energy and the S_z value. :return: the sum of the results of two other functions: self.energy() and self.S_z().

get_L(m)

The function get_L returns a 3x3 matrix L (Poisson bivector) based on the input parameter m.

Parameters:

m – The parameter “m” is a scalar value

Returns:

The function get_L returns a 3x3 numpy array L which is calculated using the values of self.mx, self.my, and self.mz.

get_E(m)

The function “get_E” returns the energy of an object.

Parameters:

m – The parameter “m” is not used in the code snippet provided. It is not clear what it represents or how it is related to the function

Returns:

The method get_E is returning the result of the method energy() called on the object self.

class models.RigidBody.RBEhrenfest(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha)

Bases: RigidBody

m_new(with_entropy=False)

The function m_new calculates and returns a new value for the angular momentum m based on the current values of mx, my, and mz, as well as other variables and matrices.

Parameters:

with_entropy – The parameter “with_entropy” is a boolean flag that determines whether or not to include entropy in the calculation of the new angular momentum. If it is set to True, entropy will be included in the calculation. If it is set to False (the default value), entropy will not be included, defaults to False (optional)

Returns:

the updated value of the angular momentum vector, m_new.

class models.RigidBody.RBESeReCN(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha)

Bases: RigidBody

f(mNew)

The function f calculates the difference between the old and new values of m and returns the result.

Parameters:

mNew – The parameter mNew represents the new value of the vector m in the function f

Returns:

a tuple containing the values of res[0], res[1], and res[2].

m_new(with_entropy=False)

The function m_new calculates and returns new values for mx, my, and mz, and updates the corresponding variables in the class instance.

Parameters:

with_entropy – The “with_entropy” parameter is a boolean flag that determines whether or not to include entropy in the calculation of the new angular momentum. If set to True, entropy will be considered in the calculation. If set to False, entropy will not be considered, defaults to False (optional)

Returns:

the updated values of mx, my, and mz as a tuple.

class models.RigidBody.RBIMR(Ix, Iy, Iz, d2E, mx, my, mz, dt)

Bases: RigidBody

f(mNew)

The function f calculates the residual of a given angular field vector mNew by using the previous angular field vector mOld and other variables.

Parameters:

mNew – The parameter mNew represents the new values of the angular field components mx, my, and mz

Returns:

a tuple containing the values of res[0], res[1], and res[2].

m_new(with_entropy=False)

The function m_new calculates and returns new values for mx, my, and mz, and updates the corresponding variables in the class.

Parameters:

with_entropy – The “with_entropy” parameter is a boolean flag that determines whether or not to include entropy in the calculation of the new value of m. If set to True, entropy will be considered in the calculation. If set to False, entropy will not be considered, defaults to False (optional)

Returns:

the updated values of mx, my, and mz as a tuple.

class models.RigidBody.RBESeReFE(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha)

Bases: RigidBody

m_new(with_entropy=False)

The function m_new calculates the new value of the angular momentum m based on the old value mOld and updates the values of mx, my, and mz, and optionally calculates the new entropy if with_entropy is True.

Parameters:

with_entropy – A boolean parameter that determines whether or not to calculate the new entropy using explicit forward Euler. If set to True, the entropy will be calculated and updated. If set to False, the entropy will not be calculated, defaults to False (optional)

Returns:

the updated value of the angular momentum vector, m.

class models.RigidBody.Neural(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha, method='without', name='.')

Bases: RigidBody

neural_zdot(z)

The function neural_zdot calculates the Hamiltonian of a neural network given a set of input values.

Parameters:

z – The parameter z is the input to the neural_zdot function. It is a tensor or array that represents the input data for the neural network.

Returns:

the hamiltonian, which is a numpy array.

f(mNew)

The function f calculates the difference between two sets of values and returns the result.

Parameters:

mNew – The parameter mNew represents the new values of mx, my, and mz

Returns:

a tuple containing the values of res[0], res[1], and res[2].

get_cass(z)

The function get_cass takes in a parameter z, converts it to a tensor, passes it through a neural network J_net, and returns the output cass as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the neural network J_net. It is converted to a tensor using torch.tensor with a data type of torch.float32 and requires_grad set to True. The requires_grad flag

Returns:

the value of cass as a NumPy array.

get_L(z)

The function get_L takes a tensor z, passes it through a neural network L_net, and returns the output L as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the L_net neural network. It is converted to a tensor using torch.tensor with a data type of torch.float32. The requires_grad=True argument indicates that gradients will be computed for this

Returns:

the value of L, which is obtained by passing the input z through the L_net neural network and converting the result to a numpy array.

get_E(z)

The function get_E takes a parameter z, converts it to a tensor, passes it through a neural network called energy_net, and returns the resulting energy value.

Parameters:

z – The parameter z is a numerical input that is used as an input to the energy_net neural network. It is converted to a tensor using torch.tensor and is set to have a data type of torch.float32. The requires_grad=True argument indicates that gradients will

Returns:

the value of E, which is the output of the energy_net model when given the input z.

m_new(with_entropy=False)

The function m_new calculates new values for mx, my, and mz using the fsolve function and updates the corresponding variables.

Parameters:

with_entropy – The parameter “with_entropy” is a boolean flag that determines whether or not to include entropy in the calculation of the new value of m. If it is set to True, entropy will be considered in the calculation. If it is set to False, entropy will not be considered, defaults to False (optional)

Returns:

the updated values of mx, my, and mz as a tuple.

class models.RigidBody.RBNeuralIMR(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha, method='without', name='.')

Bases: Neural

f(mNew)

The function f calculates the difference between the old and new values of m and adds the product of the time step dt and the derivative of z to it.

Parameters:

mNew – The parameter mNew represents the new values of mx, my, and mz

Returns:

a tuple containing three values: res[0], res[1], and res[2].

class models.RigidBody.HeavyTopCN(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha, Mgl, init_rx, init_ry, init_rz)

Bases: RigidBody

get_E(m)

The function get_E calculates the total energy of an object by adding the energy of the object’s parent class and the product of the object’s mass, gravitational acceleration, and the dot product of the object’s position vector and a given vector.

Parameters:

m – The parameter m represents the mass of the object

Returns:

the sum of the energy calculated by the parent class (using the energy() method) and the dot product of self.r and self.chi, multiplied by self.Mgl.

get_L(m)

The function get_L returns a 6x6 numpy array L based on the input parameter m and the attributes self.mz, self.my, self.mx, and self.r.

Parameters:

m – The parameter m is not defined in the code snippet you provided. It is a variable that represents the moment of inertia.

Returns:

The function get_L returns a numpy array L which is a 6x6 matrix.

f(mrnew)

The function f calculates the residuals for a given set of input variables.

Parameters:

mrnew – The parameter mrnew is a tuple containing the values for mNew and rNew

Returns:

a tuple containing the values of m_res[0], m_res[1], m_res[2], r_res[0], r_res[1], and r_res[2].

m_new(with_entropy=False)

The function m_new calculates new values for mx, my, mz, and r using the fsolve function and returns the updated values.

Parameters:

with_entropy – The parameter “with_entropy” is a boolean flag that determines whether or not to include entropy in the calculation. If it is set to True, entropy will be included in the calculation. If it is set to False, entropy will not be included, defaults to False (optional)

Returns:

a tuple containing the updated values of (self.mx, self.my, self.mz) and self.r.

class models.RigidBody.HeavyTopIMR(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha, Mgl, init_rx, init_ry, init_rz)

Bases: HeavyTopCN

f(mrnew)

The function f calculates the residuals for a given set of inputs and returns them as a tuple.

Parameters:

mrnew – The parameter mrnew is a list or tuple containing the following elements:

Returns:

a tuple containing the values of m_res[0], m_res[1], m_res[2], r_res[0], r_res[1], and r_res[2].

class models.RigidBody.HeavyTopNeural(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha, Mgl, init_rx, init_ry, init_rz, method='without', name='.')

Bases: HeavyTopCN

neural_zdot(z)

The neural_zdot function calculates the Hamiltonian of a neural network given a set of input values.

Parameters:

z – The parameter z is the input to the neural_zdot function. It is expected to be a numerical value or an array-like object that can be converted to a tensor

Returns:

The function neural_zdot returns the variable hamiltonian.

f(mrNew)

The function f calculates the difference between the old and new values of mr and adds the average of the neural network outputs for the old and new values multiplied by the time step.

Parameters:

mrNew – mrNew is a list containing the new values for the variables mx, my, mz, rx, ry, and rz

Returns:

the result of the calculation, which is stored in the variable “res”.

get_cass(z)

The function get_cass takes in a parameter z, converts it to a tensor, passes it through a neural network J_net, and returns the output cass as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the neural network. It is converted to a tensor using torch.tensor with a data type of torch.float32. The requires_grad=True argument indicates that gradients will be computed for this tensor during backprop

Returns:

the value of cass as a NumPy array.

get_L(z)

The function get_L takes a tensor z, passes it through a neural network L_net, and returns the output L as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the L_net neural network. It is converted to a tensor using torch.tensor and is set to have a data type of torch.float32. The requires_grad=True argument indicates that gradients will

Returns:

the value of L, which is obtained by passing the input z through the L_net neural network and converting the result to a numpy array.

get_E(z)

The function get_E takes a parameter z, converts it to a tensor, passes it through a neural network called energy_net, and returns the resulting energy value.

Parameters:

z – The parameter z is a numerical input that is used as an input to the energy_net neural network. It is converted to a tensor using torch.tensor and is set to have a data type of torch.float32. The requires_grad=True argument indicates that gradients will

Returns:

the value of E, which is the output of the energy_net model when given the input z.

m_new(with_entropy=False)

The function m_new calculates new values for mx, my, mz, and r based on the current values and returns the updated values.

Parameters:

with_entropy – The with_entropy parameter is a boolean flag that determines whether or not to include entropy in the calculation. If with_entropy is set to True, entropy will be included in the calculation. If with_entropy is set to False (default), entropy will not be included, defaults to False (optional)

Returns:

The function m_new returns a tuple containing the updated values of mx, my, mz (momefield components) and r (position vector).

class models.RigidBody.HeavyTopNeuralIMR(Ix, Iy, Iz, d2E, mx, my, mz, dt, alpha, Mgl, init_rx, init_ry, init_rz, method='without', name='.')

Bases: HeavyTopNeural

f(mrNew)

The function f calculates the difference between the old and new values of mr and adds the product of dt and the derivative of z with respect to mr.

Parameters:

mrNew – The parameter mrNew is a list or array containing the new values for mx, my, mz, and r

Returns:

the value of the variable “res”.

class models.RigidBody.Particle3DCN(M, dt, alpha, init_rx, init_ry, init_rz, init_mx, init_my, init_mz)

Bases: object

get_E(m)

The function get_E calculates the total energy E based on the input m and some constants M and alpha.

Parameters:

m – The parameter m is a list or tuple containing six elements. The elements represent the values of m[0], m[1], m[2], m[3], m[4], and m[5], where the first three give the position while the latter three position

Returns:

The function get_E returns the value of the expression 0.5*(m[3]**2 + m[4]**2 + m[5]**2)/self.M + 0.5 *self.alpha * (m[0]**2 + m[1]**2 + m[2]**2).

get_L(m=(0.0, 0.0, 0.0))

The function get_L returns a 6x6 numpy array representing a transformation matrix.

Parameters:

m – The parameter m is a tuple with three elements representing the x, y, and z coordinates respectively. The default value for m is (0.0, 0.0, 0.0)

Returns:

The function get_L returns a 6x6 numpy array L with the following values:

f(rpNew)

The function f calculates the residual of a given set of input parameters rpNew by performing a series of mathematical operations.

Parameters:

rpNew – The parameter rpNew is a list or array containing the new values of r and p. It should have a length of 6, where the first 3 elements represent the new values of r and the last 3 elements represent the new values of p

Returns:

a tuple containing the values of rpres[0], rpres[1], rpres[2], rpres[3], rpres[4], and rpres[5].

m_new()

The function m_new calculates new values for r and p using the fsolve function and returns the updated values.

Returns:

The function m_new returns a tuple containing two tuples. The first tuple contains the values (rx, ry, rz) and the second tuple contains the values (px, py, pz).

class models.RigidBody.Particle3DIMR(M, dt, alpha, init_rx, init_ry, init_rz, init_mx, init_my, init_mz)

Bases: Particle3DCN

f(rpNew)

The function f calculates the residual of a given input rpNew by performing a series of mathematical operations.

Parameters:

rpNew – The parameter rpNew is a numpy array that represents the new values of position and momentum. It has the following structure:

Returns:

a tuple containing the values of rpres[0], rpres[1], rpres[2], rpres[3], rpres[4], and rpres[5].

class models.RigidBody.Particle3DNeural(M, dt, alpha, init_rx, init_ry, init_rz, init_mx, init_my, init_mz, method='without', name='.')

Bases: Particle3DCN

neural_zdot(z)

The function neural_zdot calculates the Hamiltonian of a neural network model given a set of input parameters.

Parameters:

z – The parameter z is a tensor representing the input to the neural network. It is of type torch.Tensor and has a shape determined by the specific neural network architecture being used

Returns:

the Hamiltonian, which is a scalar value representing the energy of the system.

f(rpNew)

The function f calculates the residual of a given input rpNew by subtracting it from rpOld and adding the product of self.dt/2 and the sum of zdo and zd.

Parameters:

rpNew – The parameter rpNew is a numpy array that represents the new values of r and p

Returns:

the value of the variable “res”.

get_cass(z)

The function get_cass takes in a parameter z, converts it to a tensor, passes it through a neural network J_net, and returns the output cass as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the neural network. It is converted to a tensor using torch.tensor with a data type of torch.float32. The requires_grad=True argument indicates that gradients will be computed for this tensor during backprop

Returns:

the value of cass as a NumPy array.

get_L(z)

The function get_L takes a tensor z, passes it through a neural network L_net, and returns the output L as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the L_net neural network. It is converted to a tensor using torch.tensor with a data type of torch.float32. The requires_grad=True argument indicates that gradients will be computed with respect

Returns:

the value of L, which is obtained by passing the input z through the L_net neural network and converting the result to a numpy array.

get_E(z)

The function get_E takes a parameter z, converts it to a tensor, passes it through a neural network called energy_net, and returns the resulting energy value.

Parameters:

z – The parameter z is a numerical input that is used as an input to the energy_net neural network. It is converted to a tensor using torch.tensor and is set to have a data type of torch.float32. The requires_grad=True argument indicates that gradients will

Returns:

the value of E, which is the output of the energy_net model when given the input z.

m_new()

The function m_new calculates new values for r and p using the fsolve function and returns them as a tuple.

Returns:

a tuple containing the updated values of self.r and self.p.

class models.RigidBody.Particle3DNeuralIMR(M, dt, alpha, init_rx, init_ry, init_rz, init_mx, init_my, init_mz, method='without', name='.')

Bases: Particle3DNeural

f(rpNew)

The function f calculates the residual between the old and new values of rp and the time derivative of z using the midpoint method.

Parameters:

rpNew – rpNew is a numpy array that represents the new values of the variables r and p

Returns:

the value of the variable “res”.

class models.RigidBody.Particle3DKeplerIMR(M, dt, alpha, init_rx, init_ry, init_rz, init_mx, init_my, init_mz)

Bases: Particle3DIMR

f(rpNew)

The function f calculates the residual of a given set of inputs and returns it as a tuple.

Parameters:

rpNew – The parameter rpNew is a numpy array that represents the new values of position and momentum. It has a shape of (6,) and contains the following elements:

Returns:

a tuple containing the values of rpres[0], rpres[1], rpres[2], rpres[3], rpres[4], and rpres[5].

class models.RigidBody.Particle2DIMR(M, dt, alpha, init_rx, init_ry, init_mx, init_my, zeta)

Bases: object

get_E(m)

The function get_E calculates the total energy E based on the input m and the class attributes M and alpha.

Parameters:

m – The parameter m is a list or tuple containing four elements. The first two elements (m[0] and m[1]) represent the x and y components of the position vector, while the last two elements (m[2] and m[3]) represent the momentum.

Returns:

the value of the expression 0.5*(m[2]**2 + m[3]**2)/self.M + 0.5 *self.alpha * (m[0]**2 + m[1]**2).

get_L(m=(0.0, 0.0, 0.0))

The function get_L returns a 4x4 numpy array representing a transformation matrix.

Parameters:

m – The parameter m is a tuple with three elements representing the x, y, and z coordinates respectively. The default value for m is (0.0, 0.0, 0.0)

Returns:

a 4x4 numpy array called L.

f(rpNew)

The function f calculates the residual of the difference between the old and new values of r and p, taking into account various factors such as mass, dissipation, and time step.

Parameters:

rpNew – The parameter rpNew is a numpy array containing the new values of position and momentum. It has the form [x_new, y_new, px_new, py_new]

Returns:

a tuple containing the values of rpres[0], rpres[1], rpres[2], and rpres[3].

m_new()

The function m_new returns new values for r and p by solving a system of equations using the fsolve function. :return: a tuple containing two tuples. The first tuple contains the values of rx and ry, and the second tuple contains the values of px and py.

class models.RigidBody.Particle2DNeural(M, dt, alpha, init_rx, init_ry, init_mx, init_my, zeta, method='without', name='.')

Bases: Particle2DIMR

neural_zdot(z)

The function neural_zdot calculates the Hamiltonian for a given input z using neural networks.

Parameters:

z – The parameter z is a tensor representing the input to the neural network. It is of type torch.Tensor and has a shape determined by the specific neural network architecture being used.

f(rpNew)

The function f calculates the residual between the old and new values of rp and the time derivative of z.

Parameters:

rpNew – The parameter rpNew represents the new values of r and p that are being passed to the function f

Returns:

the value of the variable “res”.

get_cass(z)

The function get_cass takes in a parameter z, converts it to a tensor, passes it through a neural network J_net, and returns the output cass as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the neural network. It is converted to a tensor using torch.tensor with a data type of torch.float32. The requires_grad=True argument indicates that gradients will be computed for this tensor during backprop

Returns:

The function get_cass returns the value of cass as a NumPy array.

get_L(z)

The function get_L takes a tensor z, passes it through a neural network L_net, and returns the output L as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the L_net neural network. It is converted to a tensor using torch.tensor with a data type of torch.float32.

Returns:

the value of L, which is obtained by passing the input z through the L_net neural network and converting the result to a numpy array.

get_E(z)

The function get_E takes a parameter z, converts it to a tensor, passes it through a neural network called energy_net, and returns the resulting energy value.

Parameters:

z – The parameter z is a numerical input that is used as an input to the energy_net neural network. It is converted to a tensor using torch.tensor and is set to have a data type of torch.float32. The requires_grad=True argument indicates that gradients will

Returns:

the value of E, which is the output of the energy_net model when given the input z.

m_new()

The function m_new calculates new values for r and p using the fsolve function and returns the updated values. :return: a tuple containing two tuples. The first tuple contains the values of self.r[0] and self.r[1], and the second tuple contains the values of self.p[0] and self.p[1].

class models.RigidBody.ShivamoggiIMR(M, dt, alpha, init_rx, init_ry, init_rz, init_u)

Bases: object

get_E(m)

The function get_E calculates the value of E using the formula E = m[3]**2 + m[0]**2 - m[2]**2.

Parameters:

m – The parameter m is a list or tuple containing four elements

Returns:

the value of m[3]**2 + m[0]**2 - m[2]**2.

get_UV(m)

The function get_UV takes a list m as input and returns a tuple of two tuples, where the first tuple is calculated based on the values of u, x, and z from m, and the second tuple is calculated based on the value of x and z from m.

Parameters:

m – The parameter m is a list containing four elements: u, x, y, and z

Returns:

The function get_UV returns a tuple of two tuples. The first tuple contains three values: 0.0, 2*u*(x+z), and 0.0. The second tuple contains three values: x, 0, and -z.

get_L(m=(0.0, 0.0, 0.0, 0.0))

The function get_L calculates and returns a 4x4 matrix L based on the input parameter m.

Parameters:

m – The parameter m is a tuple of four values (m[0], m[1], m[2], m[3])

Returns:

The function get_L returns a 4x4 numpy array.

f(mNew)

The function f calculates the residual of a given input mNew by performing a series of mathematical operations.

Parameters:

mNew – The parameter mNew is a list or array containing the new values for u, x[0], x[1], and x[2]

Returns:

a tuple containing the values of mres[0], mres[1], mres[2], and mres[3].

m_new()

The function m_new returns new values for u, x[0], x[1], and x[2] by solving the equation f(u, x[0], x[1], x[2]) = 0 using the fsolve function. :return: a tuple containing the values of u, x, y, and z.

class models.RigidBody.ShivamoggiNeural(M, dt, alpha, init_rx, init_ry, init_rz, init_u, method='without', name='.')

Bases: ShivamoggiIMR

neural_zdot(z)

The function neural_zdot calculates the Hamiltonian of a neural network given a set of input values.

Parameters:

z – The parameter z is a tensor representing the input to the neural network. It is of type torch.Tensor and has a shape determined by the dimensions of the input data

Returns:

The function neural_zdot returns the variable hamiltonian.

f(mNew)

The function f calculates the difference between the old and new values of m and adds the product of the time step and the derivative of z to it.

Parameters:

mNew – The parameter mNew represents the new values of m that are passed to the function f

Returns:

the difference between the old values and the new values, plus the product of the time step and the derivative of the neural network with respect to the midpoint of the old and new values.

get_cass(z)

The function get_cass takes in a parameter z, converts it to a tensor, passes it through a neural network J_net, and returns the output cass as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the neural network. It is converted to a tensor using torch.tensor with a data type of torch.float32. The requires_grad=True argument indicates that gradients will be computed for this tensor during backprop

Returns:

the value of cass as a NumPy array.

get_L(z)

The function get_L takes a tensor z, passes it through a neural network L_net, and returns the output L as a numpy array.

Parameters:

z – The parameter z is a numerical input that is used as an input to the L_net neural network. It is converted to a tensor using torch.tensor with a data type of torch.float32. The requires_grad=True argument indicates that gradients will be computed with respect

Returns:

the value of L, which is obtained by passing the input z through the L_net neural network and converting the result to a numpy array.

get_E(z)

The function get_E takes a parameter z, converts it to a tensor, passes it through a neural network called energy_net, and returns the resulting energy value.

Parameters:

z – The parameter z is a numerical input that is used as an input to the energy_net neural network. It is converted to a tensor using torch.tensor and is set to have a data type of torch.float32. The requires_grad=True argument indicates that gradients will

Returns:

the value of E, which is the output of the energy_net model when given the input z.

m_new()

The function m_new returns the values of u, x[0], x[1], and x[2] after solving the equation f using the fsolve function.

Returns:

a tuple containing the values of self.u, self.x[0], self.x[1], and self.x[2].