Skip to content

Commit

Permalink
Testing Fitch and restart implementation (#1545)
Browse files Browse the repository at this point in the history
* Testing Fitch and restart implementation

* Removing unwanted file

---------

Co-authored-by: Mahesh Natarajan <[email protected]>
  • Loading branch information
nataraj2 and Mahesh Natarajan authored Apr 1, 2024
1 parent 7f701af commit 6f18955
Show file tree
Hide file tree
Showing 6 changed files with 163 additions and 38 deletions.
79 changes: 79 additions & 0 deletions Exec/Fitch/inputs_Fitch_Testing
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# ------------------ INPUTS TO MAIN PROGRAM -------------------
max_step = 200

amrex.fpe_trap_invalid = 1

fabarray.mfiter_tile_size = 1024 1024 1024

# PROBLEM SIZE & GEOMETRY
erf.latitude_lo = 35.0
erf.longitude_lo = -100.0
geometry.prob_extent = 200150 202637 1000
amr.n_cell = 50 50 40

#erf.grid_stretching_ratio = 1.025
#erf.initial_dz = 16.0

geometry.is_periodic = 0 0 0

# MOST BOUNDARY (DEFAULT IS ADIABATIC FOR THETA)
#zlo.type = "MOST"
#erf.most.z0 = 0.1
#erf.most.zref = 8.0

zlo.type = "SlipWall"
zhi.type = "SlipWall"

xlo.type = "Outflow"
xhi.type = "Outflow"
ylo.type = "Outflow"
yhi.type = "Outflow"

# TIME STEP CONTROL
erf.use_native_mri = 1
erf.fixed_dt = 0.0025 # fixed time step depending on grid resolution
#erf.fixed_fast_dt = 0.0025

# DIAGNOSTICS & VERBOSITY
erf.sum_interval = 1 # timesteps between computing mass
erf.v = 1 # verbosity in ERF.cpp
amr.v = 1 # verbosity in Amr.cpp

# REFINEMENT / REGRIDDING
amr.max_level = 0 # maximum level number allowed

# CHECKPOINT FILES
erf.check_file = chk # root name of checkpoint file
erf.check_int = 100 # number of timesteps between checkpoints
#erf.restart = chk00100

# PLOTFILES
erf.plot_file_1 = plt # prefix of plotfile name
erf.plot_int_1 = 10000 # number of timesteps between plotfiles
erf.plot_vars_1 = density rhoadv_0 x_velocity y_velocity z_velocity pressure temp theta QKE

# SOLVER CHOICE
erf.alpha_T = 0.0
erf.alpha_C = 1.0
erf.use_gravity = false

erf.molec_diff_type = "None"
erf.les_type = "None"
erf.Cs = 1.5
erf.dynamicViscosity = 0.0

erf.pbl_type = "None"

erf.init_type = "uniform"

erf.windfarm_type = "Fitch"

# PROBLEM PARAMETERS
prob.rho_0 = 1.0
prob.A_0 = 1.0

prob.U_0 = 10.0
prob.V_0 = 10.0
prob.W_0 = 0.0
prob.T_0 = 300.0

55 changes: 25 additions & 30 deletions Exec/Fitch/windturbines.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
36.732 -97.128 1
36.824 -97.367 1
36.967 -96.754 1
36.607 -96.846 1
36.719 -97.249 1
36.889 -97.031 1
36.621 -96.932 1
36.752 -96.788 1
36.855 -97.421 1
36.694 -96.656 1
36.579 -97.223 1
36.912 -97.379 1
36.721 -96.815 1
36.685 -97.437 1
36.781 -97.049 1
36.936 -97.203 1
36.541 -96.791 1
36.655 -97.284 1
36.798 -96.695 1
36.887 -96.956 1
36.633 -96.716 1
36.912 -96.813 1
36.725 -96.579 1
36.594 -97.184 1
36.902 -97.354 1
36.628 -96.871 1
36.762 -97.428 1
36.811 -97.285 1
36.549 -97.492 1
36.642 -96.673 1
35.863963964 -98.9228 1
35.881981982 -98.9228 1
35.9 -98.9228 1
35.918018018 -98.9228 1
35.936036036 -98.9228 1
35.863963964 -98.9004 1
35.881981982 -98.9004 1
35.9 -98.9004 1
35.918018018 -98.9004 1
35.936036036 -98.9004 1
35.863963964 -98.878 1
35.881981982 -98.878 1
35.9 -98.878 1
35.918018018 -98.878 1
35.936036036 -98.878 1
35.863963964 -98.8556 1
35.881981982 -98.8556 1
35.9 -98.8556 1
35.918018018 -98.8556 1
35.936036036 -98.8556 1
35.863963964 -98.8332 1
35.881981982 -98.8332 1
35.9 -98.8332 1
35.918018018 -98.8332 1
35.936036036 -98.8332 1
30 changes: 30 additions & 0 deletions Exec/Fitch/windturbines.txt_LargeDomain
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
36.732 -97.128 1
36.824 -97.367 1
36.967 -96.754 1
36.607 -96.846 1
36.719 -97.249 1
36.889 -97.031 1
36.621 -96.932 1
36.752 -96.788 1
36.855 -97.421 1
36.694 -96.656 1
36.579 -97.223 1
36.912 -97.379 1
36.721 -96.815 1
36.685 -97.437 1
36.781 -97.049 1
36.936 -97.203 1
36.541 -96.791 1
36.655 -97.284 1
36.798 -96.695 1
36.887 -96.956 1
36.633 -96.716 1
36.912 -96.813 1
36.725 -96.579 1
36.594 -97.184 1
36.902 -97.354 1
36.628 -96.871 1
36.762 -97.428 1
36.811 -97.285 1
36.549 -97.492 1
36.642 -96.673 1
22 changes: 21 additions & 1 deletion Source/IO/Checkpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,22 @@ ERF::WriteCheckpointFile () const
// Write the precipitation accumulation component only
if (solverChoice.moisture_type == MoistureType::Kessler) {
ng = qmoist[lev][0]->nGrowVect();
int nvar = 1;
int nvar = 1;
MultiFab moist_vars(grids[lev],dmap[lev],nvar,ng);
MultiFab::Copy(moist_vars,*(qmoist[lev][0]),0,0,nvar,ng);
VisMF::Write(moist_vars, amrex::MultiFabFileFullPrefix(lev, checkpointname, "Level_", "MoistVars"));
}

#if defined(ERF_USE_WINDFARM)
if(solverChoice.windfarm_type == WindFarmType::Fitch){
ng = Nturb[lev].nGrowVect();
MultiFab mf_Nturb(grids[lev],dmap[lev],1,ng);
MultiFab::Copy(mf_Nturb,Nturb[lev],0,0,1,ng);
VisMF::Write(mf_Nturb, amrex::MultiFabFileFullPrefix(lev, checkpointname, "Level_", "NumTurb"));
}
#endif


if (solverChoice.lsm_type != LandSurfaceType::None) {
for (int mvar(0); mvar<lsm_data[lev].size(); ++mvar) {
BoxArray ba = lsm_data[lev][mvar]->boxArray();
Expand Down Expand Up @@ -375,6 +385,16 @@ ERF::ReadCheckpointFile ()
MultiFab::Copy(*(qmoist[lev][0]),moist_vars,0,0,nvar,ng);
}


#if defined(ERF_USE_WINDFARM)
if(solverChoice.windfarm_type == WindFarmType::Fitch){
ng = Nturb[lev].nGrowVect();
MultiFab mf_Nturb(grids[lev],dmap[lev],1,ng);
VisMF::Read(mf_Nturb, amrex::MultiFabFileFullPrefix(lev, restart_chkfile, "Level_", "NumTurb"));
MultiFab::Copy(Nturb[lev],mf_Nturb,0,0,1,ng);
}
#endif

if (solverChoice.lsm_type != LandSurfaceType::None) {
for (int mvar(0); mvar<lsm_data[lev].size(); ++mvar) {
BoxArray ba = lsm_data[lev][mvar]->boxArray();
Expand Down
6 changes: 5 additions & 1 deletion Source/Initialization/ERF_init_windfarm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,11 @@ ERF::init_windfarm (int lev)
power.resize(nlines);

file_turb_table >> hub_height >> rotor_dia >> thrust_coeff_standing >> nominal_power;
std::cout << hub_height << " " << rotor_dia << " " << thrust_coeff_standing << " " << nominal_power << "\n";
if(rotor_dia/2.0 > hub_height)
{
amrex::Abort("The blade length is more than the hub height. Check the second line in wind-turbine-1.tbl. Aborting.....");
}

for(int iline=0;iline<nlines;iline++){
file_turb_table >> wind_speed[iline] >> thrust_coeff[iline] >> power[iline];
}
Expand Down
9 changes: 3 additions & 6 deletions Source/WindFarmParametrization/Fitch/AdvanceFitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ using namespace amrex;

Real R = 30.0;
Real z_c = 100.0;
Real C_T = 0.5, C_TKE = 0.0;
Real Nturb = 2;
Real C_T = 0.8, C_TKE = 0.0;

Real compute_A(Real z)
{
Expand Down Expand Up @@ -138,19 +137,17 @@ void fitch_source_terms_cellcentered (const Geometry& geom,

// Compute Fitch source terms

if((i-10)*(i-12) <= 0.0 and (j-10)*(j-12) <= 0.0 and ((i-10)%2 == 0 or (j-10)%2==0)){
Real Vabs = std::pow(u_vel(i,j,k)*u_vel(i,j,k) +
v_vel(i,j,k)*v_vel(i,j,k) +
w_vel(i,j,k)*w_vel(i,j,k), 0.5);

fitch_array(i,j,k,0) = Vabs;
fitch_array(i,j,k,1) = -0.5*Nturb*C_T*Vabs*Vabs*A_ijk/(z_kp1 - z_k);
fitch_array(i,j,k,1) = -0.5*Nturb_array(i,j,k)*C_T*Vabs*Vabs*A_ijk/(z_kp1 - z_k);
fitch_array(i,j,k,2) = u_vel(i,j,k)/Vabs*fitch_array(i,j,k,1);
fitch_array(i,j,k,3) = v_vel(i,j,k)/Vabs*fitch_array(i,j,k,1);
fitch_array(i,j,k,4) = 0.5*Nturb*C_TKE*std::pow(Vabs,3)*A_ijk/(z_kp1 - z_k);
fitch_array(i,j,k,4) = 0.5*Nturb_array(i,j,k)*C_TKE*std::pow(Vabs,3)*A_ijk/(z_kp1 - z_k);

//amrex::Gpu::Atomic::Add(sum_area, A_ijk);
}
});
}
//std::cout << "Checking sum here...." <<"\n";
Expand Down

0 comments on commit 6f18955

Please sign in to comment.