-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnozzle.c
More file actions
193 lines (150 loc) · 4.16 KB
/
Copy pathnozzle.c
File metadata and controls
193 lines (150 loc) · 4.16 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
#include "paul.h"
//static double r0;
static double Pow;
static double th0;
static double eta0;
static double gam0;
static double tjet;
static double tmin;
void setNozzleParams( struct domain * theDomain ){
// r0 = theDomain->theParList.Nozzle_r0;
Pow = theDomain->theParList.Nozzle_Power;
th0 = theDomain->theParList.Nozzle_th0;
eta0 = theDomain->theParList.Nozzle_Eta;
gam0 = theDomain->theParList.Nozzle_Gamma;
tjet = theDomain->theParList.Nozzle_Time;
tmin = theDomain->theParList.t_min;
}
void noz_src( double * cons , double dVdt , double r , double theta , double t , double r_min ){
double r0,v,Vol,f,eta;
int wind = 0;
if( !wind ){
//double r0 = 5.*r_min;
r0 = 2.*r_min;
v = sqrt(1.-1./gam0/gam0);
Vol = pow( sqrt(2.*M_PI)*r0 , 3. )*( 1. - exp(-2./th0/th0) )*th0*th0/sqrt(.5*M_PI);
f = (r/r0)*exp(-.5*r*r/r0/r0)*exp( (fabs(cos(theta))-1.) /th0/th0)/Vol;
eta = eta0;
//f *= exp(-(t-tmin)/tjet);
}else{
r0 = 2.*r_min;
v = 0.1;
Vol = 8.*M_PI*pow( r0 , 3. );
f = (r/r0)*exp(-.5*r*r/r0/r0)/Vol;
eta = .5*v*v;
}
// f *= pow(1.+(t-tmin)/tjet,-2.);
double SE = Pow*f;
double SS = v*SE;
double SM = SE/eta;
cons[DEN] += SM*dVdt;
cons[SS1] += SS*dVdt;// *cos(theta);
//cons[SS2] += SS*dVdt*sin(theta)*(-r);
cons[TAU] += SE*dVdt;
if( NUM_N > 0 ){
cons[NUM_C+0] += SM*dVdt;
}
// int q;
// for( q=NUM_C ; q<NUM_C+NUM_N ; ++q ){
// cons[q] += SM*dVdt;
// }
/*
double r0 = 3.*r_min;
double Vol = 4./3.*M_PI*pow(r0,3.);
double Q = 0.0;
double v_wind = 50.0;
if( r<r0 ) Q = Pow/Vol*pow(1.+t/tjet,-2.);
cons[TAU] += Q*dVdt;
cons[DEN] += Q*dVdt/eta0;
// cons[SS1] += 2.*Q/v_wind*dVdt;
// cons[DEN] += 2.*Q/v_wind/v_wind*dVdt;
// int q;
// for( q=NUM_C ; q<NUM_C+NUM_N ; ++q ){
// cons[q] += 2.*Q/v_wind/v_wind*dVdt;
// }
*/
/*
double Rmin = 2.47*7e10;
double Rmax = 5e11; //0.05;
double Vol = 4./3.*M_PI*( pow(Rmax,3.) - pow(Rmin,3.) );
double T = 1e7; //0.1;
//double Pow = 3e41/(1.+pow(t/3e5,1.5));
//4.5e40
double Pow = 1e41;
double Q = 0.0;
if( r<Rmax && r>Rmin && t<T ) Q = Pow/Vol;
cons[TAU] += Q*dVdt;
*/
/*
double R = 0.006;
Vol = 4./3.*M_PI*pow(R,3.);
double T = 1e10;
double E = 1.0;
// double Pow = E/T;
// Pow = 1e-4;
double Q = 0.0;
if( r<R && t<T ) Q = Pow/Vol;
double eps = 1e-1;
cons[TAU] += Q*dVdt;
cons[DEN] += eps*Q*dVdt;
*/
}
void noz_set( double * prim , double r , double theta , double t , double r_min ){
double r0 = 3.*r_min;
if( r<r0 ){
double rho,Pp,gv,X;
if( theta < th0 ){
double Area = 2.*M_PI*r0*r0*(1.-cos(th0));
Pp = Pow/4./gam0/gam0/Area*exp(-t/tjet);
rho = 4.*gam0*Pp/eta0;
gv = gam0;
X = 1.0;
}else{
rho = prim[RHO];
gv = 0.0;
Pp = prim[PPP];
X = 0.0;
}
prim[RHO] = rho;
prim[UU1] = gv;
prim[UU2] = 0.0;
prim[PPP] = Pp;
int q;
for( q=NUM_C ; q<NUM_C+NUM_N ; ++q ){
prim[q] = X;
}
}
}
double get_dV( double * , double * );
void nozzle( struct domain * theDomain , double dt ){
struct cell ** theCells = theDomain->theCells;
int Nt = theDomain->Nt;
int Np = theDomain->Np;
int * Nr = theDomain->Nr;
double * t_jph = theDomain->t_jph;
double * p_kph = theDomain->p_kph;
double t = theDomain->t;
double r_min = theCells[0][0].riph;
int i,j,k;
for( j=0 ; j<Nt ; ++j ){
double thp = t_jph[j];
double thm = t_jph[j-1];
double th = .5*(thp+thm);
for( k=0 ; k<Np ; ++k ){
double php = p_kph[k];
double phm = p_kph[k-1];
int jk = j+Nt*k;
for( i=0 ; i<Nr[jk] ; ++i ){
struct cell * c = &(theCells[jk][i]);
double rp = c->riph;
double rm = rp - c->dr;
double r = rp - .5*c->dr;
double xp[3] = {rp,thp,php};
double xm[3] = {rm,thm,phm};
double dV = get_dV(xp,xm);
noz_src( c->cons , dV*dt , r , th , t , r_min );
//noz_set( c->prim , r , th );
}
}
}
}