Hawaii Hybrid
Loading...
Searching...
No Matches
trajectory.h
Go to the documentation of this file.
1#ifndef TRAJECTORY_H_
2#define TRAJECTORY_H_
3
4#include <stdlib.h>
5#include <assert.h>
6#include <string.h>
7
8#include "array.h"
9#include "hawaii.h"
10
11#include <cvode/cvode.h>
12#include <nvector/nvector_serial.h>
13#include <sunmatrix/sunmatrix_dense.h>
14#include <sunlinsol/sunlinsol_dense.h>
15#include <cvode/cvode_direct.h>
16#include <sundials/sundials_types.h>
17
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23extern int rhs(realtype t, N_Vector y, N_Vector ydot, void * user_data);
24
25typedef struct
26{
27 size_t DIM;
28 size_t mxsteps;
29 N_Vector y;
30 N_Vector abstol;
31 realtype reltol;
32 SUNMatrix A;
33 SUNLinearSolver LS;
34 void *cvode_mem;
35 //
38 N_Vector ic;
39 // -- energy conservation
41 double E0;
42 double E_last;
44
45Trajectory init_trajectory(MoleculeSystem *ms, double reltol);
46void free_trajectory(Trajectory *traj);
47
50int make_step(Trajectory *traj, double tout, double *t);
51
53N_Vector make_vector(int size);
54void set_tolerance(Trajectory *traj, double tolerance);
55
56void reinit_trajectory(Trajectory *traj, double t);
57
58#ifdef __cplusplus
59}
60#endif
61
62#endif // TRAJECTORY_H_
63
64/*
65 * Copyright (C) 2026 A.Finenko & D.Chistikov
66 * Distributed under the GNU General Public License, version 3
67 *
68 * This program is free software: you can redistribute it and/or modify
69 * it under the terms of the GNU General Public License as published by
70 * the Free Software Foundation, either version 3 of the License, or
71 * (at your option) any later version.
72 *
73 * This program is distributed in the hope that it will be useful,
74 * but WITHOUT ANY WARRANTY; without even the implied warranty of
75 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
76 * GNU General Public License for more details.
77 *
78 * You should have received a copy of the GNU General Public License
79 * along with this program. If not, see <http://www.gnu.org/licenses/>.
80 */
Definition array.h:11
Angular variables and conjugated momenta are stored within the MoleculeSystem struct in the same orde...
Definition hawaii.h:278
Definition trajectory.h:26
SUNMatrix A
Matrix structure for storing jacobian information.
Definition trajectory.h:32
double E_last
Energy value from the last computed step (for tracking changes in energy).
Definition trajectory.h:42
N_Vector y
Internal phase-space vector (current step of the system).
Definition trajectory.h:29
MoleculeSystem * ms
Pointer to MoleculeSystem.
Definition trajectory.h:37
void * cvode_mem
Pointer to the CVODE memory block (solver internal state).
Definition trajectory.h:34
size_t mxsteps
Maximum number of internal time steps for the solver.
Definition trajectory.h:28
N_Vector abstol
Absolute tolerance for each variable in the ODE system.
Definition trajectory.h:30
SUNLinearSolver LS
Linear solver object for the ODE system.
Definition trajectory.h:33
double E0
Initial total energy of the system (used for conservation checks).
Definition trajectory.h:41
realtype reltol
Relative tolerance for the ODE solver.
Definition trajectory.h:31
size_t DIM
Number of Hamilton's equations of motion (system dimension).
Definition trajectory.h:27
Array temp_qp
Temporary storage array for coordinates and momenta during trajectory propagation.
Definition trajectory.h:36
bool check_energy_conservation
Flag indicating whether to monitor energy conservation during trajectory propagation.
Definition trajectory.h:40
N_Vector ic
Initial conditions for the trajectory.
Definition trajectory.h:38
void free_trajectory(Trajectory *traj)
free_trajectory
Definition trajectory.c:77
Trajectory init_trajectory(MoleculeSystem *ms, double reltol)
init_trajectory initializes a Trajectory structure for propagating Hamilton's equations of motion for...
Definition trajectory.c:5
void trajectory_reinit(Trajectory *traj)
free_trajectory
Definition trajectory.c:140
void reinit_trajectory(Trajectory *traj, double t)
Definition trajectory.c:234
void set_tolerance(Trajectory *traj, double tolerance)
set_tolerance
Definition trajectory.c:216
bool trajectory_apply_requantization(Trajectory *traj)
Definition trajectory.c:93
N_Vector make_vector(int size)
make_vector
Definition trajectory.c:204
void set_initial_condition(Trajectory *traj, Array qp)
set_initial_condition
Definition trajectory.c:187
int rhs(realtype t, N_Vector y, N_Vector ydot, void *user_data)
rhs function is passed to CVode library to propagate the trajectory. First, the phase-point coordinat...
Definition hawaii.c:594
int make_step(Trajectory *traj, double tout, double *t)
make_step Invokes the main function of CVode and, if enabled, applies requantization to the monomers'...
Definition trajectory.c:148