Beispiel #1
0
int physics_init()
{
  // 2D initial profiles
  Field2D rho0, p0;
  Vector2D v0, B0;

  // read options
  options.setSection("mhd");
  OPTION(gamma,          5.0/3.0);
  OPTION(include_viscos, false);
  OPTION(viscos,         0.1);


  // Read 2D initial profiles
  GRID_LOAD(rho0);
  GRID_LOAD(p0);
  v0.covariant = true; // Read covariant components of v0
  GRID_LOAD(v0);
  B0.covariant = false; // Read contravariant components of B0
  GRID_LOAD(B0);

  // tell BOUT which variables to evolve
  
  bout_solve(rho, F_rho, "density");
  bout_solve(p, F_p, "pressure");
  v.covariant = true; // evolve covariant components
  bout_solve(v, F_v, "v");
  B.covariant = false; // evolve contravariant components
  bout_solve(B, F_B, "B");

  output.write("dx[0,0] = %e, dy[0,0] = %e, dz = %e\n", dx[0][0], dy[0][0], dz);

  dump.add(divB, "divB", 1);

  if(!restarting) {
    // Set variables to these values (+ the initial perturbation)
    // NOTE: This must be after the calls to bout_solve
    rho += rho0;
    p += p0;
    v += v0;
    B += B0;
    
    // Added this for modifying the Orszag-Tang vortex problem
    real v_fact;
    options.get("v_fact",         v_fact,         1.0);
    v *= v_fact;
  }

  // Set communications
  
  comms.add(rho);
  comms.add(p);
  comms.add(v);
  comms.add(B);

  return 0;
}
Beispiel #2
0
int physics_init()
{
  real v0_multiply;

  // Read initial conditions

  grid_load2d(N0, "density");
  grid_load2d(P0, "pressure");
  V0.covariant = false; // Read contravariant components
  V.covariant = false; // Evolve contravariant components
  grid_load2d(V0, "v");
  g.covariant = false;
  grid_load2d(g, "g");
  
  // read options
  
  options.setSection("gas");
  
  options.get("gamma",  gamma_ratio, 5.0/3.0);
  options.get("viscosity", nu, 0.1);
  options.get("include_viscosity", include_viscosity, false);
  options.get("v0_multiply", v0_multiply, 1.0);
  options.get("sub_initial", sub_initial, false);

  V0 *= v0_multiply;

  // Set evolving variables
  
  bout_solve(N, F_N, "density");
  bout_solve(P, F_P, "pressure");
  bout_solve(V, F_V, "v");

  if(!restarting) {
    // Apply boundary conditions
    apply_boundary(N, "density");
    apply_boundary(P, "pressure");
    V.to_contravariant();
    apply_boundary(V, "v");

    // Set variables to these values (+ the initial perturbation)
    // NOTE: This must be after the calls to bout_solve
    N += N0;
    P += P0;
    V += V0;

  }

  // set communications
  comms.add(N);
  comms.add(P);
  comms.add(V);
  
  return 0;
}
Beispiel #3
0
int physics_init()
{
  Field2D I; // Shear factor 
  
  output.write("Solving 6-variable 2-fluid equations\n");

  /************* LOAD DATA FROM GRID FILE ****************/

  // Load 2D profiles (set to zero if not found)
  GRID_LOAD(Ni0);
  GRID_LOAD(Ti0);
  GRID_LOAD(Te0);
  GRID_LOAD(Vi0);

  // Load metrics
  GRID_LOAD(Rxy);
  GRID_LOAD(Bpxy);
  GRID_LOAD(Btxy);
  GRID_LOAD(hthe);
  grid.get(dx,   "dpsi");

  // Load normalisation values
  GRID_LOAD(Te_x);
  GRID_LOAD(Ti_x);
  GRID_LOAD(Ni_x);
  GRID_LOAD(bmag);

  Ni_x *= 1.0e14;
  bmag *= 1.0e4;

  /*************** READ OPTIONS *************************/

  // Read some parameters
  options.setSection("2fluid");
  OPTION(AA, 2.0);
  OPTION(ZZ, 1.0);

  OPTION(chi_perp,  0.6); // Read in m^2 / s 
  OPTION(D_perp,    0.6);
  OPTION(mu_perp,   0.6);

  OPTION(lambda_relax, 10.0);
  
  /************** CALCULATE PARAMETERS *****************/

  rho_s = 1.02*sqrt(AA*Te_x)/ZZ/bmag;
  fmei  = 1./1836.2/AA;

  lambda_ei = 24.-log(sqrt(Ni_x)/Te_x);
  lambda_ii = 23.-log(ZZ*ZZ*ZZ*sqrt(2.*Ni_x)/pow(Ti_x, 1.5));
  wci       = 9.58e3*ZZ*bmag/AA;
  nueix     = 2.91e-6*Ni_x*lambda_ei/pow(Te_x, 1.5);
  nuiix     = 4.78e-8*pow(ZZ,4.)*Ni_x*lambda_ii/pow(Ti_x, 1.5)/sqrt(AA);

  Vi_x = wci * rho_s;

  /************** PRINT Z INFORMATION ******************/
  
  real hthe0;
  if(GRID_LOAD(hthe0) == 0) {
    output.write("    ****NOTE: input from BOUT, Z length needs to be divided by %e\n", hthe0/rho_s);
  }

  /************** NORMALISE QUANTITIES *****************/

  output.write("\tNormalising to rho_s = %e\n", rho_s);

  // Normalise profiles
  Ni0 /= Ni_x/1.0e14;
  Ti0 /= Te_x;
  Te0 /= Te_x;
  Vi0 /= Vi_x;

   // Normalise geometry 
  Rxy /= rho_s;
  hthe /= rho_s;
  dx /= rho_s*rho_s*(bmag/1e4);

  // Normalise magnetic field
  Bpxy /= (bmag/1e4);
  Btxy /= (bmag/1e4);
  Bxy  /= (bmag/1e4);

  // calculate pressures
  pei0 = (Ti0 + Te0)*Ni0;
  pe0 = Te0*Ni0;

  // Normalise coefficients
  chi_perp /= rho_s*rho_s*wci;
  D_perp   /= rho_s*rho_s*wci;
  mu_perp  /= rho_s*rho_s*wci;

  chi_perp = 0.1;
  D_perp = 0.1;
  mu_perp = 0.1;
  
  output.write("Diffusion coefficients: chi %e D %e Mu %e\n",
	       chi_perp, D_perp, mu_perp);

  /**************** CALCULATE METRICS ******************/

  g11 = (Rxy*Bpxy)^2;
  g22 = 1.0 / (hthe^2);
  g33 = (Bxy^2)/g11;
  g12 = 0.0;
  g13 = 0.0;
  g23 = -Btxy/(hthe*Bpxy*Rxy);
  
  J = hthe / Bpxy;
  
  g_11 = 1.0/g11;
  g_22 = (Bxy*hthe/Bpxy)^2;
  g_33 = Rxy*Rxy;
  g_12 = 0.0;
  g_13 = 0.0;
  g_23 = Btxy*hthe*Rxy/Bpxy;


  /**************** SET EVOLVING VARIABLES *************/

  // Tell BOUT++ which variables to evolve
  // add evolving variables to the communication object

  Ni = Vi = Te = Ti = 0.0;
  bout_solve(Ni,    F_Ni,    "Ni");
  bout_solve(Vi,    F_Vi,    "Vi");
  bout_solve(Te,    F_Te,    "Te");
  bout_solve(Ti,    F_Ti,    "Ti");

  comms.add(Ni);
  comms.add(Vi);
  comms.add(Te);
  comms.add(Ti);

  /************** SETUP COMMUNICATIONS **************/
  
  // Add any other variables to be dumped to file
  dump.add(Ni0, "Ni0", 0);
  dump.add(Te0, "Te0", 0);
  dump.add(Ti0, "Ti0", 0);

  dump.add(Te_x,  "Te_x", 0);
  dump.add(Ti_x,  "Ti_x", 0);
  dump.add(Ni_x,  "Ni_x", 0);
  dump.add(rho_s, "rho_s", 0);
  dump.add(wci,   "wci", 0);

  return(0);
}