Difference between revisions of "Synthetic Turbulence Inflow Generator"

From PHASTA Wiki
Jump to: navigation, search
(Settings)
(STGSpectra.dat)
Line 134: Line 134:
 
* Execution of the script (ln 48->end)
 
* Execution of the script (ln 48->end)
  
 +
The user-controlled inputs is the content in the function call and the settings below:
 
==== function call ====  
 
==== function call ====  
 
There are five inputs to this function call
 
There are five inputs to this function call

Revision as of 13:44, 24 February 2021

Synthetic Turbulence Inflow Generator (STG)

Overview

The Synthetic Turbulence Inflow generator is a method to produce an inflow boundary condition that results in turbulent flow in a short downstream distance. This method is desired to be more computationally efficient than resolving a flow through from transition. This page will cover the workflow to produce the necessary auxiliary files as well as included specifications for the solver.inp file for running a simulation with the STG boundary condition. There are three auxiliary files that are needed for the method in the n-procs_case directory at runtime:

  • STGInflow.dat
  • STGSpectra.dat
  • STGRand.dat

All of the mentioned MATLAB scripts in this page are in the STGInit subdirectory of the file structure contained in the PHASTA code-tree from github.

STGInflow.dat

This is a file that will contain the mean velocity profiles, mean cross correlation targets, and any additional turbulence modeled scalars.

STGSpectra.dat

This file will contain the N spectral modes for each node that has the STG the boundary condition.

STGRand.dat

This file will contain random numbers for the N spectral modes. This is not a spatially varying set of numbers as the spectra is.

Pre-Proccessing/Preparation of Auxiliary Files

Boundary Condition Attribute

Within the simmodeler or meshing tool, the face that is to have the STG boundary condition must have a specified SurfID attribute that will later match the specified in solver.inp. A typical value that has been given to this boundary condition within our group is 411.

STGInflow.dat

This auxiliary file will be required not only for the running of PHASTA, but also, will be required for the random number optimization. The user will need mean flow field data at the position of the inflow from some preliminary simulation such as RANS data or data repository. The code requires this file to have the following format:

N

d2wall_0 U_1(d2wall_0) U_2(d2wall_0) U_3(d2wall_0) uu(d2wall_0) vv(d2wall_0) ww(d2wall_0) uv(d2wall_0) uw(d2wall_0) vw(d2wall_0) sclr1(d2wall_0) sclr2(d2wall_0)

d2wall_1 U_1(d2wall_1) U_2(d2wall_1) U_3(d2wall_1) uu(d2wall_1) vv(d2wall_1) ww(d2wall_1) uv(d2wall_1) uw(d2wall_1) vw(d2wall_1) sclr1(d2wall_1) sclr2(d2wall_1)

d2wall_2 U_1(d2wall_2) U_2(d2wall_2) U_3(d2wall_2) uu(d2wall_2) vv(d2wall_2) ww(d2wall_2) uv(d2wall_2) uw(d2wall_2) vw(d2wall_2) sclr1(d2wall_2) sclr2(d2wall_2)

.

.

.

d2wall_N U_1(d2wall_N) U_2(d2wall_N) U_3(d2wall_N) uu(d2wall_N) vv(d2wall_N) ww(d2wall_N) uv(d2wall_N) uw(d2wall_N) vw(d2wall_N) sclr1(d2wall_N) sclr2(d2wall_N)



Where:

  • N is the number of rows that this file contains. It is the number of nodes in the specially varying direction.
  • d2wall is the distance to the wall
  • U_i are the three components of the average velocity feild
  • uu, vv, ww, uv, uw, vw are the averages of the Reynolds' stress tensor
  • sclr1 and sclr2 are the scalars that represent the turbulence model.

The input profiles are varied by the type of auxiliary simulation. So the post-processing of that preliminary simulation will be varied and so the generation of this data is left to the user. However for creating the STGInflow.dat file it is useful to know the format that the fortran file reader is setup for. The below chunk of MATLAB code is useful once the profiles are known:

 nPoints = length(d);
 [dSort,index]=sort(d);
 fid=fopen('STGINFLOWNAME.dat','w');
 fprintf(fid,'%d\n',nPoints);
 for j=1:nPoints
     i=index(j);
     tmp=[d(i) u(i,:) R(i,:) nut(i)];
     if (j~=nPoints)
         fprintf(fid,'%.12E %.12E %.12E %.12E %.12E %.12E %.12E %.12E %.12E %.12E %.12E\n',tmp);
     elseif (j==nPoints)
         fprintf(fid,'%.12E %.12E %.12E %.12E %.12E %.12E %.12E %.12E %.12E %.12E %.12E',tmp);
     end
 end
 fclose(fid);

STGSpectra.dat

