HARM
harm and utilities
 All Data Structures Files Functions Variables Typedefs Macros Pages
u2p_defs.h
Go to the documentation of this file.
1 
8 #include "decs.h"
9 #define GAMMA (gamideal) /* Adiabatic index used for the state equation */
10 
11 // jon commented those out:
12 
13 /*Added these for the old version of HARM: */
14 
15 /* #define FTYPE double */
16 
17 /* FILE *fail_file, *log_file; */
18 
19 /* //static int debugfail = 2; */
20 
21 
22 /* #define NUMEPSILON (2.2204460492503131e-16) */
23 
24 #define CHANGEDTOOLDER 0
25 
26 #define CRAZYDEBUG 0
27 
28 
29 
30 #define OPTIMIZED 1
31 
32 #define NEWCONVERGE 1
33 
34 #define DOHISTOGRAM 0
35 
37 #define GAMMASQCHECKRESID (1e2)
38 
39 
40 // trying to control repeated cycles
41 //#define CYCLESTOP 10 // 10 is too dangerous
42 //#define NUMCYCLES 3 // 3 is too dangerous
43 #define CYCLESTOP 200 // don't limit for now to avoid issues with bad solutions in highly magnetized cases.
44 #define NUMCYCLES 200 // ""
45 
47 #if(PRECISEINVERSION)
48 #define ITERDAMPSTART 10 // iteration to start using damp if haven't already
49 #define MAX_NEWT_ITER 100 /* Max. # of Newton-Raphson iterations for find_root_2D(); Hardly ever case where need 200 iterations */
50 #define NEWT_TOL (1E3*NUMEPSILON) /* Min. of tolerance allowed for Newton-Raphson iterations */
51 #define NEWT_TOL_ULTRAREL (5.0*NUMEPSILON) /* Min. of tolerance allowed for Newton-Raphson iterations */
52 //#define MIN_NEWT_TOL (1E5*NUMEPSILON) /* Max. of tolerance allowed for Newton-Raphson iterations */
53 
54 #if(REALTYPE==FLOATTYPE)
55 #define MIN_NEWT_TOL (1E-2)
56 #elif(REALTYPE==DOUBLETYPE)
57 #define MIN_NEWT_TOL (1E-6)
58 #elif(REALTYPE==LONGDOUBLETYPE)
59 #define MIN_NEWT_TOL (1E-8)
60 #endif
61 
62 
63 #else
64 #define ITERDAMPSTART 10 // iteration to start using damp if haven't already
65 #define MAX_NEWT_ITER 30 /* Max. # of Newton-Raphson iterations for find_root_2D(); */
66 #define NEWT_TOL (1E5*NUMEPSILON) /* Min. of tolerance allowed for Newton-Raphson iterations */
67 #define NEWT_TOL_ULTRAREL (1E1*NUMEPSILON) /* Min. of tolerance allowed for Newton-Raphson iterations */
68 //#define MIN_NEWT_TOL (1E5*NUMEPSILON) /* Max. of tolerance allowed for Newton-Raphson iterations */
69 
70 #if(REALTYPE==FLOATTYPE)
71 #define MIN_NEWT_TOL (1E-2)
72 #elif(REALTYPE==DOUBLETYPE)
73 #define MIN_NEWT_TOL (1E-2)
74 #elif(REALTYPE==LONGDOUBLETYPE)
75 #define MIN_NEWT_TOL (1E-2)
76 #endif
77 
78 
79 #endif
80 
83 #define MINERROREXPECTED (NUMEPSILON*10.0)
84 
85 
86 /* #define MAX_NEWT_ITER 30 /\* Max. # of Newton-Raphson iterations for find_root_2D(); *\/ */
87 /* #define NEWT_TOL 1.0e-10 /\* Min. of tolerance allowed for Newton-Raphson iterations *\/ */
88 /* #define MIN_NEWT_TOL 1.0e-10 /\* Max. of tolerance allowed for Newton-Raphson iterations *\/ */
89 
90 #if(PRECISEINVERSION)
91 
92 
93 
94 
95 #define EXTRA_NEWT_ITER 2
96 #define EXTRA_NEWT_ITER_ULTRAREL 2
97 #else
98 
99 #define EXTRA_NEWT_ITER 1
100 #define EXTRA_NEWT_ITER_ULTRAREL 2
101 #endif
102 
103 #define CYCLE_BREAK_PERIOD 1000 /* change newton step by random factor every this number of newton iterations*/
104 #define CHECK_FOR_STALL 0 /* check for stationary newton stepping */
105 
106 
107 #define NEWT_TOL2 (NUMEPSILON) /* TOL of new DBL gnr2 method */
108 #define MIN_NEWT_TOL2 (1E4*NUMEPSILON) /* TOL of new DBL gnr2 method */
109 
110 
111 #define SCALEMAX 1.0e2 /* Max. value of the factor used to scale the Newton step */
112 #define TOL_LINE_STEP NEWT_TOL /* Minimum value of Max(dx/x) in line search algorithm */
113 #define GRADMIN (1E4*NUMEPSILON) /* Magnitude of gradient below which we say we are at a local min. */
114 #define NEWT_FUNC_TOL 1.0e-5 /* Max. ratio of the final and initial resid magnitudes to be considered converged */
115 
116 
117 //#define W_TOO_BIG (GAMMAFAIL*GAMMAFAIL)
118 // \gamma^2 (\rho_0 + u + p) is assumed to always be smaller than this. This
119 // is used to detect solver failures
120 
121 
122 
123 
124 
125 #define GAMMASQ_TOO_BIG (GAMMAFAIL*GAMMAFAIL)
126 
127 #define UTSQ_TOO_BIG ((GAMMAFAIL-1.0)*(GAMMAFAIL-1.0))
128 #define UT_TOO_BIG (GAMMAFAIL-1.0)
129 /* \tilde{u}^2 is assumed to be smaller
130  than this. Used to detect solver
131  failures */
132 
133 //#define VSQ_TOO_BIG (1.0-1.0/((UT_TOO_BIG+1.0)*(UT_TOO_BIG+1.0))) //atch: corrected to be a square
134 #define VSQ_TOO_BIG ((GAMMASQ_TOO_BIG-1.0)/(GAMMASQ_TOO_BIG)) // avoids catastrophic cancellation unlike above
135 
136 
137 #define FAIL_VAL BIG
138 
145 #define VSQNEGCHECK 2
146 
148 #define UTSQNEGLIMIT (-0.9*UTSQ_TOO_BIG)
149 
151 //#define MAXNEGUTSQ (1E-10) // greater than negative of this but <0 makes utsq=0
152 #define MAXNEGUTSQ (fabs(UTSQNEGLIMIT)) // greater than negative of this but <0 makes utsq=0
153 //#define MAXNEGVSQ (1.0-1.0/(MAXNEGUTSQ+1.0))
154 #define MAXNEGVSQ (0.9*VSQ_TOO_BIG)
155 
156 
157 
158 /* some mnemonics */
159 /* for primitive variables */
160 #ifndef RHO
161 #define RHO 0
162 #endif
163 
164 #ifndef UU
165 #define UU 1
166 #endif
167 
168 #define UTCON1 2
169 #define UTCON2 3
170 #define UTCON3 4
171 #define BCON1 5
172 #define BCON2 6
173 #define BCON3 7
174 
175 /* for conserved variables */
176 #define QCOV0 1
177 #define QCOV1 2
178 #define QCOV2 3
179 #define QCOV3 4
180 
181 
182 #define MYMAX(a,b) ( ((a) > (b)) ? (a) : (b) )
183 
184