-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Generalize wind farm parametrization (#1511)
* Generalizing Fitch * WIP: Generalizing Fitch * Minor changes * Reverting changes for inputs * Remove unwanted function * Adding ifdef to plotfile * Some minor changes to comments * Adding params to inputs * Adding params to inputs --------- Co-authored-by: Mahesh Natarajan <[email protected]> Co-authored-by: Aaron M. Lattanzi <[email protected]>
- Loading branch information
1 parent
5258b98
commit c8677ef
Showing
9 changed files
with
241 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# ------------------ INPUTS TO MAIN PROGRAM ------------------- | ||
max_step = 10 | ||
|
||
amrex.fpe_trap_invalid = 1 | ||
|
||
fabarray.mfiter_tile_size = 1024 1024 1024 | ||
|
||
# PROBLEM SIZE & GEOMETRY | ||
erf.windfarm_type = "Fitch" | ||
erf.latitude_lo = 35.0 | ||
erf.longitude_lo = -100.0 | ||
geometry.prob_extent = 534000 389000 20000 | ||
amr.n_cell = 32 32 64 | ||
|
||
#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.fixed_dt = 0.005 # fixed time step depending on grid resolution | ||
|
||
# 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 = -1 # number of timesteps between checkpoints | ||
|
||
# PLOTFILES | ||
erf.plot_file_1 = plt # prefix of plotfile name | ||
erf.plot_int_1 = 1000 # number of timesteps between plotfiles | ||
erf.plot_vars_1 = density rhoadv_0 x_velocity y_velocity z_velocity pressure temp theta QKE num_turb | ||
|
||
# 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" | ||
|
||
|
||
# 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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* \file ERF_init_windfarm.cpp | ||
*/ | ||
|
||
#include <ERF.H> | ||
|
||
using namespace amrex; | ||
|
||
/** | ||
* Read in the turbine locations in latitude-longitude from windturbines.txt | ||
* and convert it into x and y coordinates in metres | ||
* | ||
* @param lev Integer specifying the current level | ||
*/ | ||
void | ||
ERF::init_windfarm (int lev) | ||
{ | ||
// Read turbine locations from windturbines.txt | ||
FILE *file_windturbines; | ||
file_windturbines = fopen("windturbines.txt","r"); | ||
std::ifstream file("windturbines.txt"); | ||
if (!file.is_open()) { | ||
amrex::Error("Wind turbines location file windturbines.txt not found"); | ||
} | ||
// Vector of vectors to store the matrix | ||
std::vector<Real> lat, lon, xloc, yloc; | ||
Real value1, value2, value3; | ||
while (file >> value1 >> value2 >> value3) { | ||
lat.push_back(value1); | ||
lon.push_back(value2); | ||
} | ||
file.close(); | ||
|
||
Real rad_earth = 6371.0e3; // Radius of the earth | ||
Real lat_lo = solverChoice.latitude_lo*M_PI/180.0; | ||
Real lon_lo = solverChoice.longitude_lo*M_PI/180.0; | ||
|
||
// (lat_lo, lon_lo) is mapped to (0,0) | ||
|
||
for(int it=0;it<lat.size();it++){ | ||
lat[it] = lat[it]*M_PI/180.0; | ||
lon[it] = lon[it]*M_PI/180.0; | ||
Real delta_lat = (lat[it] - lat_lo); | ||
Real delta_lon = (lon[it] - lon_lo); | ||
|
||
Real term1 = std::pow(sin(delta_lat/2.0),2); | ||
Real term2 = cos(lat[it])*cos(lat_lo)*std::pow(sin(delta_lon/2.0),2); | ||
Real dist = 2.0*rad_earth*std::asin(std::sqrt(term1 + term2)); | ||
Real dy_turb = (lat[it] - lat_lo) * 111000.0 * 180.0/M_PI ; | ||
yloc.push_back(dy_turb); | ||
Real dx_turb = std::sqrt(std::pow(dist,2) - std::pow(dy_turb,2)); | ||
xloc.push_back(dx_turb); | ||
} | ||
|
||
// Write out a vtk file for turbine locations | ||
if (ParallelDescriptor::IOProcessor()){ | ||
FILE* file_turbloc_vtk; | ||
file_turbloc_vtk = fopen("turbine_locations.vtk","w"); | ||
fprintf(file_turbloc_vtk, "%s\n","# vtk DataFile Version 3.0"); | ||
fprintf(file_turbloc_vtk, "%s\n","Wind turbine locations"); | ||
fprintf(file_turbloc_vtk, "%s\n","ASCII"); | ||
fprintf(file_turbloc_vtk, "%s\n","DATASET POLYDATA"); | ||
fprintf(file_turbloc_vtk, "%s %ld %s\n", "POINTS", xloc.size(), "float"); | ||
for(int it=0; it<xloc.size(); it++){ | ||
fprintf(file_turbloc_vtk, "%0.15g %0.15g %0.15g\n", xloc[it], yloc[it], 1e-12); | ||
} | ||
fclose(file_turbloc_vtk); | ||
} | ||
|
||
Nturb[lev].setVal(0); | ||
|
||
int i_lo = geom[lev].Domain().smallEnd(0); int i_hi = geom[lev].Domain().bigEnd(0); | ||
int j_lo = geom[lev].Domain().smallEnd(1); int j_hi = geom[lev].Domain().bigEnd(1); | ||
|
||
// Initialize wind farm | ||
for ( MFIter mfi(Nturb[lev],TilingIfNotGPU()); mfi.isValid(); ++mfi) { | ||
const Box& bx = mfi.tilebox(); | ||
auto Nturb_array = Nturb[lev].array(mfi); | ||
ParallelFor(bx, [=] AMREX_GPU_DEVICE(int i, int j, int k) noexcept { | ||
int li = amrex::min(amrex::max(i, i_lo), i_hi); | ||
int lj = amrex::min(amrex::max(j, j_lo), j_hi); | ||
|
||
auto dx = geom[lev].CellSizeArray(); | ||
Real x1 = li*dx[0], x2 = (li+1)*dx[0]; | ||
Real y1 = lj*dx[1], y2 = (lj+1)*dx[1]; | ||
|
||
for(int it=0; it<xloc.size(); it++){ | ||
if( xloc[it]+1e-12 > x1 and xloc[it]+1e-12 < x2 and | ||
yloc[it]+1e-12 > y1 and yloc[it]+1e-12 < y2){ | ||
Nturb_array(i,j,k,0) = Nturb_array(i,j,k,0) + 1; | ||
} | ||
} | ||
}); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters