-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtransport_tables.c
149 lines (123 loc) · 4.84 KB
/
transport_tables.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#include "pluto.h"
#include "table_utilities.h"
#define REPRINT_ETA_TAB YES
#define REPRINT_KAPPA_TAB YES
#define ETA_TAB_SCRIPT "transport_tables_scripts/EtaTable_4pluto.py"
#define KAPPA_TAB_SCRIPT "transport_tables_scripts/KappaTable_4pluto.py"
#define ETA_TAB_FILE_NAME "eta.dat"
#define KAPPA_TAB_FILE_NAME "kappa.dat"
static Table2D eta_tab; /* A 2D table containing pre-computed values of
electr. resistivity stored at equally spaced node
values of Log(T) and Log(rho) .*/
static Table2D kappa_tab; /* A 2D table containing pre-computed values of
therm. conductivity stored at equally spaced node
values of Log(T) and Log(rho) .*/
/*****************************************************************************/
/* Function to build a table of electrical resistivity using a python script*/
/*****************************************************************************/
void MakeElecResistivityTable() {
int i,j;
double rho_min, rho_max, T_min, T_max;
int N_rho, N_T;
char table_finame[30] = ETA_TAB_FILE_NAME;
char command[300];
// char options[100] = " 800.0 30000.0 6 2.5e-11 2.7e-5 4";
double **f;
int logspacing;
#if MAKE_ETA_TAB_FILE
sprintf(command, "python3 %s %e %e %d %e %e %d %s", ETA_TAB_SCRIPT,
(double)(T_TAB_MIN), (double)(T_TAB_MAX), (int) N_TAB_T,
(double)(RHO_TAB_MIN), (double)(RHO_TAB_MAX), (int)(N_TAB_RHO),
table_finame);
system(command);
#endif
// Now I read the just made table
ReadASCIITableSettings(table_finame, &logspacing,
&T_min, &T_max, &N_T,
&rho_min, &rho_max, &N_rho);
if (logspacing!=10) {
print1("\n> MakeElecResistivityTable(): Error! Only logspacing 10 is supported!");
QUIT_PLUTO(1);
}
print1 ("\n> MakeElecResistivityTable(): Generating table (%d x %d points)",
N_T, N_rho);
InitializeTable2D(&eta_tab,
T_min, T_max, N_T,
rho_min, rho_max, N_rho);
f = ARRAY_2D(N_rho, N_T, double);
ReadASCIITableMatrix(table_finame, f, N_T, N_rho);
for (j = 0; j < eta_tab.ny; j++)
for (i = 0; i < eta_tab.nx; i++)
eta_tab.f[j][i] = f[j][i];
eta_tab.interpolation = LINEAR;
FinalizeTable2D(&eta_tab);
#if REPRINT_ETA_TAB
ReprintTable(&eta_tab, table_finame);
#endif
FreeArray2D((void *)f);
}
/*************************************************************/
/* Function to get the Electrical res. from table */
/*************************************************************/
int GetElecResisitivityFromTable(double rho, double T, double *eta) {
int status;
status = Table2DInterpolate(&eta_tab, T, rho, eta);
if (status != 0){
return status;
}
return 0;
}
/*****************************************************************************/
/* Function to build a table of thermal conductivity using a python script */
/*****************************************************************************/
void MakeThermConductivityTable() {
int i,j;
double rho_min, rho_max, T_min, T_max;
int N_rho, N_T;
char table_finame[30] = KAPPA_TAB_FILE_NAME;
char command[300];
double **f;
int logspacing;
#if MAKE_KAPPA_TAB_FILE
sprintf(command, "python3 %s %e %e %d %e %e %d %s", KAPPA_TAB_SCRIPT,
(double)(T_TAB_MIN), (double)(T_TAB_MAX), (int) N_TAB_T,
(double)(RHO_TAB_MIN), (double)(RHO_TAB_MAX), (int)(N_TAB_RHO),
table_finame);
system(command);
#endif
// Now I read the just made table
ReadASCIITableSettings(table_finame, &logspacing,
&T_min, &T_max, &N_T,
&rho_min, &rho_max, &N_rho);
if (logspacing!=10) {
print1("\n> MakeThermConductivityTable(): Error! Only logspacing 10 is supported!");
QUIT_PLUTO(1);
}
print1 ("\n> MakeThermConductivityTable(): Generating table (%d x %d points)",
N_T, N_rho);
InitializeTable2D(&kappa_tab,
T_min, T_max, N_T,
rho_min, rho_max, N_rho);
f = ARRAY_2D(N_rho, N_T, double);
ReadASCIITableMatrix(table_finame, f, N_T, N_rho);
for (j = 0; j < kappa_tab.ny; j++)
for (i = 0; i < kappa_tab.nx; i++)
kappa_tab.f[j][i] = f[j][i];
kappa_tab.interpolation = LINEAR;
FinalizeTable2D(&kappa_tab);
#if REPRINT_ETA_TAB
ReprintTable(&kappa_tab, table_finame);
#endif
FreeArray2D((void *)f);
}
/*************************************************************/
/* Function to get the thermal cond. from table */
/*************************************************************/
int GetThermConductivityFromTable(double rho, double T, double *kappa) {
int status;
status = Table2DInterpolate(&kappa_tab, T, rho, kappa);
if (status != 0){
return status;
}
return 0;
}