OSHUN  beta
Arbitrary Order Spherical-Harmonic 1D-3P Vlasov-Fokker-Planck-Maxwell code
fluid.cpp
Go to the documentation of this file.
1 
9 //--------------------------------------------------------------
10 // Standard libraries
11  #include <iostream>
12  #include <vector>
13  #include <valarray>
14  #include <complex>
15  #include <algorithm>
16  #include <cstdlib>
17 
18  #include <math.h>
19  #include <map>
20 
21 // My libraries
22  #include "lib-array.h"
23  #include "lib-algorithms.h"
24 
25 // Declerations
26  #include "state.h"
27  #include "formulary.h"
28  #include "input.h"
29  #include "nmethods.h"
30  // #include "vlasov.h"
31  #include "fluid.h"
32 
33 //*******************************************************************************************************************************************************
35 //-------------------------------------------------------------------------------------------------------------------------------------------------------
36 Hydro_Functor::Hydro_Functor(double xmin, double xmax, size_t numx):
37  idx(numx/(xmax-xmin)), szx(numx), FEQ(xmin,xmax,numx) {}
38 //-------------------------------------------------------------------------------------------------------------------------------------------------------
39 //-------------------------------------------------------------------------------------------------------------------------------------------------------
40 void Hydro_Functor::operator()(const State1D& Yin, State1D& Yslope){
41  Yslope = 0.0;
42 
43  valarray<double> electronpressure(0.0,szx), electrondensity(0.0, szx);
44  Array2D<double> electroncurrent(3,szx);
45 
46  electrondensity = Yin.DF(0).getdensity();
47  electronpressure = Yin.DF(0).getpressure();
48 
49  FEQ.density( Yin.HYDRO(), Yslope.HYDRO());
50  FEQ.chargefraction( Yin.HYDRO(), Yslope.HYDRO());
51  FEQ.velocity( Yin , Yslope.HYDRO(), electrondensity, electronpressure, electroncurrent);
52  FEQ.updateE( Yin.HYDRO(), Yslope.EMF());
53 }
54 //-------------------------------------------------------------------------------------------------------------------------------------------------------
55 //-------------------------------------------------------------------------------------------------------------------------------------------------------
56 void Hydro_Functor::operator()(const State1D& Yin, State1D& Yslope, size_t dir){}
57 void Hydro_Functor::operator()(const State1D& Y1in, const State1D& Y2in, State1D& Yslope){}
58 //-------------------------------------------------------------------------------------------------------------------------------------------------------
59 //-------------------------------------------------------------------------------------------------------------------------------------------------------
60 
61 //******************************************************************************************
62 //------------------------------------------------------------------------------------------
63 // Fluid Equation Class Constructor
64 
65 Fluid_Equation_1D::Fluid_Equation_1D(double xmin, double xmax, size_t Nx)
66  : idx(Nx/(xmax-xmin)), szx(Nx), dummy(0.0,Nx)
67  {
69 
70  }
71 
72 //------------------------------------------------------------------------------------------
73 //------------------------------------------------------------------------------------------
74 void Fluid_Equation_1D::density(const Hydro1D& Hin, Hydro1D& Hslope){
75  valarray<double> d_nvx(Hin.densityarray());
76  for (size_t ix(0);ix<szx;++ix)
77  d_nvx[ix] = d_nvx[ix] * Hin.vx(ix);
78 
79  d_nvx = df_4thorder(d_nvx);
80 
81  Hslope.density(0) -= idx * d_nvx[0];
82 
83  for (size_t ix(1);ix<szx-1;++ix)
84  {
85  Hslope.density(ix) -= idx * d_nvx[ix];
86  }
87 
88  Hslope.density(szx - 1) -= idx * d_nvx[szx-1];
89 
90 }
91 //---------------------------------------------------------------------------------------------
92 //---------------------------------------------------------------------------------------------
94  valarray<double> d_nZx(Hin.densityarray());
95  for (size_t ix(0);ix<szx;++ix)
96  d_nZx[ix] = d_nZx[ix] * Hin.Z(ix);
97 
98  d_nZx = df_4thorder(d_nZx);
99 
100  Hslope.Z(0) -= idx * d_nZx[0];
101 
102  for (size_t ix(1);ix<szx-1;++ix)
103  {
104  Hslope.Z(ix) -= idx * d_nZx[ix];
105  }
106 
107  Hslope.Z(szx - 1) -= idx * d_nZx[szx-1];
108 
109 }
110 //---------------------------------------------------------------------------------------------
111 //---------------------------------------------------------------------------------------------
112 void Fluid_Equation_1D::velocity(const State1D& Yin , Hydro1D& Hslope,
113  valarray<double>& electrondensity, valarray<double>& electronpressure, Array2D<double>& electroncurrent){
114 
115  double Zeovermi = Yin.HYDRO().charge()/Yin.HYDRO().mass();
116  valarray<double> eventuallynetPovern(Yin.HYDRO().densityarray()), d_vx(Yin.HYDRO().vxarray()), d_vy(Yin.HYDRO().vxarray()), d_vz(Yin.HYDRO().vxarray());
117  valarray<double> eventuallychargeseparation(electronpressure);
118  Array2D<double> netcurrent(3,szx);
119 
120 
121  for (size_t ix(0);ix<szx;++ix){
122  eventuallynetPovern[ix] = eventuallynetPovern[ix] * Yin.HYDRO().temperature(ix);
123  }
124 
125  eventuallynetPovern = df_4thorder(eventuallynetPovern);
126  eventuallychargeseparation = df_4thorder(eventuallychargeseparation);
127 
128  for (size_t ix(0);ix<szx;++ix){
129 
130  // Net pressure
131  eventuallynetPovern[ix] = eventuallynetPovern[ix] / Yin.HYDRO().density(ix) + eventuallychargeseparation[ix] / electrondensity[ix];
132 
133  // Net current
134  netcurrent(0,ix) = Yin.HYDRO().Z(ix)*Yin.HYDRO().charge()*Yin.HYDRO().density(ix)*Yin.HYDRO().vx(ix) - electroncurrent(0,ix);
135  netcurrent(1,ix) = Yin.HYDRO().Z(ix)*Yin.HYDRO().charge()*Yin.HYDRO().density(ix)*Yin.HYDRO().vy(ix) - electroncurrent(1,ix);
136  netcurrent(2,ix) = Yin.HYDRO().Z(ix)*Yin.HYDRO().charge()*Yin.HYDRO().density(ix)*Yin.HYDRO().vz(ix) - electroncurrent(2,ix);
137 
138  // Net charge separation
139  eventuallychargeseparation[ix] = Yin.HYDRO().Z(ix)*Yin.HYDRO().charge()*Yin.HYDRO().density(ix)-electrondensity[ix];
140  }
141 
142  d_vx = df_4thorder(d_vx);
143  d_vy = df_4thorder(d_vy);
144  d_vz = df_4thorder(d_vz);
145 
146 
147  Hslope.vx(0) += - idx * eventuallynetPovern[0] / Yin.HYDRO().mass()
148  + Zeovermi * eventuallychargeseparation[0] * (Yin.EMF().Ex()(0).real()
149  + netcurrent(1,0) * Yin.EMF().Bz()(0).real()
150  - netcurrent(2,0) * Yin.EMF().By()(0).real()); //+ Rie/ni;
151 
152  Hslope.vx(0) -= netcurrent(0,0) * (idx * d_vx[0]);
153 
154  for (size_t ix(1);ix<szx-1;++ix)
155  {
156 
157  Hslope.vx(ix) += -0.5 * idx * eventuallynetPovern[ix] / Yin.HYDRO().mass()
158  + Zeovermi * eventuallychargeseparation[ix] * (Yin.EMF().Ex()(ix).real()
159  + netcurrent(1,ix) * Yin.EMF().Bz()(ix).real()
160  - netcurrent(2,ix) * Yin.EMF().By()(ix).real()); //+ Rie/ni;
161  Hslope.vx(ix) -= netcurrent(0,ix) * (idx * d_vx[ix]);
162  }
163 
164  Hslope.vx(szx - 1) += -idx * eventuallynetPovern[szx - 1] / Yin.HYDRO().mass()
165  + Zeovermi * eventuallychargeseparation[szx - 1] * (Yin.EMF().Ex()(szx - 1).real()
166  + netcurrent(1,szx - 1) * Yin.EMF().Bz()(szx - 1).real()
167  - netcurrent(2,szx - 1) * Yin.EMF().By()(szx - 1).real()); //+ Rie/ni
168  Hslope.vx(szx - 1) -= netcurrent(0,szx - 1) * (idx * d_vx[szx - 1]);
169 
173  Hslope.vy(0) += Zeovermi *
174  ( netcurrent(2,0) * Yin.EMF().Bx()(0).real()
175  - netcurrent(0,0) * Yin.EMF().Bz()(0).real()
176  + eventuallychargeseparation[0] * Yin.EMF().Ey()(0).real());
177 
178  for (size_t ix(1);ix<szx-1;++ix)
179  {
180  Hslope.vy(ix) += Zeovermi *
181  ( netcurrent(2,ix) * Yin.EMF().Bx()(ix).real()
182  - netcurrent(0,ix) * Yin.EMF().Bz()(ix).real()
183  + eventuallychargeseparation[ix] * Yin.EMF().Ey()(ix).real());
184  }
185 
186  Hslope.vy(szx - 1) += Zeovermi *
187  ( netcurrent(2,szx - 1) * Yin.EMF().Bx()(szx - 1).real()
188  - netcurrent(0,szx - 1) * Yin.EMF().Bz()(szx - 1).real()
189  + eventuallychargeseparation[szx - 1] * Yin.EMF().Ey()(szx - 1).real());
190 
191 
195  Hslope.vz(0) += Zeovermi *
196  ( netcurrent(0,0) * Yin.EMF().By()(0).real()
197  - netcurrent(1,0) * Yin.EMF().Bx()(0).real()
198  + eventuallychargeseparation[0] * Yin.EMF().Ez()(0).real());
199 
200  for (size_t ix(1);ix<szx-1;++ix)
201  {
202  Hslope.vz(ix) += Zeovermi *
203  ( netcurrent(0,ix) * Yin.EMF().By()(ix).real()
204  - netcurrent(1,ix) * Yin.EMF().Bx()(ix).real()
205  + eventuallychargeseparation[ix] * Yin.EMF().Ez()(ix).real());
206  }
207 
208  Hslope.vz(szx - 1) += Zeovermi *
209  ( netcurrent(0,szx - 1) * Yin.EMF().By()(szx - 1).real()
210  - netcurrent(1,szx - 1) * Yin.EMF().Bx()(szx - 1).real()
211  + eventuallychargeseparation[szx - 1] * Yin.EMF().Ez()(szx - 1).real());
212 }
213 //------------------------------------------------------------------------------------------
214 //------------------------------------------------------------------------------------------
216  EMF1D& EMF){
217 
218 
219 
220 
221 
222  for (size_t ix(0);ix<szx;++ix){
223  // EMF.Ex()(ix) -= 0.0;//dCdt[ix]; //+0.5*dC2xdx[ix]+(hydrocharge*electrondensity[ix]-hydrodensity[ix]); // Needs JxB in 2D
224  // EMF.Ey()(ix) += -1.0*HYDRO.Z(ix)*HYDRO.charge()*HYDRO.vx(ix)*EMF.Bz()(ix);//+jx[ix]*Bz(ix)-jz[ix]*Bx(ix);
225  // EMF.Ez()(ix) += HYDRO.Z(ix)*HYDRO.charge()*HYDRO.vx(ix)*EMF.By()(ix);//-jx[ix]*By(ix)-jy[ix]*Bx(ix);
226 
227  // EMF.Ex()(ix) += HYDRO.Z(ix)*HYDRO.charge()*HYDRO.vx(ix)*HYDRO.density(ix);
228  // EMF.Ey()(ix) += HYDRO.Z(ix)*HYDRO.charge()*HYDRO.vy(ix)*HYDRO.density(ix);
229  // EMF.Ez()(ix) += HYDRO.Z(ix)*HYDRO.charge()*HYDRO.vz(ix)*HYDRO.density(ix);
230  }
231 }
232 
233 //------------------------------------------------------------------------------------------
234 //------------------------------------------------------------------------------------------
235 
236 // void Fluid_Equation_1D:: calcquantities(const State1D& Yin){
237 
238 // Yin.HYDRO().kineticspeciespressurearray()=0.0;
239 
240 // for (size_t s(0);s<Yin.Species();++s){
241 
242 // Yin.HYDRO().kineticspeciespressurearray() += Yin.DF(s).getpressure();
243 // // Yin.HYDRO().jxarray() += (Yin.DF(s).getcurrent(0));
244 // // Yin.HYDRO().jyarray() += (Yin.DF(s).getcurrent(1));
245 // // Yin.HYDRO().jzarray() += (Yin.DF(s).getcurrent(2));
246 // // std::cout << "kinetic pressure[" << ix << "]=" << Yin.HYDRO().kpressure(ix) << "\n";
247 // // }
248 // }
249 
250 // Yin.HYDRO().electrondensityarray() = Yin.DF(0).getdensity();
251 
252 // }
253 
254 //------------------------------------------------------------------------------------------
255 //------------------------------------------------------------------------------------------
256 
257 //******************************************************************************************
258 //------------------------------------------------------------------------------------------
260  double pmin, double pmax, size_t Np,
261  double xmin, double xmax, size_t Nx)
262 //--------------------------------------------------------------
263 // Constructor
264 //--------------------------------------------------------------
265  : XX1(Nl+1,Nm+1), XX2(Nl+1,Nm+1), XX3(Nl+1,Nm+1), XX4(Nl+1,Nm+1),
266  A1(Nl+1,Nm+1), A2(Nl+1,Nm+1), fd1(Nl+1,Nm+1), fd2(Nl+1,Nm+1),
267  Hp0(Nl+1), H(Np,Nx), G(Np,Nx), TMP(Np,Nx),
268  pr(Algorithms::MakeCAxis(static_cast<complex<double> >(pmin),
269  static_cast<complex<double> >(pmax),
270  Np)),
271  invpr(pr), szx(Nx)
272  {
273 // - - - - - - - - - - - - - - - - - - - - - - - - - - -
274  complex<double> lc, mc;
275 
276 // Inverted momentum axis
277  for (size_t i(0); i < pr.size(); ++i) {
278  invpr[i] = 1.0/pr[i];
279  }
280  idp = (-1.0)/ (2.0*(pmax-pmin)/double(Np)); // -1/(2dp)
281  idx = (-1.0) / (2.0*(xmax-xmin)/double(Nx)); // -1/(2dx)
282 
284 
285 // - - - - - - - - - - - - - - - - - - - - - - - - - - -
286 // Calculate the "A1, A2" parameters
287  for (size_t l(0); l < Nl+1; ++l){
288  for (size_t m=0; m<((Nm<l)?Nm:l)+1; ++m){
289  lc = static_cast< complex<double> >(l);
290  mc = static_cast< complex<double> >(m);
291  XX1(l,m) = (lc+mc ) * (lc-mc ) / (2.0*lc-1.0) / (2.0*lc+1.0) ;
292  XX2(l,m) = (lc-mc+1.0) * (lc+mc+1.0) / (2.0*lc+3.0) / (2.0*lc+1.0) ;
293 
294  XX3(l,m) = (lc-mc+1.0) * (lc-mc+2.0) / (2.0*lc+3.0) / (2.0*lc+1.0) ;
295  XX4(l,m) = (lc+mc-1.0) * (lc+mc ) / (2.0*lc-1.0) / (2.0*lc+1.0) ; //idx *(-1.0) * (lc-mc+1.0) / (2.0*lc+1.0);
296  }
297  }
298  A2(0,0) = 1.0;
299  // -2*Dp*H at the 0 momentum cell
300  Hp0[0] = 1.0 / pr[0];
301  for (size_t l(1); l < Nl+1; ++l) {
302  double ld(l);
303  Hp0[l] = Hp0[l-1] * (pr[0]/pr[1]) * (2.0*ld+1.0)/(2.0*ld-1.0);
304  }
305  Hp0 *= (-2.0)*(pr[1]-pr[0]);
306  }
307 //--------------------------------------------------------------
308 
309 //--------------------------------------------------------------
310 // Advection in x
311 void Hydro_Advection_1D::operator()(const DistFunc1D& Din, const Hydro1D& hydro, DistFunc1D& Dh) {
312 //--------------------------------------------------------------
313 
314  valarray<complex<double> > vt(pr); vt *= 1.0/Din.mass();
315  valarray<complex<double> > tempv(vt);
316 
317 
318  valarray<complex<double> > Ux(0.0,(hydro.vxarray()).size());
319  valarray<complex<double> > dUxdx(0.0,(hydro.vxarray()).size());
320 
321 
322  Ux[0] = hydro.vx(0);
323  dUxdx[0] = idx*(hydro.vx(1)-hydro.vx(0));
324 
325  Ux[szx-1] = hydro.vx(szx-1);
326  dUxdx[szx-1] = idx*(hydro.vx(szx-1)-hydro.vx(szx-2));
327  for (size_t i(1);i<szx-1;++i)
328  {
329  Ux[i] = hydro.vx(i);
330  // dUxdx[i] = idx/12.0*(-hydro.vx(i+2)+8.0*(hydro.vx(i+1)-hydro.vx(i-1))+hydro.vx(i-2));
331  dUxdx[i] = idx*0.5*(hydro.vx(i+1)-hydro.vx(i-1));
332  // dUxdx[i] = idx/3.0*(-Cx[i+3]+6.0*Cx[i+2]-3.0*Cx[i+1]-2.0*Cx[i]);
333  }
334 
335 
336  // vt += fluidvx;
337  size_t l0(Din.l0());
338  size_t m0(Din.m0());
339 
340  SHarmonic1D tG(G), tH(H);
341 
342  // dCdx df/dv term
343  TMP = Din(0,0); //fd1 = fd1.Dx();
344  MakeGH(TMP, 0); MakeG00(TMP); tH=H;tG=G;
345 
346  tempv = vt * XX1(0,0); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(0,0) += tH; tH = H;
347  tempv = vt * XX2(0,0); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(0,0) += tG; tG = G;
348  tempv = vt * XX3(0,0); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(2,0) += tG;
349 
350  // Dh.checknan();
351 
352  TMP = Din(1,0); //fd1 = fd1.Dx();
353  MakeGH(TMP,1); tH=H;tG=G;
354  tempv = vt * XX1(1,0); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(1,0) += tH; tH = H;
355  tempv = vt * XX2(1,0); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(1,0) += tG; tG = G;
356  tempv = vt * XX3(1,0); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(3,0) += tG;
357 
358  // Dh.checknan();
359 
360  TMP = Din(1,1);
361  MakeGH(TMP,1); tH=H;tG=G;
362  tempv = vt * XX1(1,1); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(1,1) += tH; tH = H;
363  tempv = vt * XX2(1,1); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(1,1) += tG; tG = G;
364  tempv = vt * XX3(1,1); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(3,1) += tG; tG = G;
365  // tempv = vt * 1.0;
366 
367  MakeGH(TMP,l0); tH=H;tG=G;
368  for (size_t m(0); m<((m0<l0-1)?(m0+1):(l0-1)); ++m){
369  TMP = Din(l0,m);
370  tempv = vt * XX1(l0,m); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(l0,m) += tH; tH = H;
371  tempv = vt * XX2(l0,m); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(l0,m) += tG; tG = G;
372  tempv = vt * XX4(l0,m); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(l0-2,m) += tG; tG = G;
373  // tempv = vt * 1.0);
374  }
375  for (size_t m(l0-2); m<((m0<l0)?(m0):(l0+1)); ++m){
376  // TMP = Din(l0,m); //fd1 = fd1.Dx();
377  tempv = vt * XX1(l0,m); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(l0,m) += tH; tH = H;
378  tempv = vt * XX2(l0,m); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(l0,m) += tG; tG = G;
379  // tempv = vt * XX4(l0,m)); TMP = H.mpaxis(tempv); Dh(l0-2,m) += TMP;
380  // tempv = vt * 1.0);
381  }
382 
383 
384  MakeGH(TMP,l0-1); tH=H;tG=G;
385  for (size_t m(0); m<((m0<l0-2)?(m0+1):(l0-2)); ++m){
386  // TMP = Din(l0-1,m); //fd1 = fd1.Dx();
387  tempv = vt * XX1(l0-1,m); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(l0-1,m) += tH; tH = H;
388  tempv = vt * XX2(l0-1,m); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(l0-1,m) += tG; tG = G;
389  tempv = vt * XX4(l0-1,m); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(l0-3,m) += tH; tH = H;
390  // tempv = vt * 1.0;
391  }
392 
393  for (size_t m(l0-3); m<((m0<l0)?(m0+1):(l0+1)); ++m){
394  // TMP = Din(l0-1,m); //fd1 = fd1.Dx();
395  tempv = vt * XX1(l0-1,m); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(l0-1,m) += tH; tH = H;
396  tempv = vt * XX2(l0-1,m); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(l0-1,m) += tG; tG = G;
397  // tempv = vt * 1.0,m);
398  }
399 
400  for (size_t l(2); l<l0-1; ++l){
401  MakeGH(TMP,l); tH=H;tG=G;
402  for (size_t m(0); m < ((m0<l+1)?(m0+1):(l+1)); ++m){
403  tempv = vt * XX1(l,m); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(l,m) += tH; tH = H;
404  tempv = vt * XX2(l,m); tG.mpaxis(tempv); tG.mxaxis(dUxdx); Dh(l,m) += tG; tG = G;
405  // tempv = vt * 1.0;
406  }
407 
408  for (size_t m(0); m < ((m0<l-1)?(m0+1):(l-1)); ++m){
409  tempv = vt * XX4(l,m); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(l-2,m) += tH; tH = H;
410  }
411 
412  for (size_t m(0); m < ((m0<l+3)?(m0+1):(l+3)); ++m){
413  tempv = vt * XX3(l,m); tH.mpaxis(tempv); tH.mxaxis(dUxdx); Dh(l+2,m) += tH; tH = H;
414  // tempv = vt * 1.0;
415  }
416  }
417 
418  // C df/dr term
419  for (size_t m(0); m < ((m0<l0)?(m0+1):m0); ++m){
420 
421  tH = Din(m,m); tH = tH.Dx();
422  for (int ip(0); ip<tH.nump(); ++ip) tH(ip,Din(0,0).numx()-1) = 0.0;
423  Dh(m,m) += tH.mxaxis(Ux);
424 
425  for (size_t l(m+1); l < l0; ++l) {
426  tH = Din(l,m); tH = tH.Dx();
427  for (int ip(0); ip<tH.nump(); ++ip) tH(ip,Din(0,0).numx()-1) = 0.0;
428 
429  Dh(l,m) += tH.mxaxis(Ux);
430 
431  }
432 
433  tH = Din(l0,m); tH = tH.Dx();
434  for (int ip(0); ip<tH.nump(); ++ip) tH(ip,Din(0,0).numx()-1) = 0.0;
435 
436  Dh(l0,m) += tH.mxaxis(Ux);
437 
438 
439  }
440 }
441 
442 //--------------------------------------------------------------
443 //--------------------------------------------------------------
444 // Make derivatives 2*Dp*(l+1/l)*G and -2*Dp*H for a given f
446 //--------------------------------------------------------------
447  valarray<complex<double> > invpax(invpr);
448  complex<double> ld(el);
449 
450  invpax *= (-2.0)*(ld+1.0) * (pr[1]-pr[0]);
451 
452  G = f; H = f;
453  G = G.Dp();
454  H = H.mpaxis(invpax);
455  H += G;
456  G *= -(2.0*ld+1.0)/ld;
457  G += H;
458 
459  for (size_t i(0); i < G.numx(); ++i) G(0,i) = 0.0;
460  for (size_t i(0); i < H.numx(); ++i) H(0,i) = f(1,i) * Hp0[el];
461  }
462 //--------------------------------------------------------------
463 // Calculation of G00 = -2*Dp* df/dp(p0)
465 //--------------------------------------------------------------
466  G = f; G = G.Dp();
467 
468  complex<double> p0p1_sq( pr[0]*pr[0]/(pr[1]*pr[1]) ),
469  inv_mp0p1_sq( 1.0/(1.0-p0p1_sq) ),
470  g_r = -4.0*(pr[1]-pr[0]) * pr[0]/(pr[1]*pr[1]),
471  f00;
472 
473  for (size_t i(0); i < f.numx(); ++i) {
474  f00 = ( f(0,i) - f(1,i) * p0p1_sq) * inv_mp0p1_sq;
475  G(0,i) = ( f(1,i) - f00) * g_r;
476  }
477  }
478 
479 //--------------------------------------------------------------
void velocity(const State1D &Yin, Hydro1D &Hslope, valarray< double > &electrondensity, valarray< double > &electronpressure, Array2D< double > &electroncurrent)
Definition: fluid.cpp:112
SHarmonic1D H
Definition: fluid.h:76
Algorithms
Plasma Formulary and Units - Declarations.
Fluid_Equation_1D(double xmin, double xmax, size_t Nx)
Constructors/Destructors.
Definition: fluid.cpp:65
valarray< double > getpressure()
Definition: state.cpp:1081
double idp
Definition: fluid.h:82
Field1D & By()
Definition: state.h:294
Input reader - Declarations.
valarray< double > df_4thorder(const valarray< double > &f)
Definition: nmethods.cpp:421
Underlying data structures.
double idx
Evaluate Quantities from Distribution Functions.
Definition: fluid.h:31
Array2D< complex< double > > XX2
Definition: fluid.h:78
A Collection of relevant 1D Hydrodynamic Quantities.
Definition: state.h:507
void operator()(const DistFunc1D &Din, const Hydro1D &hydro, DistFunc1D &Dh)
Definition: fluid.cpp:311
void density(const Hydro1D &Hin, Hydro1D &Hslope)
Momentum (and Energy and Density?) Update.
Definition: fluid.cpp:74
Fluid_Equation_1D FEQ
Definition: fluid.h:56
double mass() const
Definition: state.h:400
valarray< complex< double > > pr
Definition: fluid.h:80
Array2D< complex< double > > A2
Definition: fluid.h:79
size_t szx
Definition: fluid.h:81
double & vz(size_t i)
Definition: state.h:536
size_t numx() const
Definition: state.h:72
double idx
Definition: fluid.h:82
Field1D & Ez()
Definition: state.h:292
Array2D< complex< double > > XX1
Definition: fluid.h:78
A 1D Spherical Harmonic.
Definition: state.h:57
Array2D< complex< double > > XX4
Definition: fluid.h:78
SHarmonic1D & Dp()
Definition: state.cpp:139
Definition: state.h:577
Field1D & Bx()
Definition: state.h:293
Hydro1D & HYDRO()
Definition: state.h:613
double & temperature(size_t i)
Definition: state.h:539
double & Z(size_t i)
Definition: state.h:542
size_t szx
Definition: fluid.h:55
valarray< complex< double > > Hp0
Definition: fluid.h:80
void chargefraction(const Hydro1D &Hin, Hydro1D &Hslope)
Definition: fluid.cpp:93
double mass() const
Definition: state.h:523
size_t m0() const
Definition: state.h:397
Field1D & Bz()
Definition: state.h:295
DistFunc1D & DF(size_t s)
Definition: state.h:602
void MakeG00(SHarmonic1D &f)
Definition: fluid.cpp:464
double idx
Definition: fluid.h:54
void updateE(Hydro1D &HYDRO, EMF1D &EMF)
Electric Field Update.
Definition: fluid.cpp:215
Fields, Distributions, Harmonics, States - Declarations.
Field1D & Ex()
Definition: state.h:290
SHarmonic1D TMP
Definition: fluid.h:76
valarray< double > & densityarray() const
Definition: state.h:545
valarray< double > getdensity()
Definition: state.cpp:945
Definition: state.h:271
valarray< complex< double > > invpr
Definition: fluid.h:80
double & vx(size_t i)
Definition: state.h:530
size_t Nbc
Definition: fluid.h:32
void operator()(const State1D &Hin, State1D &Hslope)
Definition: fluid.cpp:40
valarray< T > MakeCAxis(const T min, const T max, const size_t N)
Input_List & List()
Definition: input.cpp:1585
double & density(size_t i)
Definition: state.h:527
size_t szx
Definition: fluid.h:32
Field1D & Ey()
Definition: state.h:291
size_t l0() const
Definition: state.h:396
double & vy(size_t i)
Definition: state.h:533
SHarmonic1D G
Definition: fluid.h:76
valarray< double > & vxarray() const
Definition: state.h:546
Array2D< complex< double > > XX3
Definition: fluid.h:78
size_t Nbc
Definition: fluid.h:81
int BoundaryCells
Definition: input.h:50
double charge() const
Definition: state.h:524
The 1D distribution function is the container for all SHarmonic1D per species.
Definition: state.h:376
Hydro_Functor(double xmin, double xmax, size_t numx)
Constructor for hydro equations.
Definition: fluid.cpp:36
EMF1D & EMF() const
Definition: state.h:610
Hydro_Advection_1D(size_t Nl, size_t Nm, double pmin, double pmax, size_t Np, double xmin, double xmax, size_t Nx)
Definition: fluid.cpp:259
SHarmonic1D & mpaxis(const valarray< complex< double > > &shmulti)
Definition: state.cpp:122
void MakeGH(SHarmonic1D &f, size_t l)
Definition: fluid.cpp:445
Numerical Methods - Declarations.