This file will contain the spectral data at each nodal point within the mesh that is attributed with the STG attribute. To create this file we use the first of several scripts within the STGInit subdirectory of the github remote repository for PHASTA. Within MATLAB open STGspectra.m. The following is what you should see from the header of the file:

 1 %% Create STGspectra.dat
 2 % This script will produce spectral data for the implementation in PHASTA
 3 % This script's intention is to move the spectral data calculation out of
 4 % PHASTA so as to not require a call to PHASTA to gather such data. (A
 5 % wasteful thing to do when large meshes are investigated)
 6 
 7 % Authors: Ken Jansen, John Patterson
 8 % Version: 1.0 
 9 % Last mod: 7/3/2020
10 
11 
12 %STGspectra('exampleInput/LES_DNS_ReL1M_2d_KEJ_SAVEFILE.mat','exampleInput/LES_DNS_ReL1M_2d_KEJ.cnnTet',1,'/projects/tools/Models/STG/STG_tests/Post/analizeRand/RunTetRand_newRAND_2/',8)
13 function []=STGspectra(x_Path,conn_PATH,d2wall_Path,Run_Dir,nprocs)
14 tic
15 %% Preliminary Settings
16     nu=1.5E-5;
17 
18     %Specify how the d2wall field may be constructed
19     d2wall_tech='load';%'calculate ana';
20     %Specify (if nessicary), the path of the nodal data of the d2wall field
21     d2wall_Path='d2wall_ana.mat';%'none';
22 
23     %Specify the method to determine the nodes of the STGInflow plane
24     STG_node_choose='min_x';
25 
26     %Spesify the method by which the mesh data is structured 
27     struct_Spe='structured';
28 
29     %Settings found in solver.inp that are nessisary for using the
30     %STGInflow
31     deltaBL=0.05;
32     alphaWave=0.01;
33     setEps=17251.0;
34 
35 
36 %% Unfolding
37     nprocs_Dir                 =strcat(num2str(nprocs),'-procs_case/');
38     [x,ien,surround_nodes]     =importCords(x_Path,conn_PATH);
39     d2wall                     =importD2Wall(d2wall_tech,x,d2wall_Path);
40 
41 
42 %% Load in STGInflow and interpolate onto the inflow mesh
43     STGInflow_Path=[Run_Dir,nprocs_Dir,'STGInflow.dat'];
44     STGInflow=importSTGInflow(STGInflow_Path);
45 
46     [U,V,W,uu,vv,ww,uv,uw,vw,sclr1,sclr2,lt,eps,ch_decomp]=...
47         interpSTG(STGInflow,x,d2wall);%x(:,2));
48     if(~isnan(setEps))
49         eps=ones(length(x),1).*setEps;
50     end


This will be the standard format for many of the scripts in this subdirectory. That is,

  • Description/ Authors (ln 1->9)
  • function call/ function call example (ln 12->13)
  • Settings for each run (ln 15->33)
  • Loadins from other files (ln 36->47)
  • Execution of the script (ln 48->end)

The user-controlled inputs is the content in the function call and the settings below:

function call

There are five inputs to this function call

  • x_Path (str)
  • conn_Path (str)
    • x_Path and conn_Path are strings that point to files that are able to be interpreted by importCords.m. When these files read-in a .crd .cnn type files, they will output not only what is required for the STGspectra function call, but also a MATLAB .mat file that will append the names of the original data with '_SAVEFILE'. Loading in this .mat file is MUCH quicker than the .crd and .cnn raw data.
  • d2wall_Path (str)
    • d2wall_Path is a path to a MATLAB datafile containing the distance to the wall for each node in the mesh Unlike x_Path and conn_Path these two files are not required for the script to run properly SEE Settings for each run BELOW
  • nprocs (int)
    • this will be the number of processors that the case will use in the execution of PHASTA. In this script it is used to import the STGInflow.dat file.

Settings

There are 8 inputs to this function call

  • nu: the kinematic viscosity of the fluid
  • d2wall_tech: This is the technique by which the code will make the distance to the wall field. There are currently 5 options to this:
    • x_dir: Takes the x coordinate as the distance to the wall
    • y_dir: Takes the y coordinate as the distance to the wall
    • z_dir: Takes the z coordinate as the distance to the wall
    • calculate_ana: This will calculate the distance to the wall via the function handle that is specified in importD2Wall ln 17 (Please modify this if you wish to create your own d2wall function) Like the importCoords file this will output a matlab file containing the d2wall at d2wall_ana
    • load: this will load in the path specified from d2wall_Path
  • d2wall_Path: If you choose to load in a specific d2wall field that has been already saved this will be the path to that file
  • struct_Spe: Currently only 'structured' is supported. This is the orientation of the mesh.
  • deltaBL: This is the boundary layer thickness at the STG boundary condition.
  • alphaWave: This is the logarithmic growth of the spacing between one wavenumber and the next. It may be set from 0.05 to 0.01. Normally we set this to 0.01.
  • setEps: This is set to the dissipation rate of the desired inflow spectrum.

STGRand.dat

Running the code

Solver.inp