File indexing completed on 2025-01-18 09:59:01
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028 #ifndef _QSS_MISC_H_
0029 #define _QSS_MISC_H_
0030
0031 typedef struct QSS_simulator_ *QSS_simulator;
0032 typedef struct QSSSubstep_ *QSSSubstep;
0033
0034 namespace Qss_misc {
0035
0036 constexpr unsigned int PXidx= 0;
0037 constexpr unsigned int PYidx= 1;
0038 constexpr unsigned int PZidx= 2;
0039
0040 constexpr unsigned int VXidx= 3;
0041 constexpr unsigned int VYidx= 4;
0042 constexpr unsigned int VZidx= 5;
0043
0044
0045 constexpr unsigned int MAX_QSS_STEPPER_ORDER= 3;
0046 constexpr unsigned int VAR_IDX_END= 6;
0047 constexpr unsigned int MIN_SUBSTEPS= 20;
0048
0049 constexpr G4double INF= 1.0e20;
0050 }
0051
0052 #if defined(WIN32) || defined(__MINGW32__)
0053 #define unlikely(x) (x)
0054 #define likely(x) (x)
0055 #else
0056 #define unlikely(x) __builtin_expect((x),0)
0057 #define likely(x) __builtin_expect((x),1)
0058 #endif
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 #define SUBSTEP_STRUCT(sim, i) (sim->substeps[i])
0069 #define SUBSTEP_START(sim, i) (sim->substeps[(i)].start_time)
0070 #define SUBSTEP_X(sim, i) (sim->substeps[(i)].x)
0071 #define SUBSTEP_TX(sim, i) (sim->substeps[(i)].tx)
0072 #define SUBSTEP_LEN(sim, i) (sim->substeps[(i)].len)
0073
0074 #define LAST_SUBSTEP_STRUCT(sim) (SUBSTEP_STRUCT(sim, sim->cur_substep_idx-1))
0075
0076 #define CUR_SUBSTEP_START(sim) (SUBSTEP_START(sim, sim->cur_substep_idx))
0077 #define CUR_SUBSTEP_X(sim) (SUBSTEP_X(sim, sim->cur_substep_idx))
0078 #define CUR_SUBSTEP_TX(sim) (SUBSTEP_TX(sim, sim->cur_substep_idx))
0079 #define CUR_SUBSTEP_LEN(sim) (SUBSTEP_LEN(sim, sim->cur_substep_idx))
0080
0081 #define CUR_SUBSTEP(sim) (sim->cur_substep_idx)
0082 #define LAST_SUBSTEP(sim) (sim->cur_substep_idx-1)
0083 #define MAX_SUBSTEP(sim) (sim->max_substep_idx)
0084 #define SUBSTEPS(sim) (sim->substeps)
0085
0086 struct QSSSubstep_
0087 {
0088 double x[Qss_misc::VAR_IDX_END*(Qss_misc::MAX_QSS_STEPPER_ORDER+1)];
0089 double tx[Qss_misc::VAR_IDX_END];
0090
0091 double start_time;
0092 double len;
0093 };
0094
0095 struct QSS_simulator_
0096 {
0097 double x[Qss_misc::VAR_IDX_END*(Qss_misc::MAX_QSS_STEPPER_ORDER+1)];
0098 double tx[Qss_misc::VAR_IDX_END];
0099
0100 double q[Qss_misc::VAR_IDX_END*(Qss_misc::MAX_QSS_STEPPER_ORDER+1)];
0101 double tq[Qss_misc::VAR_IDX_END];
0102
0103 double nextStateTime[Qss_misc::VAR_IDX_END];
0104 double time;
0105 int minIndex;
0106
0107 double dQMin[Qss_misc::VAR_IDX_END];
0108 double dQRel[Qss_misc::VAR_IDX_END];
0109 double lqu[Qss_misc::VAR_IDX_END];
0110
0111 double alg[Qss_misc::VAR_IDX_END];
0112 double it;
0113
0114 int *SD[Qss_misc::VAR_IDX_END];
0115 int states;
0116
0117 QSSSubstep substeps;
0118 int cur_substep_idx;
0119 int max_substep_idx;
0120 };
0121
0122 #endif