From 6f18955e42f3cca7438876e2e27257adffe083b1 Mon Sep 17 00:00:00 2001 From: Mahesh Natarajan Date: Mon, 1 Apr 2024 12:50:55 -0700 Subject: [PATCH] Testing Fitch and restart implementation (#1545) * Testing Fitch and restart implementation * Removing unwanted file --------- Co-authored-by: Mahesh Natarajan --- Exec/Fitch/inputs_Fitch_Testing | 79 +++++++++++++++++++ Exec/Fitch/windturbines.txt | 55 ++++++------- Exec/Fitch/windturbines.txt_LargeDomain | 30 +++++++ Source/IO/Checkpoint.cpp | 22 +++++- Source/Initialization/ERF_init_windfarm.cpp | 6 +- .../Fitch/AdvanceFitch.cpp | 9 +-- 6 files changed, 163 insertions(+), 38 deletions(-) create mode 100644 Exec/Fitch/inputs_Fitch_Testing create mode 100644 Exec/Fitch/windturbines.txt_LargeDomain diff --git a/Exec/Fitch/inputs_Fitch_Testing b/Exec/Fitch/inputs_Fitch_Testing new file mode 100644 index 000000000..8514c9cb7 --- /dev/null +++ b/Exec/Fitch/inputs_Fitch_Testing @@ -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 + diff --git a/Exec/Fitch/windturbines.txt b/Exec/Fitch/windturbines.txt index 586e94b81..85d189cdf 100644 --- a/Exec/Fitch/windturbines.txt +++ b/Exec/Fitch/windturbines.txt @@ -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 diff --git a/Exec/Fitch/windturbines.txt_LargeDomain b/Exec/Fitch/windturbines.txt_LargeDomain new file mode 100644 index 000000000..586e94b81 --- /dev/null +++ b/Exec/Fitch/windturbines.txt_LargeDomain @@ -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 diff --git a/Source/IO/Checkpoint.cpp b/Source/IO/Checkpoint.cpp index 020972485..1f168c076 100644 --- a/Source/IO/Checkpoint.cpp +++ b/Source/IO/Checkpoint.cpp @@ -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); mvarboxArray(); @@ -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); mvarboxArray(); diff --git a/Source/Initialization/ERF_init_windfarm.cpp b/Source/Initialization/ERF_init_windfarm.cpp index fbcd45ee3..7963ac01d 100644 --- a/Source/Initialization/ERF_init_windfarm.cpp +++ b/Source/Initialization/ERF_init_windfarm.cpp @@ -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> wind_speed[iline] >> thrust_coeff[iline] >> power[iline]; } diff --git a/Source/WindFarmParametrization/Fitch/AdvanceFitch.cpp b/Source/WindFarmParametrization/Fitch/AdvanceFitch.cpp index a975f1d78..3d52c9eba 100644 --- a/Source/WindFarmParametrization/Fitch/AdvanceFitch.cpp +++ b/Source/WindFarmParametrization/Fitch/AdvanceFitch.cpp @@ -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) { @@ -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";