diff --git a/Manuals/FDS_User_Guide/FDS_User_Guide.tex b/Manuals/FDS_User_Guide/FDS_User_Guide.tex index 7bd9330e211..66c6a2d2439 100644 --- a/Manuals/FDS_User_Guide/FDS_User_Guide.tex +++ b/Manuals/FDS_User_Guide/FDS_User_Guide.tex @@ -11252,6 +11252,7 @@ \subsection{Dry Volume and Mass Fractions} DRY=T / \end{lstlisting} +\ct{DRY} can also be specified on an \ct{SLCF} line that reports the \ct{'MASS FRACTION'} or \ct{'VOLUME FRACTION'} of a species as well as an \ct{HVAC} \ct{DUCT QUANTITY LIST} or \ct{NODE QUANTITY LIST}. For \ct{HVAC} line outputs, \ct{DRY} is an array corresponding to each entry on the \ct{QUANTITY LIST}. \subsection{Aerosol and Soot Concentration} \label{info:soot} @@ -12552,6 +12553,7 @@ \section{\texorpdfstring{{\tt HVAC}}{HVAC} (HVAC System Definition)} \ct{DEVC_ID} & Character & Sections ~\ref{info:HVACduct}, \ref{info:HVACfan}, \ref{info:HVACfilter} & & \\ \hline \ct{DIAMETER} & Real & Section~\ref{info:HVACduct} & m & \\ \hline \ct{DISCHARGE_COEFFICIENT} & Real & Section~\ref{info:Leaks} & & 1. \\ \hline +\ct{DRY} & Log. Array & Section~\ref{info:dry} & & \\ \hline \ct{DUCT_ID} & Char.~Array & Section~\ref{info:HVACnode} & & \\ \hline \ct{EFFICIENCY} & Real Array & Sections~\ref{info:HVACfilter}, \ref{info:HVACaircoil} & & 1.0 \\ \hline \ct{FAN_ID} & Character & Section~\ref{info:HVACduct} & & \\ \hline @@ -13485,6 +13487,7 @@ \section{\texorpdfstring{{\tt SLCF}}{SLCF} (Slice File Parameters)} \ct{AGL_SLICE} & Real & Section~\ref{info:complex_terrain} & m & \\ \hline \ct{CELL_CENTERED} & Logical & Section~\ref{info:SLCF} & & \ct{F} \\ \hline \ct{DB} & Character & Section~\ref{info:SLCF} & & \\ \hline +\ct{DRY} & Logical & Section~\ref{info:dry} & & \\ \hline \ct{ID} & Character & Section~\ref{info:SLCF} & & \\ \hline \ct{MAXIMUM_VALUE} & Real & Reference~\cite{Smokeview_Users_Guide} & & \\ \hline \ct{MESH_NUMBER} & Integer & Section~\ref{info:SLCF} & & \\ \hline diff --git a/Source/dump.f90 b/Source/dump.f90 index e83b284f2a6..0be04776e8a 100644 --- a/Source/dump.f90 +++ b/Source/dump.f90 @@ -6662,8 +6662,6 @@ SUBROUTINE DUMP_SLCF(T,DT,NM,IFRMT) ! Return if there are no slices to process and this is not a Plot3D dump -DRY=.FALSE. - SELECT CASE(IFRMT) CASE(0) ; PLOT3D=.FALSE. ; SLCF3D=.FALSE. CASE(1) ; PLOT3D=.TRUE. ; SLCF3D=.FALSE. @@ -6779,6 +6777,7 @@ SUBROUTINE DUMP_SLCF(T,DT,NM,IFRMT) AGL_TERRAIN_SLICE = .FALSE. CC_CELL_CENTERED = .FALSE. CC_INTERP2FACES = .FALSE. + DRY = .FALSE. ELSE SL => SLICE(IQ) IND = SL%INDEX @@ -6796,6 +6795,7 @@ SUBROUTINE DUMP_SLCF(T,DT,NM,IFRMT) J2 = SL%J2 K1 = SL%K1 K2 = SL%K2 + DRY = SL%DRY DEBUG = 0 IF(SL%DEBUG)DEBUG = 1 AGL_TERRAIN_SLICE = SL%TERRAIN_SLICE @@ -7972,7 +7972,7 @@ SUBROUTINE UPDATE_DEVICES_1(T,DT,NM) CASE(300:350) OUTPUT_INDEX_SELECT ! HVAC output - SDV%VALUE_1 = HVAC_OUTPUT(DV%QUANTITY_INDEX(1),DV%Y_INDEX,DV%Z_INDEX,DV%DUCT_INDEX,DV%NODE_INDEX,DV%DUCT_CELL_INDEX) + SDV%VALUE_1 = HVAC_OUTPUT(DV%QUANTITY_INDEX(1),DV%Y_INDEX,DV%Z_INDEX,DV%DUCT_INDEX,DV%NODE_INDEX,DV%DUCT_CELL_INDEX,DV%DRY) CASE(400:454) OUTPUT_INDEX_SELECT ! Particle-specific output @@ -10709,7 +10709,7 @@ REAL(EB) FUNCTION SOLID_PHASE_OUTPUT(INDX,Y_INDEX,Z_INDEX,PART_INDEX,OPT_WALL_IN END FUNCTION SOLID_PHASE_OUTPUT -REAL(EB) FUNCTION HVAC_OUTPUT(IND,Y_INDEX,Z_INDEX,DUCT_INDEX,NODE_INDEX,DUCT_CELL_INDEX) +REAL(EB) FUNCTION HVAC_OUTPUT(IND,Y_INDEX,Z_INDEX,DUCT_INDEX,NODE_INDEX,DUCT_CELL_INDEX,DRY) ! Compute HVAC Output Quantities @@ -10717,6 +10717,7 @@ REAL(EB) FUNCTION HVAC_OUTPUT(IND,Y_INDEX,Z_INDEX,DUCT_INDEX,NODE_INDEX,DUCT_CEL USE PHYSICAL_FUNCTIONS, ONLY: GET_MASS_FRACTION,GET_MOLECULAR_WEIGHT,GET_ENTHALPY,GET_SENSIBLE_ENTHALPY INTEGER, INTENT(IN) :: Y_INDEX,Z_INDEX,IND,DUCT_INDEX,NODE_INDEX(2),DUCT_CELL_INDEX REAL(EB) :: Y_H2O,ZZ_GET(1:N_TRACKED_SPECIES),MW,Y_SPECIES,RCON,H_DUCT,H_TMPA +LOGICAL :: DRY Y_H2O = 0._EB Y_SPECIES=1.0_EB @@ -11335,7 +11336,7 @@ SUBROUTINE DUMP_HVAC(T) NODE_INDEX(1)=N DO NN = 1, N_NODE_QUANTITY HQT=>NODE_QUANTITY_ARRAY(NN) - OUTVAL_N(NN) = REAL(HVAC_OUTPUT(HQT%OUTPUT_INDEX,HQT%Y_INDEX,HQT%Z_INDEX,-1,NODE_INDEX,-1),FB) + OUTVAL_N(NN) = REAL(HVAC_OUTPUT(HQT%OUTPUT_INDEX,HQT%Y_INDEX,HQT%Z_INDEX,-1,NODE_INDEX,-1,HQT%DRY),FB) ENDDO WRITE(LU_HVAC) OUTVAL_N ENDDO @@ -11347,14 +11348,15 @@ SUBROUTINE DUMP_HVAC(T) DO NNN=1,DUCT(N)%N_CELLS DO NN = 1, N_DUCT_QUANTITY HQT=>DUCT_QUANTITY_ARRAY(NN) - OUTVAL_D(NN) = REAL(HVAC_OUTPUT(HVAC_SMV_EQUIVALENCE(HQT%OUTPUT_INDEX),HQT%Y_INDEX,HQT%Z_INDEX,N,NODE_INDEX,NNN),FB) + OUTVAL_D(NN) = REAL(HVAC_OUTPUT(HVAC_SMV_EQUIVALENCE(HQT%OUTPUT_INDEX),HQT%Y_INDEX,HQT%Z_INDEX,N,NODE_INDEX,NNN,& + HQT%DRY),FB) ENDDO WRITE(LU_HVAC) OUTVAL_D ENDDO ELSE DO NN = 1, N_DUCT_QUANTITY HQT=>DUCT_QUANTITY_ARRAY(NN) - OUTVAL_D(NN) = REAL(HVAC_OUTPUT(HQT%OUTPUT_INDEX,HQT%Y_INDEX,HQT%Z_INDEX,N,NODE_INDEX,-1),FB) + OUTVAL_D(NN) = REAL(HVAC_OUTPUT(HQT%OUTPUT_INDEX,HQT%Y_INDEX,HQT%Z_INDEX,N,NODE_INDEX,-1,HQT%DRY),FB) ENDDO WRITE(LU_HVAC) OUTVAL_D ENDIF diff --git a/Source/fire.f90 b/Source/fire.f90 index 7a3a75037f7..f37e21f4e74 100644 --- a/Source/fire.f90 +++ b/Source/fire.f90 @@ -781,9 +781,10 @@ SUBROUTINE COMBUSTION_MODEL(T,DT,ZZ_GET,Q_OUT,MIX_TIME_OUT,CHI_R_OUT,CHEM_SUBIT_ Q_REAC_SUB(1:N_REACTIONS),Q_REAC_1(1:N_REACTIONS),Q_REAC_2(1:N_REACTIONS),Q_REAC_4(1:N_REACTIONS),& Q_REAC_SUM(1:N_REACTIONS),Q_SUM_CHI_R,CHI_R_SUM,TIME_RAMP_FACTOR,& TOTAL_MIXED_MASS_1,TOTAL_MIXED_MASS_2,TOTAL_MIXED_MASS_4,TOTAL_MIXED_MASS,& - ZETA_1,ZETA_2,ZETA_4,D_F,TMP_IN,C_U,DT_SUB_OLD,ERR_EST(N_TRACKED_SPECIES),ERR_TOL(N_TRACKED_SPECIES),ERR_TINY,& + ZETA_1,ZETA_2,ZETA_4,D_F,TMP_IN,K_SGS,DT_SUB_OLD,ERR_EST(N_TRACKED_SPECIES),ERR_TOL(N_TRACKED_SPECIES),ERR_TINY,& ZZ_TEMP(1:N_TRACKED_SPECIES),ATOL(1:N_TRACKED_SPECIES) INTEGER :: NR,NS,ITER,TVI,RICH_ITER,TIME_ITER,RICH_ITER_MAX +REAL(EB), PARAMETER :: C_U=0.4_EB,TAU_EPS=1.E-10_EB INTEGER, PARAMETER :: TV_ITER_MIN=5 LOGICAL :: TV_FLUCT(1:N_TRACKED_SPECIES),EXTINCT,NO_REACTIONS,NO_REAC_2,NO_REAC_4 TYPE(REACTION_TYPE), POINTER :: RN !,R1 @@ -804,9 +805,9 @@ SUBROUTINE COMBUSTION_MODEL(T,DT,ZZ_GET,Q_OUT,MIX_TIME_OUT,CHI_R_OUT,CHEM_SUBIT_ TAU_D = DELTA**2/MAX(D_F,TWO_EPSILON_EB) ! FDS Tech Guide (5.14) SELECT CASE(SIM_MODE) CASE DEFAULT - C_U = 0.4_EB*C_DEARDORFF*SQRT(1.5_EB) - TAU_U = C_U*RHO_IN*DELTA**2/MAX(MU_IN,TWO_EPSILON_EB) ! FDS Tech Guide (5.15) - TAU_G = SQRT(2._EB*DELTA/(GRAV+1.E-10_EB)) ! FDS Tech Guide (5.16) + K_SGS = (MU_IN/(RHO_IN*C_DEARDORFF*DELTA))**2 ! FDS Tech Guide (4.17) + TAU_U = C_U*DELTA/SQRT(TWTH*(K_SGS+TAU_EPS)) ! FDS Tech Guide (5.15) + TAU_G = SQRT(2._EB*DELTA/(GRAV+TAU_EPS)) ! FDS Tech Guide (5.16) MIX_TIME_OUT= MAX(TAU_CHEM,MIN(TAU_D,TAU_U,TAU_G,TAU_FLAME)) ! FDS Tech Guide (5.13) CASE (DNS_MODE) MIX_TIME_OUT= MAX(TAU_CHEM,TAU_D) diff --git a/Source/hvac.f90 b/Source/hvac.f90 index 221ab6fb3d1..52c6e943db0 100644 --- a/Source/hvac.f90 +++ b/Source/hvac.f90 @@ -124,6 +124,7 @@ SUBROUTINE READ_HVAC LOGICAL :: INITIALIZED_HVAC_MASS_TRANSPORT !< Flag indicating DUCTs with N_CELLS>1 have been initiazed. LOGICAL :: DUCT_QUANTITY_DEFINED=.FALSE. !< Flag indicating a DUCT_QUANTITY list has alreayd been defined LOGICAL :: NODE_QUANTITY_DEFINED=.FALSE. !< Flag indicating a NODE_QUANTITY list has alreayd been defined +LOGICAL :: DRY(20) !< Flag indicating species output is DRY CHARACTER(LABEL_LENGTH) :: AIRCOIL_ID !< ID of an AIRCOIL located in a DUCT. CHARACTER(LABEL_LENGTH) :: CTRL_ID !< Name of a control function controlling a FAN, damper, or AIRCOIL. CHARACTER(LABEL_LENGTH) :: DEVC_ID !< Name of a device controlling a FAN, damper, or AIRCOIL. @@ -145,7 +146,7 @@ SUBROUTINE READ_HVAC TYPE(DUCT_TYPE), POINTER :: DU !< Pointer to a DUCT TYPE(HVAC_QUANTITY_TYPE), POINTER :: HQT !< Pointer to a DUCT_ or NODE_QUANTITY_ARRAY NAMELIST /HVAC/ AIRCOIL_ID,AMBIENT,AREA,CLEAN_LOSS,COOLANT_SPECIFIC_HEAT,COOLANT_MASS_FLOW,COOLANT_TEMPERATURE,CTRL_ID,& - DAMPER,DEBUG,DEVC_ID,DIAMETER,DISCHARGE_COEFFICIENT,DUCT_ID,& + DAMPER,DEBUG,DEVC_ID,DIAMETER,DISCHARGE_COEFFICIENT,DRY,DUCT_ID,& EFFICIENCY,FAN_ID,FILTER_ID,FIXED_Q,GEOM,GEOM2,ID,LEAK_ENTHALPY,LEAK_PRESSURE_EXPONENT,LEAK_REFERENCE_PRESSURE,& LENGTH,LOADING,LOADING_MULTIPLIER,LOSS,& MASS_FLOW,MAX_FLOW,MAX_PRESSURE,N_CELLS,NETWORK_ID,NODE_ID,PERIMETER,QUANTITY,QUANTITY_SPEC_ID,& @@ -719,6 +720,7 @@ SUBROUTINE READ_HVAC N_DUCT_QUANTITY = N_DUCT_QUANTITY + 1 ENDDO ALLOCATE (DUCT_QUANTITY_ARRAY(N_DUCT_QUANTITY)) + DUCT_QUANTITY_ARRAY(1:N_DUCT_QUANTITY)%DRY = DRY(1:N_DUCT_QUANTITY) DO N=1, N_DUCT_QUANTITY HQT => DUCT_QUANTITY_ARRAY(N) CALL GET_QUANTITY_INDEX(HQT%SMOKEVIEW_LABEL,HQT%SMOKEVIEW_BAR_LABEL,HQT%OUTPUT_INDEX,HQT%Y_INDEX,HQT%Z_INDEX,& @@ -736,6 +738,7 @@ SUBROUTINE READ_HVAC N_NODE_QUANTITY = N_NODE_QUANTITY + 1 ENDDO ALLOCATE (NODE_QUANTITY_ARRAY(N_NODE_QUANTITY)) + NODE_QUANTITY_ARRAY(1:N_NODE_QUANTITY)%DRY = DRY(1:N_NODE_QUANTITY) DO N=1, N_NODE_QUANTITY HQT => NODE_QUANTITY_ARRAY(N) CALL GET_QUANTITY_INDEX(HQT%SMOKEVIEW_LABEL,HQT%SMOKEVIEW_BAR_LABEL,HQT%OUTPUT_INDEX,HQT%Y_INDEX,HQT%Z_INDEX,& @@ -774,6 +777,7 @@ SUBROUTINE SET_HVAC_DEFAULTS DAMPER = .FALSE. DEVC_ID = 'null' DIAMETER = -1._EB +DRY = .FALSE. DUCT_ID = 'null' FAN_ID = 'null' FIXED_Q = -1.E10_EB diff --git a/Source/mass.f90 b/Source/mass.f90 index f92260f7728..3c7975c6e72 100644 --- a/Source/mass.f90 +++ b/Source/mass.f90 @@ -630,7 +630,7 @@ SUBROUTINE CHECK_MASS_DENSITY REAL(EB) :: MASS_N(-3:3),CONST,MASS_C,RHO_ZZ_CUT,RHO_CUT,VC(-3:3),SIGN_FACTOR,SUM_MASS_N,VC1(-3:3),& RHO_ZZ_MIN,RHO_ZZ_MAX,SUM_RHO_ZZ,RHO_ZZ_TEST INTEGER :: IC -LOGICAL :: CLIP_RHO_ZZ +LOGICAL :: CLIP_RHO_ZZ(N_TRACKED_SPECIES) REAL(EB), POINTER, DIMENSION(:,:,:) :: DELTA_RHO,DELTA_RHO_ZZ,RHOP REAL(EB), POINTER, DIMENSION(:,:,:,:) :: RHO_ZZ @@ -716,12 +716,12 @@ SUBROUTINE CHECK_MASS_DENSITY ! Correct species mass density RHO_ZZ_MIN = 0._EB +CLIP_RHO_ZZ = .FALSE. SPECIES_LOOP: DO N=1,N_TRACKED_SPECIES DELTA_RHO_ZZ => WORK5 DELTA_RHO_ZZ = 0._EB - CLIP_RHO_ZZ = .FALSE. DO K=1,KBAR DO J=1,JBAR @@ -739,7 +739,7 @@ SUBROUTINE CHECK_MASS_DENSITY RHO_ZZ_MAX = RHOP(I,J,K) IF (RHO_ZZ(I,J,K,N)>=RHO_ZZ_MIN .AND. RHO_ZZ(I,J,K,N)<=RHO_ZZ_MAX) CYCLE - CLIP_RHO_ZZ = .TRUE. + CLIP_RHO_ZZ(N) = .TRUE. IF (RHO_ZZ(I,J,K,N)SLICE(N) SL%SLCF_INDEX=NN SL%ID = ID + SL%DRY = DRY SL%IOR = IOR SL%SLICETYPE = TRIM(SLICETYPE) SL%GEOM_INDEX = GEOM_INDEX diff --git a/Source/type.f90 b/Source/type.f90 index f45cf4b1102..53b295b268c 100644 --- a/Source/type.f90 +++ b/Source/type.f90 @@ -1564,7 +1564,7 @@ MODULE TYPES REAL(FB), DIMENSION(2) :: MINMAX REAL(FB) :: RLE_MIN, RLE_MAX REAL(EB):: AGL_SLICE - LOGICAL :: TERRAIN_SLICE=.FALSE.,CELL_CENTERED=.FALSE.,RLE=.FALSE.,DEBUG=.FALSE.,THREE_D=.FALSE. + LOGICAL :: TERRAIN_SLICE=.FALSE.,CELL_CENTERED=.FALSE.,RLE=.FALSE.,DEBUG=.FALSE.,THREE_D=.FALSE.,DRY=.FALSE. CHARACTER(LABEL_LENGTH) :: SLICETYPE='STRUCTURED',SMOKEVIEW_LABEL CHARACTER(LABEL_LENGTH) :: SMOKEVIEW_BAR_LABEL,ID='null',MATL_ID='null' CHARACTER(200) :: SLCF_NAME='null' @@ -2134,6 +2134,7 @@ MODULE TYPES CHARACTER(LABEL_LENGTH) :: SMOKEVIEW_LABEL !< Smokeview label for QUANTITY CHARACTER(LABEL_LENGTH) :: SMOKEVIEW_BAR_LABEL !< Smokeview colorbar label for QUANTITY CHARACTER(LABEL_LENGTH) :: UNITS !< Units for QUANTITY + LOGICAL :: DRY !< Remove water vapor before computing a mass or volume fraction END TYPE HVAC_QUANTITY_TYPE diff --git a/Utilities/Matlab/FDS_verification_script.m b/Utilities/Matlab/FDS_verification_script.m index 8ee2996d167..419e7b68663 100644 --- a/Utilities/Matlab/FDS_verification_script.m +++ b/Utilities/Matlab/FDS_verification_script.m @@ -29,7 +29,6 @@ disp('radiation_plane_layer...'); radiation_plane_layer disp('ns2d...'); ns2d disp('vort2d...'); vort2d -disp('wall_internal_radiation...'); wall_internal_radiation disp('ashrae_7...'); ashrae_7 disp('flame_species...'); flame_species disp('cat_propane_depo...'); cat_propane_depo @@ -62,12 +61,7 @@ % Special cases -disp('wall_model...'); wall_model -disp('pulsating...'); pulsating disp('compression_wave...'); compression_wave -disp('soborot_mass_transport...'); soborot_mass_transport -disp('plate_view_factor...'); plate_view_factor -disp('terminal_velocity_convergence...'); terminal_velocity_convergence disp('fluid_part...'); fluid_part disp('extinction...'); extinction disp('fan_curve...'); fan_curve @@ -80,10 +74,6 @@ disp('rms_cov_corr...'); rms_cov_corr disp('hot_layer_collapse...'); hot_layer_collapse disp('radiating_polygon...'); radiating_polygon -disp('saad_mms_temporal_error...'); saad_mms_temporal_error -disp('saad_cc_mms_temporal_error...'); saad_cc_mms_temporal_error -disp('shunn_mms_temporal_error...'); shunn_mms_temporal_error -disp('shunn_mms_favreZ...'); shunn_mms_favreZ disp('favre_test...'); favre_test disp('scaling_tests...'); scaling_tests disp('hvac_mass_transport...'); hvac_mass_transport @@ -101,7 +91,6 @@ disp('natconv...'); natconv disp('freecon_sphere...'); freecon_sphere disp('nat_conv_hot_plate...'); nat_conv_hot_plate -disp('tree_shapes...'); tree_shapes disp('impinging_jet...'); impinging_jet disp('part_drag_profile...'); part_drag_profile diff --git a/Utilities/Matlab/scripts/blasius.m b/Utilities/Matlab/scripts/blasius.m deleted file mode 100644 index 4f602eabda2..00000000000 --- a/Utilities/Matlab/scripts/blasius.m +++ /dev/null @@ -1,160 +0,0 @@ -% PARK HYUN WOOK, Yonsei University -% 8-15-2012 -% blasius.m - -close all -clear all - -plot_style - -repository = '../../Verification/Flowfields/'; - - -%gather FDS result(n=16) -filename=[repository,'blasius_16_line.csv']; - -if ~exist(filename) - display(['Error: File ' filename ' does not exist. Skipping case.']) - return -end - -M = csvread(filename,2,0); - -u_16 = M(:,2); -z_16 = M(:,1); - - -%gather FDS result(n=32) -filename=[repository,'blasius_32_line.csv']; - -M = csvread(filename,2,0); - -u_32 = M(:,2); -z_32 = M(:,1); - - -%gather FDS result(n=64) -filename=[repository,'blasius_64_line.csv']; - -M = csvread(filename,2,0); - -u_64 = M(:,2); -z_64 = M(:,1); - -%gather blasius profile - -u0= max(u_64(:)); -zmax=0.3; -mu = 0.001; -rho = 1.2; -xc = 0.05; - -[eta,f,fp] = blasius_analytic(u0, zmax, mu, rho, xc, 257, 0.3318); -z_blasius=eta*sqrt(mu/rho*xc/u0); -u_blasius=fp*u0; - - -%plot whole velocity profile -range = 1:4:length(u_blasius); - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -H(1)=plot(u_blasius(range),z_blasius(range),'bo'); -hold on -H(2)=plot(u_16,z_16,'r--'); -H(3)=plot(u_32,z_32,'c-.'); -H(4)=plot(u_64,z_64,'g-'); - -axis([0 1.1 0 0.15]) - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -xlabel('{\it u} (m/s)','Interpreter',Font_Interpreter,'FontName',Font_Name,'FontSize',Label_Font_Size) -ylabel('{\it z} (m)','Interpreter',Font_Interpreter,'FontName',Font_Name,'FontSize',Label_Font_Size) - -h = legend(H,'Blasius','{\it N_z}=16','{\it N_z}=32','{\it N_z}=64','Location','northwest'); -set(h,'FontSize',Title_Font_Size,'Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) - -% add Git revision if file is available - -Git_Filename = [repository,'blasius_16_git.txt']; -addverstr(gca,Git_Filename,'linear') - -% print to pdf for whole velocity profile -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf','../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/blasius_profile') - - -%%%%%%%get error comparing with analytic solution(blasius)%%%%%%%%%% -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) -clear H - -err(1) = 0; -err(2) = 0; -err(3) = 0; - -% get error(n=16) -for i=1:length(u_16) - err(1)=err(1)+(abs(u_16(i)-u_blasius(9+(i-1)*16)))^2; -end -err(1)=err(1)/16; -err(1)=sqrt(err(1)); - -% get error(n=32) -for i=1:length(u_32) - err(2)=err(2)+(abs(u_32(i)-u_blasius(5+(i-1)*8)))^2 ; -end -err(2)=err(2)/32; -err(2)=sqrt(err(2)); - -% get error(n=64) -for i=1:length(u_64) - err(3)=err(3)+(abs(u_64(i)-u_blasius(3+(i-1)*4)))^2; -end -err(3)=err(3)/64; -err(3)=sqrt(err(3)); - - -dz(1)=abs(z_16(10)-z_16(9)); -dz(2)=abs(z_32(10)-z_32(9)); -dz(3)=abs(z_64(10)-z_64(9)); - -plot_style - -H(1)=loglog(dz, err,'b*-','LineWidth',Line_Width); hold on -H(2)=loglog(dz, 10*dz,'k--','LineWidth',Line_Width); -H(3)=loglog(dz, 100*dz.^2,'k-','LineWidth',Line_Width); - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -xlabel('Grid Spacing, {\it\deltaz} (m)','FontSize',Title_Font_Size,'Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('RMS Error (m/s)','FontSize',Title_Font_Size,'Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -axis([1e-3 1e-1 1e-3 1e-0]) -legend_handle=legend(H,'FDS','{\itO}({\it\deltaz})','{\itO}({\it\deltaz^2})','Location','Northwest'); -set(legend_handle,'FontSize',Label_Font_Size,'Interpreter',Font_Interpreter) - -% add Git revision if file is available - -Git_Filename = [repository,'blasius_16_git.txt']; -addverstr(gca,Git_Filename,'loglog') - -% print to pdf -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf','../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/blasius_convergence') - - - diff --git a/Utilities/Matlab/scripts/blasius_analytic.m b/Utilities/Matlab/scripts/blasius_analytic.m deleted file mode 100644 index 56e7d9f42d4..00000000000 --- a/Utilities/Matlab/scripts/blasius_analytic.m +++ /dev/null @@ -1,63 +0,0 @@ -% PARK HYUN WOOK, Yonsei University -% 8-15-2012 -% blasius_analytic.m - -function [eta,f,fp] = blasius_analytic(u0, zmax, mu, rho, x, steps, fpp_init) - -% etamax = maximum eta for calculation -% steps = number of steps between 0 and etamax -% fppwall = initial (wall) value of 2nd derivative of Blasius function -% outputs: -% eta - the similarity coordinate normal to the wall -% f, fp, fpp, fppp - the Blasius function and it first 3 derivatives - -etamax=zmax/sqrt(mu/rho*x/u0); -deta = etamax/(steps-1); -eta = zeros(steps,1); -f = zeros(steps,1); -fp = zeros(steps,1); -fpp = zeros(steps,1); -fppp = zeros(steps,1); -% initial guess for fpp -fpp(1) = fpp_init; -for i=1:steps-1 - eta(i+1) = eta(i) + deta; - % predictor - %1st - k1(1)=fp(i); - k1(2)=fpp(i); - k1(3)=-f(i)*fpp(i)/2; - - fbar = f(i) + 0.5*deta * k1(1); - fpbar = fp(i) + 0.5*deta * k1(2); - fppbar = fpp(i) + 0.5*deta * k1(3); - - %2nd - k2(1)=fpbar; - k2(2)=fppbar; - k2(3)=-fbar*fppbar/2; - - fbar = f(i) + 0.5*deta * k2(1); - fpbar = fp(i) + 0.5*deta * k2(2); - fppbar = fpp(i) + 0.5*deta * k2(3); - - %3rd - k3(1)=fpbar; - k3(2)=fppbar; - k3(3)=-fbar*fppbar/2; - - fbar = f(i) + deta * k3(1); - fpbar = fp(i) + deta * k3(2); - fppbar = fpp(i) + deta * k3(3); - - %4th - k4(1)=fpbar; - k4(2)=fppbar; - k4(3)=-fbar*fppbar/2; - - % corrector - f(i+1) = f(i) + deta * (k1(1)+2*k2(1)+2*k3(1)+k4(1))/6; - fp(i+1) = fp(i) + deta * (k1(2)+2*k2(2)+2*k3(2)+k4(2))/6; - fpp(i+1) = fpp(i) + deta * (k1(3)+2*k2(3)+2*k3(3)+k4(3))/6; - fppp(i+1) = -f(i+1)*fpp(i+1)/2; -end diff --git a/Utilities/Matlab/scripts/blasius_thermal.m b/Utilities/Matlab/scripts/blasius_thermal.m deleted file mode 100644 index a0564208e22..00000000000 --- a/Utilities/Matlab/scripts/blasius_thermal.m +++ /dev/null @@ -1,152 +0,0 @@ -% McDermott -% 1/21/2022 -% blasius_thermal.m -% -% solution by Pohlhausen, 1921. - -close all -clear all - -datdir = '../../../out/Convection/'; -pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/'; - -chid = {'Pohlhausen_Pr_p5','Pohlhausen_Pr_1','Pohlhausen_Pr_2'}; - -% blasius profile - -Pr=[0.5, 1, 2]; % Prandtl numbers -u0=1; % see FDS input file -zmax=1; % see FDS input file -mu = 0.001; % see FDS input and output files -rho = 1.2; % taken from FDS output file -nu = mu/rho; -x = 5; % corresponds to the position of the DEVC array in the FDS input file -neta=500; -[eta,f,fp] = blasius_analytic(u0, zmax, mu, rho, x, neta, .3318); -etamax=eta(end); - -% thermal profile from Pohlhausen solution, Holman eq. (B-14) - -f1_key={}; -f2_key={}; - -plot_style -Font_Interpreter='LaTeX'; -figure - -for p=1:length(Pr) - - deta = eta(2)-eta(1); - - I = find(eta<=etamax); - for i=1:length(I) - ieta=I(i); - num=0; - for j=1:ieta - intf=trapz(f(1:j))*deta; - num=num+exp(-Pr(p)/2*intf)*deta; - end - denom=num; - for j=ieta+1:neta - intf=trapz(f(1:j))*deta; - denom=denom+exp(-Pr(p)/2*intf)*deta; - end - theta(ieta)=(num-deta)/(denom-deta); - end - - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - H(p)=plot(eta(I),1-theta); hold on - f1_key{end+1}=['Pr=',num2str(Pr(p))]; - xlabel('$\eta=z/\sqrt{\nu x/u_0}$','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) - ylabel('$\frac{T-T_0}{T_w-T_0}=1-\theta$','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) - axis([0 8 0 1]) - - set(gca,'FontName',Font_Name) - set(gca,'FontSize',Label_Font_Size) - -end - -set(gcf,'Visible',Figure_Visibility); -lh=legend(H,f1_key); - -git_file = [datdir, 'Pohlhausen_Pr_2_git.txt']; -addverstr(gca,git_file,'linear') - -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[pltdir,'Pohlhausen_similarity_solution']); - -% now plot the temperature profile in physical space - -figure - -for p=1:length(Pr) - - Tw=21; % wall temerature - T0=20; % ambient temperature - - T = Tw*ones(1,length(theta))+(T0-Tw)*theta; - z = eta(I)*sqrt(nu*x/u0); - - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - f2_key{end+1}=['Pohlhausen Pr=',num2str(Pr(p))]; - H2(length(f2_key))=plot(T,z); hold on - line_color=get(H2(end),'Color'); - - % add FDS results - - M = importdata([datdir,char(chid(p)),'_line.csv'],',',2); - zfds=M.data(:,find(strcmp(M.colheaders,'z'))); - Tfds=M.data(:,find(strcmp(M.colheaders,'Tz'))); - Ufds=M.data(:,find(strcmp(M.colheaders,'Uz'))); - - f2_key{end+1}=['FDS Pr=',num2str(Pr(p))]; - H2(length(f2_key))=plot(Tfds(2:end),zfds(2:end),'--*','Color',line_color); hold on - - xlabel('$T$ ($^\circ$C)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) - ylabel('$z$ (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) - axis([T0-.1 Tw+.1 0 zmax]) - - set(gca,'FontName',Font_Name) - set(gca,'FontSize',Label_Font_Size) - -end - -set(gcf,'Visible',Figure_Visibility); -lh2=legend(H2,f2_key); - -git_file = [datdir, 'Pohlhausen_Pr_2_git.txt']; -addverstr(gca,git_file,'linear') - -set(lh2,'FontName',Font_Name,'FontSize',Key_Font_Size) -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[pltdir,'Pohlhausen_Tz_profile']); - -% % plot velocity field (debug) - -% figure(3) - -% z_bla=eta*sqrt(nu*x/u0); -% u_bla=fp*u0; - -% plot(u_bla,z_bla); hold on -% plot(Ufds,zfds) -% axis([0 1.4*u0 0 zmax]) -% xlabel('u (m/s)') -% ylabel('z (m)') -% title('Blasius velocity profile') - - - - - - - diff --git a/Utilities/Matlab/scripts/colebrook.m b/Utilities/Matlab/scripts/colebrook.m deleted file mode 100644 index 0a3fffb7505..00000000000 --- a/Utilities/Matlab/scripts/colebrook.m +++ /dev/null @@ -1,25 +0,0 @@ -% McDermott -% 2-23-09 -% colebrook.m -% -% input: -% Re = Reynolds number -% RR = relative roughness -% ff = a guess for the value of f -% tol = convergence tolerance (relative error between f and ff) -% -% output: -% f = Moody friction factor based on Colebrook formula -% -% ref: -% Munson, Young and Okiishi, Fundamentals of Fluid Mechanics, Wiley, 1990. - -function [f,error,iter] = colebrook(Re,RR,ff,tol) -iter=0; -error=tol+1; -while error > tol - iter=iter+1; - f = (-2*log10(RR/3.7 + 2.51/(Re*sqrt(ff))))^(-2); - error = abs((f-ff)/ff); - ff = f; % Picard iteration -end diff --git a/Utilities/Matlab/scripts/fds_moody_chart.m b/Utilities/Matlab/scripts/fds_moody_chart.m deleted file mode 100644 index 0efea2b05fa..00000000000 --- a/Utilities/Matlab/scripts/fds_moody_chart.m +++ /dev/null @@ -1,133 +0,0 @@ -% McDermott -% 2-24-09 -% fds_moody_chart.m - -close all -clear all - -% % test Colebrook formula -% Re = 1e5; -% RR = 0; -% ff = .1; -% [f_cor,error,iter] = colebrook(Re,RR,ff,1e-3) % correct value is f=0.018 - -n = 100; -Re = logspace(3.3,8,n); -RR = [0,1e-4,1e-3,1e-2,1e-1]; -tol = 1e-3; - -for i=1:length(RR) - - for j=1:n - % initial guess for f - if j>1 - ff = f(j-1); - else - ff = .1; - end - [f(j),error,iter] = colebrook(Re(j),RR(i),ff,tol); - M(j,1) = Re(j); - M(j,i+1) = f(j); - end - - if i==1; loglog(Re,f,'k-'); hold on; end - if i==2; loglog(Re,f,'b-'); end - if i==3; loglog(Re,f,'r-'); end - if i==4; loglog(Re,f,'g-'); end - if i==5; loglog(Re,f,'m-'); end -end - -Re_DNS = logspace(2,3.3); -f_DNS = (24./Re_DNS); -loglog(Re_DNS,f_DNS,'k-') - -plot_style -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -axis([1e2 1e8 .005 .2]) % based on MYO -xlabel('Re$_H$','Interpreter','LaTeX','FontSize',Label_Font_Size) -ylabel('$f$','Interpreter','LaTeX','FontSize',Label_Font_Size,'Rotation',0.0) - -outdir = '../../../out/Moody_Chart/'; - -% gather FDS results (laminar) -L = 1; -dpdx = -1; -[f_fds(1),Re_fds(1)] = friction_factor_calc(dpdx,L,[outdir,'poiseuille_N64_mu025_devc.csv']); -[f_fds(2),Re_fds(2)] = friction_factor_calc(dpdx,L,[outdir,'poiseuille_N64_mu0125_devc.csv']); - -loglog(Re_fds,f_fds,'k*') - -% gather FDS results (turbulent) -mu = 1.84e-5; - -dpdx = -.01; -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-0p01_N8_devc.csv'],mu);loglog(Re,f,'ksq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-0p01_N16_devc.csv'],mu);loglog(Re,f,'k^') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-0p01_N32_devc.csv'],mu);loglog(Re,f,'ko') - -dpdx = -1; -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-1_N8_devc.csv'],mu);loglog(Re,f,'ksq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-1_N16_devc.csv'],mu);loglog(Re,f,'k^') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-1_N32_devc.csv'],mu);loglog(Re,f,'ko') - -dpdx = -100; -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-100_N8_devc.csv'],mu);H(1)=loglog(Re,f,'ksq'); -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-100_N16_devc.csv'],mu);H(2)=loglog(Re,f,'k^'); -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'moody_dpdx=-100_N32_devc.csv'],mu);H(3)=loglog(Re,f,'ko'); - -dpdx = -.0001; -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p0001_dpdx=-p0001_N8_devc.csv'],mu);loglog(Re,f,'bsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p001_dpdx=-p0001_N8_devc.csv'],mu);loglog(Re,f,'rsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p01_dpdx=-p0001_N8_devc.csv'],mu);loglog(Re,f,'gsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p1_dpdx=-p0001_N8_devc.csv'],mu);loglog(Re,f,'msq') - -dpdx = -.01; -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p0001_dpdx=-p01_N8_devc.csv'],mu);loglog(Re,f,'bsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p001_dpdx=-p01_N8_devc.csv'],mu);loglog(Re,f,'rsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p01_dpdx=-p01_N8_devc.csv'],mu);loglog(Re,f,'gsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p1_dpdx=-p01_N8_devc.csv'],mu);loglog(Re,f,'msq') - -dpdx = -1; -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p0001_dpdx=-1_N8_devc.csv'],mu);loglog(Re,f,'bsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p001_dpdx=-1_N8_devc.csv'],mu);loglog(Re,f,'rsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p01_dpdx=-1_N8_devc.csv'],mu);loglog(Re,f,'gsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p1_dpdx=-1_N8_devc.csv'],mu);loglog(Re,f,'msq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p0001_dpdx=-1_N16_devc.csv'],mu);loglog(Re,f,'b^') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p001_dpdx=-1_N16_devc.csv'],mu);loglog(Re,f,'r^') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p01_dpdx=-1_N16_devc.csv'],mu);loglog(Re,f,'g^') -[f,Re] = friction_factor_calc(dpdx,2*L,[outdir,'s=p02_dpdx=-1_N16_devc.csv'],mu);H(4)=loglog(Re,f,'k>');loglog(Re,f,'g>'); - -dpdx = -100; -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p0001_dpdx=-100_N8_devc.csv'],mu);loglog(Re,f,'bsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p001_dpdx=-100_N8_devc.csv'],mu);loglog(Re,f,'rsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p01_dpdx=-100_N8_devc.csv'],mu);loglog(Re,f,'gsq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p1_dpdx=-100_N8_devc.csv'],mu);loglog(Re,f,'msq') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p0001_dpdx=-100_N16_devc.csv'],mu);loglog(Re,f,'b^') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p001_dpdx=-100_N16_devc.csv'],mu);loglog(Re,f,'r^') -[f,Re] = friction_factor_calc(dpdx,L,[outdir,'s=p01_dpdx=-100_N16_devc.csv'],mu);loglog(Re,f,'g^') -[f,Re] = friction_factor_calc(dpdx,2*L,[outdir,'s=p02_dpdx=-100_N16_devc.csv'],mu);loglog(Re,f,'g>') - -text(1.3e8,2e-1,'$s/H$','Interpreter','LaTeX','FontSize',Key_Font_Size,'Fontname',Font_Name) -text(1.3e8,1.2e-2,num2str(RR(2)),'Interpreter',Font_Interpreter,'FontSize',Key_Font_Size,'Fontname',Font_Name) -text(1.3e8,1.95e-2,num2str(RR(3)),'Interpreter',Font_Interpreter,'FontSize',Key_Font_Size,'Fontname',Font_Name) -text(1.3e8,3.85e-2,num2str(RR(4)),'Interpreter',Font_Interpreter,'FontSize',Key_Font_Size,'Fontname',Font_Name) -text(1.3e8,1.02e-1,num2str(RR(5)),'Interpreter',Font_Interpreter,'FontSize',Key_Font_Size,'Fontname',Font_Name) -h = legend(H,'$N_z=8$, $H=1$','$N_z=16$, $H=1$','$N_z=32$, $H=1$','$N_z=16$, $H=2$','Location','Southwest'); -set(h,'Interpreter','LaTeX','FontSize',Key_Font_Size) - -% add VerStr if file is available - -Git_Filename = [outdir,'moody_dpdx=-0p01_N8_git.txt']; -addverstr(gca,Git_Filename,'loglog') - -% print to pdf -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[1.1*Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 1.1*Paper_Width Paper_Height]); -print(gcf,'-dpdf','../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/fds_moody_chart') - - diff --git a/Utilities/Matlab/scripts/friction_factor_calc.m b/Utilities/Matlab/scripts/friction_factor_calc.m deleted file mode 100644 index 13f21efbe8f..00000000000 --- a/Utilities/Matlab/scripts/friction_factor_calc.m +++ /dev/null @@ -1,22 +0,0 @@ -% McDermott -% 5-14-2009 -% friction_factor_calc.m - -function [f_fds,Re_H]=friction_factor_calc(dpdx,H,filename,varargin) - -M = csvread(filename,2,0); - -ubar = M(:,2); -if nargin==3 - mu = max(M(:,4)); -elseif nargin==4 - mu = varargin{1}; -end - -rho = max(M(:,5)); - -U = ubar(length(ubar)); % steady state mean velocity (planar averaged) -Re_H = H*U*rho/mu; % Reynolds number based on H -f_fds = 2*(-dpdx)*H/(rho*U^2); % f from FDS - - diff --git a/Utilities/Matlab/scripts/heated_channel.m b/Utilities/Matlab/scripts/heated_channel.m deleted file mode 100644 index 5b97bdd81e7..00000000000 --- a/Utilities/Matlab/scripts/heated_channel.m +++ /dev/null @@ -1,232 +0,0 @@ -% McDermott and Moon -% 8-15-12 -% heated_channel.m -% -% References: -% -% Moser, Kim, and Mansour. DNS of Turbulent Channel Flow up to Re_tau=590. -% Physics of Fluids, vol 11, 943-945, 1999. -% -% Kim, Moin & Moser. [Numerical Method, Re_tau = 178.12]. J. Fluid Mech. -% vol 177, 133-166, 1987. - -close all -clear all - -plot_style - -% plot the DNS results - -outdir='../../../out/Heated_Channel_Flow/'; -expdir='../../../exp/Heated_Channel_Flow/'; - -M = importdata([expdir,'heated_channel_dns_data.csv'],',',1); - -yp_up_mean = M.data(:,find(strcmp(M.colheaders,'yp_up_mean'))); -up_mean = M.data(:,find(strcmp(M.colheaders,'up_mean'))); -yp_Tp_mean = M.data(:,find(strcmp(M.colheaders,'yp_Tp_mean'))); -Tp_mean_Pr0p10 = M.data(:,find(strcmp(M.colheaders,'Tp_mean_Pr0p1'))); -Tp_mean_Pr0p71 = M.data(:,find(strcmp(M.colheaders,'Tp_mean_Pr0p71'))); -Tp_mean_Pr2p00 = M.data(:,find(strcmp(M.colheaders,'Tp_mean_Pr2p0'))); -range = 1:3:length(yp_up_mean); - -f1=figure; -a1=gca; -set(f1,'Visible',Figure_Visibility); -set(a1,'Units',Plot_Units) -set(a1,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -hfig1(2)=semilogx(yp_up_mean,up_mean,'ro'); hold on -axis([1e0 1e3 0 30]) - -set(a1,'FontName',Font_Name) -set(a1,'FontSize',Title_Font_Size) - -xlabel('{\it z}^+','Interpreter',Font_Interpreter,'Fontname',Font_Name) -ylabel('{\it u}^+','Interpreter',Font_Interpreter,'Fontname',Font_Name) - - -f2=figure; -a2=gca; -set(f2,'Visible',Figure_Visibility); -set(a2,'Units',Plot_Units) -set(a2,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -hfig2(2)=semilogx(yp_Tp_mean(range),Tp_mean_Pr0p10(range),'bo'); hold on -semilogx(yp_Tp_mean(range),Tp_mean_Pr0p71(range),'bo') -semilogx(yp_Tp_mean(range),Tp_mean_Pr2p00(range),'bo') -axis([1e0 1e3 0 30]) - -set(a2,'FontName',Font_Name) -set(a2,'FontSize',Label_Font_Size) - -xlabel('{\it z}^+','Interpreter',Font_Interpreter,'Fontname',Font_Name) -ylabel('{\it T}^+','Interpreter',Font_Interpreter,'Fontname',Font_Name) - -text(225,26,'Pr=2.0','Interpreter',Font_Interpreter,'Fontname',Font_Name,'FontSize',Label_Font_Size) -text(225,15,'Pr=0.71','Interpreter',Font_Interpreter,'Fontname',Font_Name,'FontSize',Label_Font_Size) -text(225,5,'Pr=0.10','Interpreter',Font_Interpreter,'Fontname',Font_Name,'FontSize',Label_Font_Size) - -% plot the FDS results - -H = 2; -dpdx = 9.0088e-6; -tau_w = 0.5*dpdx*H; -cp = 1; -mu = 1.8216e-5; -T_w = 20; - -devcfile = {'heated_channel_Pr_0p10_16_devc.csv', ... - 'heated_channel_Pr_0p71_16_devc.csv', ... - 'heated_channel_Pr_1p00_16_devc.csv', ... - 'heated_channel_Pr_2p00_16_devc.csv'}; - -linefile = {'heated_channel_Pr_0p10_16_line.csv', ... - 'heated_channel_Pr_0p71_16_line.csv', ... - 'heated_channel_Pr_1p00_16_line.csv', ... - 'heated_channel_Pr_2p00_16_line.csv'}; - -skip_case = 0; - -for i = [1,2,3,4] - - if ~exist([outdir,devcfile{i}]) - display(['Error: File ' [outdir,devcfile{i}] ' does not exist. Skipping case.']) - skip_case = 1; - continue - end - - M = importdata([outdir,devcfile{i}],',',2); - - rho = M.data(end,strcmp(M.colheaders,'RHO')); % should be about 1.19 - u_tau = sqrt(tau_w/rho); - delta_nu = (mu/rho)/u_tau; - - j1 = find(strcmp(M.colheaders,'HF0B')); - j2 = find(strcmp(M.colheaders,'HF0T')); - q_w = mean(M.data(end,j1:j2)); - T_tau = q_w/(rho*u_tau*cp); - - if ~exist([outdir,linefile{i}]) - display(['Error: File ' [outdir,linefile{i}] ' does not exist. Skipping case.']) - skip_case = 1; - continue - end - - M = importdata([outdir,linefile{i}],',',2); - - zp = M.data(1:16,1)/delta_nu; - - switch(i) - case {1,2,4} - j1 = find(strcmp(M.colheaders,'T11')); - j2 = find(strcmp(M.colheaders,'T115')); - T1 = mean(M.data(1:16,j1:j2),2); % bottom wall - T2 = mean(M.data(32:-1:17,j1:j2),2); % top wall - Tp = (0.5*(T1+T2)-T_w)/T_tau; - set(groot,'CurrentFigure',f2); - hfig2(1)=semilogx(zp,Tp,'ksq-'); - case 3 - j1 = find(strcmp(M.colheaders,'U11')); - j2 = find(strcmp(M.colheaders,'U115')); - u1 = mean(M.data(1:16,j1:j2),2); % bottom wall - u2 = mean(M.data(32:-1:17,j1:j2),2); % top wall - up = 0.5*(u1+u2)/u_tau; - set(groot,'CurrentFigure',f1); - hfig1(1)=semilogx(zp,up,'ksq-'); - end - - switch i - case 1; err(i) = abs( mean(Tp)-mean(Tp_mean_Pr0p10,'omitnan') )/mean(Tp_mean_Pr0p10,'omitnan'); - case 2; err(i) = abs( mean(Tp)-mean(Tp_mean_Pr0p71,'omitnan') )/mean(Tp_mean_Pr0p71,'omitnan'); - case 3; err(i) = abs( mean(up)-mean(up_mean,'omitnan') )/mean(up_mean,'omitnan'); - case 4; err(i) = abs( mean(Tp)-mean(Tp_mean_Pr2p00,'omitnan') )/mean(Tp_mean_Pr2p00,'omitnan'); - end - - if err(i)>1 - disp(['Matlab Warning: heated_channel case ',num2str(i),' out of tolerance']) - end - -end - -if skip_case - return -end - -set(groot,'CurrentFigure',f1); -h = legend(hfig1,'FDS','DNS Re_\tau=180','Location','Northwest'); -set(h,'FontSize',Key_Font_Size) - -% add Git if file is available - -Git_Filename = [outdir,'heated_channel_Pr_1p00_16_git.txt']; -addverstr(a1,Git_Filename,'semilogx') - -% print pdf - -set(f1,'Visible',Figure_Visibility); -set(f1,'Units',Paper_Units) -set(f1,'PaperUnits',Paper_Units); -set(f1,'PaperSize',[Paper_Width Paper_Height]); -set(f1,'Position',[0 0 Paper_Width Paper_Height]); -print(f1,'-dpdf','../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/heated_channel_uplus') - -set(groot,'CurrentFigure',f2); -h = legend(hfig2,'FDS','DNS Re_\tau=180','Location','Northwest'); -set(h,'FontSize',Key_Font_Size) - -% add Git if file is available - -Git_Filename = [outdir,'heated_channel_Pr_0p71_16_git.txt']; -addverstr(a2,Git_Filename,'semilogx') - -% print pdf - -set(f2,'Visible',Figure_Visibility); -set(f2,'Units',Paper_Units) -set(f2,'PaperUnits',Paper_Units); -set(f2,'PaperSize',[Paper_Width Paper_Height]); -set(f2,'Position',[0 0 Paper_Width Paper_Height]); -print(f2,'-dpdf','../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/heated_channel_Tplus') - - -% % Compute pressure gradient from Re_tau - -% mu=1.8216e-5 -% rho=1.1934 -% Re_tau=180 % Kim and Moin, 1987 -% delta=1 % channel half height -% u_tau=Re_tau*(mu/rho)/delta -% tau_w=rho*u_tau^2 -% dpdx=tau_w/delta -% Pr = 1; -% Tref = 293; - -% q = 2/(Pr*Re_tau) * rho*cp*u_tau*Tref/delta - -% % Check bulk velocity - -% figure -% for i = [1,2,3,4] -% M = importdata([outdir,devcfile{i}],',',2); -% t = M.data(:,find(strcmp(M.colheaders,'Time'))); -% UVEL = M.data(:,find(strcmp(M.colheaders,'"U-VEL"'))); -% plot(t,UVEL); hold on -% end - -% % Check heat balance - -% figure -% for i = [1,2,3,4] -% M = importdata([outdir,devcfile{i}],',',2); -% t = M.data(:,find(strcmp(M.colheaders,'Time'))); -% j1 = find(strcmp(M.colheaders,'"NetHF0B"')); -% j2 = find(strcmp(M.colheaders,'"NetHF0T"')); -% q_w = mean(M.data(:,j1:j2),2); -% plot(t,q_w); hold on -% end - - - - - diff --git a/Utilities/Matlab/scripts/law_of_the_wall.m b/Utilities/Matlab/scripts/law_of_the_wall.m deleted file mode 100644 index 40e8c7eb2cf..00000000000 --- a/Utilities/Matlab/scripts/law_of_the_wall.m +++ /dev/null @@ -1,66 +0,0 @@ -% McDermott -% 3-4-09 -% law_of_the_wall.m - -close all -clear all - -% plot Werner and Wengle velocity profile - -A = 8.3; -B = 1/7; -n = 100; -zp = logspace(0,4,n); -uu = zp; % log law -for j = 1:n - if zp(j)<11.81 - up(j) = zp(j); - else - up(j) = A*zp(j)^B; % Werner and Wengle (power law) - uu(j) = (1/0.41)*log(zp(j))+5.2; % log law - end -end - -figure -plot_style -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -semilogx(zp,up,'b-'); hold on -semilogy(zp,uu,'r--') -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) -text(1.5,8,'{\itu}^+ = {\itz}^+','FontSize',Label_Font_Size,'Interpreter',Font_Interpreter) -text(200,15,'{\itu}^+ = 2.4 ln {\itz}^+ + 5.2','FontSize',Label_Font_Size,'Interpreter',Font_Interpreter,'Color',[1 0 0]) -text(500,30,'{\itu}^+ = A({\itz}^+)^B','FontSize',Label_Font_Size,'Interpreter',Font_Interpreter,'Color',[0 0 1]) -line([11.81 11.81],[0 20],'LineStyle','--','Color',[0 0 0]) -text(15,5,'{\itz}^+ = 11.81','FontSize',Label_Font_Size,'Interpreter',Font_Interpreter); -xlabel('{\itz}^+','FontSize',Label_Font_Size,'Interpreter',Font_Interpreter) -ylabel('{\itu}^+','FontSize',Label_Font_Size,'Interpreter',Font_Interpreter) - -% print pdf -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf','../../Manuals/FDS_Technical_Reference_Guide/SCRIPT_FIGURES/lawofthewall') - -% % check FDS parameters -% -% alpha = (1-B)/2*A^((1+B)/(1-B)) -% beta = 1+B -% eta = (1+B)/A -% gamma = 2/(1+B) -% H = 1; -% N = 16; -% dz = H/N -% rho = 1.198; -% mu = 1.81e-5; -% nu = mu/rho; -% nu_over_dz = nu/dz -% -% u1 = 8.311075e-2; -% tau_w = ( alpha*nu_over_dz^beta + eta*nu_over_dz^B*abs(u1) )^gamma -% zplus = dz*sqrt(tau_w)/nu - diff --git a/Utilities/Matlab/scripts/plate_view_factor.m b/Utilities/Matlab/scripts/plate_view_factor.m deleted file mode 100644 index cdafaa2fb03..00000000000 --- a/Utilities/Matlab/scripts/plate_view_factor.m +++ /dev/null @@ -1,91 +0,0 @@ -% Hostikka -% April 23, 2010 -% plate_view_factor.m - -close all -clear all - -addpath('../../Verification/Radiation') - -% set the plot style parameters - -plot_style - -% Collect data - -NRA = [30 60 100]; - -Exact_Flux_2D = 105.34; -Exact_Flux_cart = 81.8; -Exact_Flux_cyl = 74.1; - -% 2D -M = csvread('plate_view_factor_2D_30_devc.csv',2,0); -Flux_2D(1) = max(M(:,2)); -M = csvread('plate_view_factor_2D_60_devc.csv',2,0); -Flux_2D(2) = max(M(:,2)); -M = csvread('plate_view_factor_2D_100_devc.csv',2,0); -Flux_2D(3) = max(M(:,2)); - -% Cart -M = csvread('plate_view_factor_cart_30_devc.csv',2,0); -Flux_cart(1) = max(M(:,2)); -M = csvread('plate_view_factor_cart_60_devc.csv',2,0); -Flux_cart(2) = max(M(:,2)); -M = csvread('plate_view_factor_cart_100_devc.csv',2,0); -Flux_cart(3) = max(M(:,2)); - -% Cylindrical -M = csvread('plate_view_factor_cyl_30_devc.csv',2,0); -Flux_cyl(1) = max(M(:,2)); -M = csvread('plate_view_factor_cyl_60_devc.csv',2,0); -Flux_cyl(2) = max(M(:,2)); -M = csvread('plate_view_factor_cyl_100_devc.csv',2,0); -Flux_cyl(3) = max(M(:,2)); - -% IBM -M = csvread('plate_view_factor_ibm_30_devc.csv',2,0); -Flux_ibm(1) = max(M(:,2)); -M = csvread('plate_view_factor_ibm_60_devc.csv',2,0); -Flux_ibm(2) = max(M(:,2)); -M = csvread('plate_view_factor_ibm_100_devc.csv',2,0); -Flux_ibm(3) = max(M(:,2)); - -% Plot data - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y 1.3*Plot_Width Plot_Height]) - -h=plot(NRA,Exact_Flux_2D*[1 1 1],'r-',NRA,Flux_2D,'ro'); -hold on -h=plot(NRA,Exact_Flux_cart*[1 1 1],'b-',NRA,Flux_cart,'bs'); -%h=plot(NRA,Flux_ibm,'bd'); % Hold for FDS 7 -h=plot(NRA,Exact_Flux_cyl*[1 1 1],'g-',NRA,Flux_cyl,'gd'); - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -axis([20 110 30 120]) -xlabel('Number of Radiation Angles','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Heat Flux (kW/m²)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -Plot_Title='Radiative Heat Flux (plate\_view\_factor)'; -text(30,113,Plot_Title,'FontSize',Title_Font_Size,'FontName',Font_Name,'Interpreter',Font_Interpreter) -%leg=legend('Exact 2D','FDS 2D','Exact 3D','FDS 3D','FDS 3D IBM','Exact cyl.','FDS cyl.','Location','EastOutside'); -leg=legend('Exact 2D','FDS 2D','Exact 3D','FDS 3D','Exact cyl.','FDS cyl.','Location','EastOutside'); -set(leg,'FontSize',Key_Font_Size); - -% add version string if file is available - -Git_Filename = 'plate_view_factor_2D_30_git.txt'; -addverstr(gca,Git_Filename,'linear') - -% print pdf -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[1.3*Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 1.3*Paper_Width Paper_Height]); -print(gcf,'-dpdf','../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/plate_view_factor') - -%close diff --git a/Utilities/Matlab/scripts/poiseuille_convergence.m b/Utilities/Matlab/scripts/poiseuille_convergence.m deleted file mode 100644 index f4add856aa1..00000000000 --- a/Utilities/Matlab/scripts/poiseuille_convergence.m +++ /dev/null @@ -1,54 +0,0 @@ -% McDermott -% 5-14-2009 -% poiseuille_convergence.m - -close all -clear all - -plot_style - -dpdx = -1; -L = 1; -N = [8,16,32,64]; - -outdir = '../../../out/Moody_Chart/'; - -[f(1),Re(1)] = friction_factor_calc(dpdx,L,[outdir,'poiseuille_N8_mu025_devc.csv']); -[f(2),Re(2)] = friction_factor_calc(dpdx,L,[outdir,'poiseuille_N16_mu025_devc.csv']); -[f(3),Re(3)] = friction_factor_calc(dpdx,L,[outdir,'poiseuille_N32_mu025_devc.csv']); -[f(4),Re(4)] = friction_factor_calc(dpdx,L,[outdir,'poiseuille_N64_mu025_devc.csv']); - -% plot convergence for Poiseuille flow (mu = 0.025) - -dz = L./N; -error = abs(f-24./Re); - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -H(1)=loglog(dz,error,'b*-','Linewidth',1.); hold on -H(2)=loglog(dz,.05*dz,'k--','Linewidth',1.); -H(3)=loglog(dz,.4*dz.^2,'k-','Linewidth',1.); - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Title_Font_Size) -axis([0.01 0.2 0.00005 0.01]) - -xlabel('Grid Spacing, $\delta z$ (m)','Interpreter','LaTeX') -ylabel('Friction Factor Error') -h = legend(H,'FDS','$\mathcal{O}(\delta z)$','$\mathcal{O}(\delta z)^2$','Location','Southeast'); -set(h,'Interpreter','LateX') - -% add Git revision if file is available - -Git_Filename = [outdir,'poiseuille_N8_mu025_git.txt']; -addverstr(gca,Git_Filename,'loglog') - -% print to pdf -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf','../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/poiseuille_convergence') diff --git a/Utilities/Matlab/scripts/poiseuille_convergence_cc.m b/Utilities/Matlab/scripts/poiseuille_convergence_cc.m deleted file mode 100644 index 62ff5f7af58..00000000000 --- a/Utilities/Matlab/scripts/poiseuille_convergence_cc.m +++ /dev/null @@ -1,115 +0,0 @@ -% CC script that follows McDermott poiseuille_convergence.m - -close all -clear all - -plot_style - -dpdx = -1; -L = 1; -N = [10,20,40,80]; - -outdir = '../../Verification/Complex_Geometry/'; - -% Method for cross velocity forcing: -vmethod=['_stm']; - -for im=1:1 - - mth=vmethod(im,:); - - % Aligned case theta=0: - [f(1),Re(1)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N10a_theta0' mth '_devc.csv']); - [f(2),Re(2)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N20a_theta0' mth '_devc.csv']); - [f(3),Re(3)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N40a_theta0' mth '_devc.csv']); - [f(4),Re(4)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N80a_theta0' mth '_devc.csv']); - - [f2(1),Re2(1)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N10nah_theta0' mth '_devc.csv']); - [f2(2),Re2(2)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N20nah_theta0' mth '_devc.csv']); - [f2(3),Re2(3)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N40nah_theta0' mth '_devc.csv']); - [f2(4),Re2(4)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N80nah_theta0' mth '_devc.csv']); - - % plot convergence for Poiseuille flow aligned case theta=0 (mu = 0.025) - - dz = L./N; - error = abs(f-24./Re); - error2= abs(f2-24./Re2); - - figure - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - - H(1)=loglog(dz,error,'b*-','Linewidth',1.); hold on - H(2)=loglog(dz,error2,'rx-','Linewidth',1.); hold on - H(3)=loglog(dz,.12*dz,'k--','Linewidth',1.); - H(4)=loglog(dz,.4*dz.^2,'k-','Linewidth',1.); - - set(gca,'FontName',Font_Name) - set(gca,'FontSize',Title_Font_Size) - axis([0.01 0.2 0.0000005 0.01]) - - xlabel('Grid Spacing, $\delta z$ (m)','Interpreter','LaTeX') - ylabel('Friction Factor Error') - h = legend(H,'FDS, $h=0$','FDS, $h=\Delta z/3$','$\mathcal{O}(\delta z)$','$\mathcal{O}(\delta z^2)$','Location','Southeast'); - set(h,'Interpreter','LaTeX') - - % add Git revision if file is available - - Git_Filename = [outdir 'geom_poiseuille_N10a_theta0' mth '_git.txt']; - addverstr(gca,Git_Filename,'loglog') - - % print to pdf - set(gcf,'Visible',Figure_Visibility); - set(gcf,'Units',Paper_Units); - set(gcf,'PaperUnits',Paper_Units); - set(gcf,'PaperSize',[Paper_Width Paper_Height]); - set(gcf,'Position',[0 0 Paper_Width Paper_Height]); - print(gcf,'-dpdf',['../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/geom_poiseuille_convergence_theta0a' mth]) - - - % NOT aligned case theta=0 - - clear f Re f2 Re2 H - - [f(1),Re(1)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N10na_theta0' mth '_devc.csv']); - [f(2),Re(2)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N20na_theta0' mth '_devc.csv']); - [f(3),Re(3)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N40na_theta0' mth '_devc.csv']); - [f(4),Re(4)] = friction_factor_calc(dpdx,L,[outdir 'geom_poiseuille_N80na_theta0' mth '_devc.csv']); - - % plot convergence for Poiseuille flow not aligned case theta=0 (mu = 0.025) - - dz = L./N; - error = abs(f-24./Re); - - figure - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - - H(1)=loglog(dz,error,'b*-','Linewidth',1.); hold on - H(2)=loglog(dz,.05*dz,'k--','Linewidth',1.); - H(3)=loglog(dz,.4*dz.^2,'k-','Linewidth',1.); - - set(gca,'FontName',Font_Name) - set(gca,'FontSize',Title_Font_Size) - axis([0.01 0.2 0.0000005 0.01]) - - xlabel('Grid Spacing, $\delta z$ (m)','Interpreter','LaTeX') - ylabel('Friction Factor Error') - h = legend(H,'FDS, $h=\Delta z_{10}/11$','$\mathcal{O}(\delta z)$','$\mathcal{O}(\delta z^2)$','Location','Southeast'); - set(h,'Interpreter','LaTeX') - - % add Git revision if file is available - - Git_Filename = [outdir 'geom_poiseuille_N10na_theta0' mth '_git.txt']; - addverstr(gca,Git_Filename,'loglog') - - % print to pdf - set(gcf,'Visible',Figure_Visibility); - set(gcf,'Units',Paper_Units); - set(gcf,'PaperUnits',Paper_Units); - set(gcf,'PaperSize',[Paper_Width Paper_Height]); - set(gcf,'Position',[0 0 Paper_Width Paper_Height]); - print(gcf,'-dpdf',['../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/geom_poiseuille_convergence_theta0na' mth]) - -end - diff --git a/Utilities/Matlab/scripts/pulsating.m b/Utilities/Matlab/scripts/pulsating.m deleted file mode 100644 index 10c9616ac4c..00000000000 --- a/Utilities/Matlab/scripts/pulsating.m +++ /dev/null @@ -1,200 +0,0 @@ -% Antonellis -% pulsating.m -% 06-24-10 - -close all -clear all - -plot_style - -data_dir = '../../Verification/Scalar_Analytical_Solution/'; -plot_dir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/'; - -devc_col = 3; % (x,y)=(pi,pi)-->devc_col=2, (x,y)=(1.5*pi,1.5*pi)-->devc_col=3 - -skip_case = 0; - -if ~exist([data_dir,'pulsating_FL2_16_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_16_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL2_32_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_32_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL2_64_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_64_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL2_128_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_128_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end - -if ~exist([data_dir,'pulsating_FL4_16_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_16_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL4_32_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_32_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL4_64_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_64_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL4_128_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_128_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end - -if ~exist([data_dir,'pulsating_FL0_16_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_16_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL0_32_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_32_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL0_64_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_64_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([data_dir,'pulsating_FL0_128_devc.csv']) - display(['Error: File ' [data_dir,'pulsating_FL2_128_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end - -if skip_case - return -end - -% Superbee limiter, FL=2 -M_FL2_16 = csvread([data_dir,'pulsating_FL2_16_devc.csv'],2,0); -M_FL2_32 = csvread([data_dir,'pulsating_FL2_32_devc.csv'],2,0); -M_FL2_64 = csvread([data_dir,'pulsating_FL2_64_devc.csv'],2,0); -M_FL2_128 = csvread([data_dir,'pulsating_FL2_128_devc.csv'],2,0); -t_FL2_16 = M_FL2_16(:,1); rho_fds_FL2_16 = M_FL2_16(:,devc_col); -t_FL2_32 = M_FL2_32(:,1); rho_fds_FL2_32 = M_FL2_32(:,devc_col); -t_FL2_64 = M_FL2_64(:,1); rho_fds_FL2_64 = M_FL2_64(:,devc_col); -t_FL2_128 = M_FL2_128(:,1); rho_fds_FL2_128 = M_FL2_128(:,devc_col); - -% CHARM limiter, FL=4 -M_FL4_16 = csvread([data_dir,'pulsating_FL4_16_devc.csv'],2,0); -M_FL4_32 = csvread([data_dir,'pulsating_FL4_32_devc.csv'],2,0); -M_FL4_64 = csvread([data_dir,'pulsating_FL4_64_devc.csv'],2,0); -M_FL4_128 = csvread([data_dir,'pulsating_FL4_128_devc.csv'],2,0); -t_FL4_16 = M_FL4_16(:,1); rho_fds_FL4_16 = M_FL4_16(:,devc_col); -t_FL4_32 = M_FL4_32(:,1); rho_fds_FL4_32 = M_FL4_32(:,devc_col); -t_FL4_64 = M_FL4_64(:,1); rho_fds_FL4_64 = M_FL4_64(:,devc_col); -t_FL4_128 = M_FL4_128(:,1); rho_fds_FL4_128 = M_FL4_128(:,devc_col); - -% central differencing, FL=0 -M_FL0_16 = csvread([data_dir,'pulsating_FL0_16_devc.csv'],2,0); -M_FL0_32 = csvread([data_dir,'pulsating_FL0_32_devc.csv'],2,0); -M_FL0_64 = csvread([data_dir,'pulsating_FL0_64_devc.csv'],2,0); -M_FL0_128 = csvread([data_dir,'pulsating_FL0_128_devc.csv'],2,0); -t_FL0_16 = M_FL0_16(:,1); rho_fds_FL0_16 = M_FL0_16(:,devc_col); -t_FL0_32 = M_FL0_32(:,1); rho_fds_FL0_32 = M_FL0_32(:,devc_col); -t_FL0_64 = M_FL0_64(:,1); rho_fds_FL0_64 = M_FL0_64(:,devc_col); -t_FL0_128 = M_FL0_128(:,1); rho_fds_FL0_128 = M_FL0_128(:,devc_col); - -% analytical solution - -B = 1; -w = 1; - -L = 2*pi; -if devc_col==2; x=pi; y=pi; end -if devc_col==3; x=1.5*pi; y=1.5*pi; end - -rho_FL2_16 = section2_soln(rho_fds_FL2_16(1),x-L/32,y-L/32,B,w,t_FL2_16); error_FL2_16 = norm(rho_fds_FL2_16-rho_FL2_16)/length(t_FL2_16); -rho_FL2_32 = section2_soln(rho_fds_FL2_32(1),x-L/64,y-L/64,B,w,t_FL2_32); error_FL2_32 = norm(rho_fds_FL2_32-rho_FL2_32)/length(t_FL2_32); -rho_FL2_64 = section2_soln(rho_fds_FL2_64(1),x-L/128,y-L/128,B,w,t_FL2_64); error_FL2_64 = norm(rho_fds_FL2_64-rho_FL2_64)/length(t_FL2_64); -rho_FL2_128 = section2_soln(rho_fds_FL2_128(1),x-L/256,y-L/256,B,w,t_FL2_128); error_FL2_128 = norm(rho_fds_FL2_128-rho_FL2_128)/length(t_FL2_128); - -rho_FL4_16 = section2_soln(rho_fds_FL4_16(1),x-L/32,y-L/32,B,w,t_FL4_16); error_FL4_16 = norm(rho_fds_FL4_16-rho_FL4_16)/length(t_FL4_16); -rho_FL4_32 = section2_soln(rho_fds_FL4_32(1),x-L/64,y-L/64,B,w,t_FL4_32); error_FL4_32 = norm(rho_fds_FL4_32-rho_FL4_32)/length(t_FL4_32); -rho_FL4_64 = section2_soln(rho_fds_FL4_64(1),x-L/128,y-L/128,B,w,t_FL4_64); error_FL4_64 = norm(rho_fds_FL4_64-rho_FL4_64)/length(t_FL4_64); -rho_FL4_128 = section2_soln(rho_fds_FL4_128(1),x-L/256,y-L/256,B,w,t_FL4_128); error_FL4_128 = norm(rho_fds_FL4_128-rho_FL4_128)/length(t_FL4_128); - -rho_FL0_16 = section2_soln(rho_fds_FL0_16(1),x-L/32,y-L/32,B,w,t_FL0_16); error_FL0_16 = norm(rho_fds_FL0_16-rho_FL0_16)/length(t_FL0_16); -rho_FL0_32 = section2_soln(rho_fds_FL0_32(1),x-L/64,y-L/64,B,w,t_FL0_32); error_FL0_32 = norm(rho_fds_FL0_32-rho_FL0_32)/length(t_FL0_32); -rho_FL0_64 = section2_soln(rho_fds_FL0_64(1),x-L/128,y-L/128,B,w,t_FL0_64); error_FL0_64 = norm(rho_fds_FL0_64-rho_FL0_64)/length(t_FL0_64); -rho_FL0_128 = section2_soln(rho_fds_FL0_128(1),x-L/256,y-L/256,B,w,t_FL0_128); error_FL0_128 = norm(rho_fds_FL0_128-rho_FL0_128)/length(t_FL0_128); - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -H(5)=plot(t_FL2_128,rho_FL2_128,'k-','LineWidth',Line_Width); hold on -H(1)=plot(t_FL2_16,rho_fds_FL2_16,'c--','LineWidth',Line_Width); hold on -H(2)=plot(t_FL2_32,rho_fds_FL2_32,'g--','LineWidth',Line_Width); hold on -H(3)=plot(t_FL2_64,rho_fds_FL2_64,'b--','LineWidth',Line_Width); hold on -H(4)=plot(t_FL2_128,rho_fds_FL2_128,'r--','LineWidth',Line_Width); hold on - -xlabel('Time (s)','FontSize',Title_Font_Size,'Interpreter',Font_Interpreter,'FontName',Font_Name) -ylabel('Density (kg/m³)','FontSize',Title_Font_Size,'Interpreter',Font_Interpreter,'FontName',Font_Name) -axis([0 12.5 0 2]) -legend_handle=legend(H,'FDS N=16','FDS N=32','FDS N=64','FDS N=128','Analytical Solution','Location','NorthEast'); -set(legend_handle,'Interpreter',Font_Interpreter); -set(legend_handle,'Fontsize',Key_Font_Size); -set(legend_handle,'Box','on'); -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Title_Font_Size) - -% add Git revision if file is available - -Git_Filename = [data_dir,'pulsating_FL2_16_git.txt']; -addverstr(gca,Git_Filename,'linear') - -% print to pdf -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'pulsating_time_series']) - -% convergence plot - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -h = 2*pi./[16 32 64 128]; -e_FL2 = [error_FL2_16 error_FL2_32 error_FL2_64 error_FL2_128]; -e_FL4 = [error_FL4_16 error_FL4_32 error_FL4_64 error_FL4_128]; -e_FL0 = [error_FL0_16 error_FL0_32 error_FL0_64 error_FL0_128]; - -H(1)=loglog(h,e_FL0,'b*-','LineWidth',Line_Width); hold on -H(2)=loglog(h,e_FL2,'ro-','LineWidth',Line_Width); hold on -H(3)=loglog(h,e_FL4,'g^-','LineWidth',Line_Width); hold on -H(4)=loglog(h,.1*h,'k--','LineWidth',Line_Width); -H(5)=loglog(h,.1*h.^2,'k-','LineWidth',Line_Width); - -xlabel('Grid Spacing (m)','FontSize',Title_Font_Size,'Interpreter',Font_Interpreter,'FontName',Font_Name) -ylabel('L2 Error (kg/m³)','FontSize',Title_Font_Size,'Interpreter',Font_Interpreter,'FontName',Font_Name) -axis([1e-2 1e0 1e-6 1e-1]) -legend_handle=legend(H(1:5),'FDS Central','FDS Superbee','FDS CHARM','{\it O}({\it\deltax})','{\it O}({\it\deltax^2})','Location','NorthWest'); -set(legend_handle,'Interpreter',Font_Interpreter); -set(legend_handle,'Fontsize',Key_Font_Size); -set(legend_handle,'Box','on'); -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Title_Font_Size) - -% add Git revision if file is available - -Git_Filename = [data_dir,'pulsating_FL2_16_git.txt']; -addverstr(gca,Git_Filename,'loglog') - -% print to pdf -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'pulsating_convergence']) - - - diff --git a/Utilities/Matlab/scripts/ribbed_channel.m b/Utilities/Matlab/scripts/ribbed_channel.m deleted file mode 100644 index 6517c2dfcf4..00000000000 --- a/Utilities/Matlab/scripts/ribbed_channel.m +++ /dev/null @@ -1,315 +0,0 @@ -% McDermott -% 9-18-12 -% ribbed_channel.m - -close all -clear all - -outdir = '../../../out/Casara_Arts_Ribbed_Channel/'; -expdir = '../../../exp/Casara_Arts_Ribbed_Channel/'; -plotdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/'; - -plot_style - -nx = [20 40 80 160]; % not correct at the moment, just referencing old file names -lnx = length(nx); -Ub=6.2; % exp bulk velocity -L= 0.3; % channel length -D = 0.1; % channel height -h = 0.03; -dx = L./[10 20 40 80]; -fds_marker = {'r+-' 'c^-' 'g>-' 'k-'}; -fds_key = {'FDS {\it h/\deltax}=3' 'FDS {\it h/\deltax}=6' 'FDS {\it h/\deltax}=12' 'FDS {\it h/\deltax}=24'}; -geom = {'_' '_geom_'}; - -if ~exist([expdir,'ribbed_channel_data.csv']) - display(['Error: File ' [expdir,'ribbed_channel_data.csv'] ' does not exist. Skipping case.']) - return -end - -DATA = importdata([expdir,'ribbed_channel_data.csv'],',',1); - -for ii=1:length(geom) - - % check existence of device files - - for i=1:lnx - if ~exist([outdir,'ribbed_channel',geom{ii},num2str(nx(i)),'_devc.csv']) - display(['Error: File ' [outdir,'ribbed_channel',geom{ii},num2str(nx(i)),'_devc.csv'] ' does not exist. Skipping case.']) - return - end - end - - % check bulk velocity is 6.2 m/s - - for i=1:lnx - M{i} = importdata([outdir,'ribbed_channel',geom{ii},num2str(nx(i)),'_devc.csv'],',',2); - end - - figure - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - - H(1)=plot([0 100],Ub*ones(1,2),'k-','linewidth',2); hold on - - for i=1:lnx - t_fds = M{i}.data(:,1); - Ub_fds = M{i}.data(:,2); - H(1+i)=plot(t_fds,Ub_fds,fds_marker{i}); - t_range = find(t_fds>2); - if abs(mean(Ub_fds(t_range))-Ub)/Ub > 0.01 - disp(['Matlab Warning: Ub mean nx ',geom{ii},num2str(nx(i)),' = ',num2str(mean(Ub_fds(t_range)))]) - end - end - - xlabel('Time (s)','Interpreter',Font_Interpreter,'Fontsize',Label_Font_Size,'FontName',Font_Name) - ylabel('Bulk Velocity (m/s)','Interpreter',Font_Interpreter,'Fontsize',Label_Font_Size,'FontName',Font_Name) - - axis([0 10 0 1.5*Ub]) - - set(gca,'FontName',Font_Name) - set(gca,'FontSize',Title_Font_Size) - - lh = legend(H,'Exp Bulk Velocity',fds_key{1:lnx},'Location','SouthEast'); - set(lh,'Interpreter',Font_Interpreter) - - % add Git revision if file is available - - Git_Filename = [outdir,'ribbed_channel',geom{ii},num2str(nx(1)),'_git.txt']; - addverstr(gca,Git_Filename,'linear') - - % print to pdf - - set(gcf,'Visible',Figure_Visibility); - set(gcf,'Units',Paper_Units); - set(gcf,'PaperUnits',Paper_Units); - set(gcf,'PaperSize',[Paper_Width Paper_Height]); - set(gcf,'Position',[0 0 Paper_Width Paper_Height]); - print(gcf,'-dpdf',[plotdir,'ribbed_channel',geom{ii},'Ubulk']) - - % check existence of line device files - - for i=1:lnx - if ~exist([outdir,'ribbed_channel',geom{ii},num2str(nx(i)),'_line.csv']) - display(['Error: File ' [outdir,'ribbed_channel',geom{ii},num2str(nx(i)),'_line.csv'] ' does not exist. Skipping case.']) - return - end - end - - % read experimental and FDS data files - - for i=1:lnx - M{i} = importdata([outdir,'ribbed_channel',geom{ii},num2str(nx(i)),'_line.csv'],',',2); - end - - % organize and plot streamwise U along bottom of channel - - j = find(strcmp(DATA.colheaders,'x/h U strm')); - xoh = DATA.data(:,j); - j = find(strcmp(DATA.colheaders,'U strm')); - u_data = DATA.data(:,j); - - figure - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - - H(1)=plot(xoh,u_data,'bo'); hold on - - for i=1:lnx - j = find(strcmp(M{i}.colheaders,'u_strm_bot-x')); - x = M{i}.data(:,j); - I = find(x<0); - x(I) = x(I) + L; - [x I] = sort(x); - - j = find(strcmp(M{i}.colheaders,'u_strm_bot')); - u_fds = M{i}.data(:,j); - u_fds = u_fds(I); - - H(1+i)=plot(x/h,u_fds/Ub,fds_marker{i}); - end - - xlabel('\it x/h','Interpreter',Font_Interpreter,'Fontsize',Label_Font_Size,'FontName',Font_Name) - ylabel('\it U/U_b','Interpreter',Font_Interpreter,'Fontsize',Label_Font_Size,'FontName',Font_Name) - - axis([0 10 -0.6 0.6]) - set(gca,'YTick',-0.6:0.3:0.6) - set(gca,'YTickLabel',-0.6:0.3:0.6) - - set(gca,'FontName',Font_Name) - set(gca,'FontSize',Title_Font_Size) - - lh = legend(H,'PIV data',fds_key{1:lnx},'Location','Northwest'); - set(lh,'Interpreter',Font_Interpreter) - - % add Git revision if file is available - - Git_Filename = [outdir,'ribbed_channel',geom{ii},num2str(nx(1)),'_git.txt']; - addverstr(gca,Git_Filename,'linear') - - % print to pdf - - set(gcf,'Visible',Figure_Visibility); - set(gcf,'Units',Paper_Units); - set(gcf,'PaperUnits',Paper_Units); - set(gcf,'PaperSize',[Paper_Width Paper_Height]); - set(gcf,'Position',[0 0 Paper_Width Paper_Height]); - print(gcf,'-dpdf',[plotdir,'ribbed_channel',geom{ii},'u_strm']) - - % streamwise urms along bottom of channel - - j = find(strcmp(DATA.colheaders,'x/h urms strm')); - xoh = DATA.data(:,j); - j = find(strcmp(DATA.colheaders,'urms strm')); - urms_data = DATA.data(:,j); - - figure - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - - H(1)=plot(xoh,urms_data,'bo'); hold on - - for i=1:lnx - j = find(strcmp(M{i}.colheaders,'urms_strm_bot-x')); - x = M{i}.data(:,j); - I = find(x<0); - x(I) = x(I) + L; - [x I] = sort(x); - - j = find(strcmp(M{i}.colheaders,'urms_strm_bot')); - urms_fds = M{i}.data(:,j); - urms_fds = urms_fds(I); - - H(1+i)=plot(x/h,urms_fds/Ub,fds_marker{i}); - end - - xlabel('\it x/h','Interpreter',Font_Interpreter,'Fontsize',Label_Font_Size,'FontName',Font_Name) - yh = ylabel('\it U_{rms}/U_b','Interpreter',Font_Interpreter,'Fontsize',Label_Font_Size,'FontName',Font_Name); - set(yh,'Position',[-0.8194-.2 0.2963-.025 1.0001]) - - axis([0 10 0 0.6]) - - set(gca,'FontName',Font_Name) - set(gca,'FontSize',Title_Font_Size) - - lh = legend(H,'PIV data',fds_key{1:lnx},'Location','Northwest'); - set(lh,'Interpreter',Font_Interpreter) - - % add Git revision if file is available - - Git_Filename = [outdir,'ribbed_channel',geom{ii},num2str(nx(1)),'_git.txt']; - addverstr(gca,Git_Filename,'linear') - - % print to pdf - - set(gcf,'Visible',Figure_Visibility); - set(gcf,'Units',Paper_Units); - set(gcf,'PaperUnits',Paper_Units); - set(gcf,'PaperSize',[Paper_Width Paper_Height]); - set(gcf,'Position',[0 0 Paper_Width Paper_Height]); - print(gcf,'-dpdf',[plotdir,'ribbed_channel',geom{ii},'urms_strm']) - - % streamwise U profile at x/h=0 (center of rib) - - j = find(strcmp(DATA.colheaders,'y/h U prof')); - yoh = DATA.data(:,j); - j = find(strcmp(DATA.colheaders,'U prof')); - u_data = DATA.data(:,j); - - figure - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - - H(1)=plot(u_data,yoh,'bo'); hold on - - for i=1:lnx - j = find(strcmp(M{i}.colheaders,'u_prof_rib-z')); - I = find( M{i}.data(:,j)>h & M{i}.data(:,j)h & M{i}.data(:,j) 0.01 - display(['Matlab Warning: FavreZ in shunn3_FavreZ_64 is out of tolerance. Error = ',num2str(FavreZ_error_64)]) -end - - diff --git a/Utilities/Matlab/scripts/shunn_mms_temporal_error.m b/Utilities/Matlab/scripts/shunn_mms_temporal_error.m deleted file mode 100644 index 12bff3c386f..00000000000 --- a/Utilities/Matlab/scripts/shunn_mms_temporal_error.m +++ /dev/null @@ -1,183 +0,0 @@ -%!/usr/bin/matlab -%McDermott -%8-3-2015 -%shunn_mms_temporal_error.m - -close all -clear all - -% Problem 1 parameters -r = 0.5; -nx = 256; - -% Output files - -datadir = '../../Verification/Scalar_Analytical_Solution/'; -plotdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/'; -filename = {'shunn3_256_cfl_1_mms.csv', ... - 'shunn3_256_cfl_p5_mms.csv', ... - 'shunn3_256_cfl_p25_mms.csv', ... - 'shunn3_256_cfl_p125_mms.csv', ... - 'shunn3_256_cfl_p0625_mms.csv'}; - -skip_case = 0; - -for n=1:length(filename) - if ~exist([datadir,filename{n}]) - display(['Error: File ' [datadir,filename{n}] ' does not exist. Skipping case.']) - skip_case = 1; - end -end - -if skip_case - return -end - -% Gather FDS results - -M1 = importdata([datadir,filename{3}],',',2); -M2 = importdata([datadir,filename{4}],',',2); -M3 = importdata([datadir,filename{5}],',',2); - -rho_1 = M1.data(:,1); -rho_2 = M2.data(:,1); -rho_3 = M3.data(:,1); -Z_1 = M1.data(:,2); -Z_2 = M2.data(:,2); -Z_3 = M3.data(:,2); -U_1 = M1.data(:,3); -U_2 = M2.data(:,3); -U_3 = M3.data(:,3); -H_1 = M1.data(:,5); -H_2 = M2.data(:,5); -H_3 = M3.data(:,5); - -p_rho = log( abs(rho_3-rho_2)./abs(rho_2-rho_1) )./log(r); -p_Z = log( abs(Z_3-Z_2)./abs(Z_2-Z_1) )./log(r); -p_U = log( abs(U_3-U_2)./abs(U_2-U_1) )./log(r); -p_H = log( abs(H_3-H_2)./abs(H_2-H_1) )./log(r); - -% disp('Shunn 3 temporal order') -% disp(' ') -% disp(['L1 p rho = ',num2str( norm(p_rho,1)/(nx*nx) )]) -% disp(['L2 p rho = ',num2str( norm(p_rho,2)/nx )]) -% disp(['Linf p rho = ',num2str( norm(p_rho,-inf) )]) -% disp(' ') -% disp(['L1 p Z = ',num2str( norm(p_Z,1)/(nx*nx) )]) -% disp(['L2 p Z = ',num2str( norm(p_Z,2)/nx )]) -% disp(['Linf p Z = ',num2str( norm(p_Z,-inf) )]) -% disp(' ') -% disp(['L1 p U = ',num2str( norm(p_U,1)/(nx*nx) )]) -% disp(['L2 p U = ',num2str( norm(p_U,2)/nx )]) -% disp(['Linf p U = ',num2str( norm(p_U,-inf) )]) -% disp(' ') -% disp(['L1 p H = ',num2str( norm(p_H,1)/(nx*nx) )]) -% disp(['L2 p H = ',num2str( norm(p_H,2)/nx )]) -% disp(['Linf p H = ',num2str( norm(p_H,-inf) )]) -% disp(' ') - -% flag errors - -L2_rho = norm(p_rho,2)/nx; -if L2_rho<1.99 - disp(['Matlab Warning: L2_rho = ',num2str(L2_rho),' in Shunn 3 MMS temporal order']) -end - -L2_Z = norm(p_Z,2)/nx; -if L2_Z<1.99 - disp(['Matlab Warning: L2_Z = ',num2str(L2_Z),' in Shunn 3 MMS temporal order']) -end - -L2_U = norm(p_U,2)/nx; -if L2_U<1.99 - disp(['Matlab Warning: L2_U = ',num2str(L2_U),' in Shunn 3 MMS temporal order']) -end - -L2_H = norm(p_H,2)/nx; -if L2_H<0.99 - disp(['Matlab Warning: L2_H = ',num2str(L2_H),' in Shunn 3 MMS temporal order']) -end - -% Tony Saad's way... -p1_rho_saad = log( norm(rho_3-rho_2,1)./norm(rho_2-rho_1,1) )./log(r); -p2_rho_saad = log( norm(rho_3-rho_2,2)./norm(rho_2-rho_1,2) )./log(r); -pinf_rho_saad = log( norm(rho_3-rho_2,inf)./norm(rho_2-rho_1,inf) )./log(r); -% disp(['L1 p rho Saad = ',num2str( p1_rho_saad )]) -% disp(['L2 p rho Saad = ',num2str( p2_rho_saad )]) -% disp(['Linf p rho Saad = ',num2str( pinf_rho_saad )]) -% disp(' ') -p1_Z_saad = log( norm(Z_3-Z_2,1)./norm(Z_2-Z_1,1) )./log(r); -p2_Z_saad = log( norm(Z_3-Z_2,2)./norm(Z_2-Z_1,2) )./log(r); -pinf_Z_saad = log( norm(Z_3-Z_2,inf)./norm(Z_2-Z_1,inf) )./log(r); -% disp(['L1 p Z Saad = ',num2str( p1_Z_saad )]) -% disp(['L2 p Z Saad = ',num2str( p2_Z_saad )]) -% disp(['Linf p Z Saad = ',num2str( pinf_Z_saad )]) -% disp(' ') -p1_U_saad = log( norm(U_3-U_2,1)./norm(U_2-U_1,1) )./log(r); -p2_U_saad = log( norm(U_3-U_2,2)./norm(U_2-U_1,2) )./log(r); -pinf_U_saad = log( norm(U_3-U_2,inf)./norm(U_2-U_1,inf) )./log(r); -% disp(['L1 p U Saad = ',num2str( p1_U_saad )]) -% disp(['L2 p U Saad = ',num2str( p2_U_saad )]) -% disp(['Linf p U Saad = ',num2str( pinf_U_saad )]) -% disp(' ') -p1_H_saad = log( norm(H_3-H_2,1)./norm(H_2-H_1,1) )./log(r); -p2_H_saad = log( norm(H_3-H_2,2)./norm(H_2-H_1,2) )./log(r); -pinf_H_saad = log( norm(H_3-H_2,inf)./norm(H_2-H_1,inf) )./log(r); -% disp(['L1 p H Saad = ',num2str( p1_H_saad )]) -% disp(['L2 p H Saad = ',num2str( p2_H_saad )]) -% disp(['Linf p H Saad = ',num2str( pinf_H_saad )]) - -%surf(reshape(p_U,[nx,nx]),'EdgeColor','none','LineStyle','none','FaceLighting','phong') - -% write the norms to a latex table - -fid = fopen([plotdir,'shunn_terr_norms.tex'],'wt'); - -tmp_str = ['$L_1$ & ', ... - num2str( norm(p_rho,1)/(nx*nx) ),' & ', ... - num2str( norm(p_Z,1)/(nx*nx) ),' & ', ... - num2str( norm(p_U,1)/(nx*nx) ),' & ', ... - num2str( norm(p_H,1)/(nx*nx) ),' \\']; - -fprintf(fid,'%s\n',tmp_str); - -tmp_str = ['$L_2$ & ', ... - num2str( norm(p_rho,2)/nx ),' & ', ... - num2str( norm(p_Z,2)/nx ),' & ', ... - num2str( norm(p_U,2)/nx ),' & ', ... - num2str( norm(p_H,2)/nx ),' \\']; - -fprintf(fid,'%s\n',tmp_str); - -tmp_str = ['$L_1$ Saad & ', ... - num2str( p1_rho_saad ),' & ', ... - num2str( p1_Z_saad ),' & ', ... - num2str( p1_U_saad ),' & ', ... - num2str( p1_H_saad ),' \\']; - -fprintf(fid,'%s\n',tmp_str); - -tmp_str = ['$L_2$ Saad & ', ... - num2str( p2_rho_saad ),' & ', ... - num2str( p2_Z_saad ),' & ', ... - num2str( p2_U_saad ),' & ', ... - num2str( p2_H_saad ),' \\']; - -fprintf(fid,'%s\n',tmp_str); - -tmp_str = ['$L_{\infty}$ Saad & ', ... - num2str( pinf_rho_saad ),' & ', ... - num2str( pinf_Z_saad ),' & ', ... - num2str( pinf_U_saad ),' & ', ... - num2str( pinf_H_saad )]; - -fprintf(fid,'%s\n',tmp_str); - -fclose(fid); - - - - - - - diff --git a/Utilities/Matlab/scripts/soborot_mass_transport.m b/Utilities/Matlab/scripts/soborot_mass_transport.m deleted file mode 100644 index bc5f6d3ab39..00000000000 --- a/Utilities/Matlab/scripts/soborot_mass_transport.m +++ /dev/null @@ -1,480 +0,0 @@ -% McDermott -% 12-7-2018 -% soborot_mass_transport.m -% -% Solid body rotation flow field, scalar transport - -close all -clear all - -plot_style - -data_dir = '../../Verification/Scalar_Analytical_Solution/'; -plot_dir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/'; - -chid = {'soborot_charm_cos_wave_16', ... - 'soborot_charm_cos_wave_32', ... - 'soborot_charm_cos_wave_64', ... - 'soborot_charm_square_wave_128', ... - 'soborot_charm_square_wave_16', ... - 'soborot_charm_square_wave_32', ... - 'soborot_charm_square_wave_64', ... - 'soborot_godunov_square_wave_128', ... - 'soborot_godunov_square_wave_16', ... - 'soborot_godunov_square_wave_32', ... - 'soborot_godunov_square_wave_64', ... - 'soborot_superbee_cos_wave_128', ... - 'soborot_superbee_cos_wave_16', ... - 'soborot_superbee_cos_wave_32', ... - 'soborot_superbee_cos_wave_64', ... - 'soborot_superbee_square_wave_128', ... - 'soborot_superbee_square_wave_128_1mesh', ... - 'soborot_superbee_square_wave_16', ... - 'soborot_superbee_square_wave_32', ... - 'soborot_superbee_square_wave_64'}; - - -skip_case = 0; -for i=1:length(chid) - devc_file = [data_dir,chid{i},'_devc.csv']; - if ~exist(devc_file) - display(['Error: File ' devc_file ' does not exist. Skipping case.']) - skip_case = 1; - end -end - -if skip_case - return -end - -% positions of DEVC along diagonal D - -L=1; -D=L*sqrt(2); -r_exact = linspace(0,D,1000); -Y_exact = zeros(1,length(r_exact)); -i_range = find(r_exact>0.25 & r_exact<0.75); -Y_exact(i_range) = ones(1,length(i_range)); -r_16 = (D/32):(D/16):(D-(D/32)); -r_32 = (D/64):(D/32):(D-(D/64)); -r_64 = (D/128):(D/64):(D-(D/128)); -r_128 = (D/256):(D/128):(D-(D/256)); - -%%%%%% SQUARE WAVE %%%%%% - -% FLUX_LIMITER='CHARM' - -M = importdata([data_dir,'soborot_charm_square_wave_16_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-16')); -Y_charm_16 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_charm_square_wave_32_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-32')); -Y_charm_32 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_charm_square_wave_64_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-64')); -Y_charm_64 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_charm_square_wave_128_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-128')); -Y_charm_128 = M.data(end,col_start:col_end); - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) -H(1)=plot(r_exact,Y_exact,'k-'); hold on -H(2)=plot(r_16,Y_charm_16,'bo-'); -H(3)=plot(r_32,Y_charm_32,'m*-'); -H(4)=plot(r_64,Y_charm_64,'r^-'); -H(5)=plot(r_128,Y_charm_128,'gsq-'); - -xlabel('Radial Position (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Scalar Mass Fraction','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -axis([0 1 0 1.2]) -text(.05,1.1,'CHARM','FontName',Font_Name,'FontSize',Label_Font_Size) - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -lh=legend(H,'Exact','{\itn}=16','{\itn}=32','{\itn}=64','{\itn}=128'); -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) -legend boxoff - -Git_Filename = [data_dir,'soborot_charm_square_wave_16_git.txt']; -addverstr(gca,Git_Filename,'linear') - -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'soborot_charm_square_wave']); - -% FLUX_LIMITER='SUPERBEE' - -M = importdata([data_dir,'soborot_superbee_square_wave_16_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-16')); -Y_superbee_16 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_superbee_square_wave_32_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-32')); -Y_superbee_32 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_superbee_square_wave_64_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-64')); -Y_superbee_64 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_superbee_square_wave_128_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-128')); -Y_superbee_128 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_superbee_square_wave_128_1mesh_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-128')); -Y_superbee_128_1mesh = M.data(end,col_start:col_end); - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) -H(1)=plot(r_exact,Y_exact,'k-'); hold on -H(2)=plot(r_16,Y_superbee_16,'bo-'); -H(3)=plot(r_32,Y_superbee_32,'m*-'); -H(4)=plot(r_64,Y_superbee_64,'r^-'); -H(5)=plot(r_128,Y_superbee_128,'gsq-'); - -xlabel('Radial Position (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Scalar Mass Fraction','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -axis([0 1 0 1.2]) -text(.05,1.1,'Superbee','FontName',Font_Name,'FontSize',Label_Font_Size) - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -lh=legend(H,'Exact','{\itn}=16','{\itn}=32','{\itn}=64','{\itn}=128'); -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) -legend boxoff - -Git_Filename = [data_dir,'soborot_superbee_square_wave_16_git.txt']; -addverstr(gca,Git_Filename,'linear') - -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'soborot_superbee_square_wave']); - -% FLUX_LIMITER='GODUNOV' - -M = importdata([data_dir,'soborot_godunov_square_wave_16_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-16')); -Y_godunov_16 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_godunov_square_wave_32_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-32')); -Y_godunov_32 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_godunov_square_wave_64_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-64')); -Y_godunov_64 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_godunov_square_wave_128_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-128')); -Y_godunov_128 = M.data(end,col_start:col_end); - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) -H(1)=plot(r_exact,Y_exact,'k-'); hold on -H(2)=plot(r_16,Y_godunov_16,'bo-'); -H(3)=plot(r_32,Y_godunov_32,'m*-'); -H(4)=plot(r_64,Y_godunov_64,'r^-'); -H(5)=plot(r_128,Y_godunov_128,'gsq-'); - -xlabel('Radial Position (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Scalar Mass Fraction','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -axis([0 1 0 1.2]) -text(.05,1.1,'Godunov','FontName',Font_Name,'FontSize',Label_Font_Size) - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -lh=legend(H,'Exact','{\itn}=16','{\itn}=32','{\itn}=64','{\itn}=128'); -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) -legend boxoff - -Git_Filename = [data_dir,'soborot_godunov_square_wave_16_git.txt']; -addverstr(gca,Git_Filename,'linear') - -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'soborot_godunov_square_wave']); - -% plot error - -Y_exact_16 = interp1(r_exact,Y_exact,r_16,'nearest'); -Y_exact_32 = interp1(r_exact,Y_exact,r_32,'nearest'); -Y_exact_64 = interp1(r_exact,Y_exact,r_64,'nearest'); -Y_exact_128 = interp1(r_exact,Y_exact,r_128,'nearest'); - -% figure; plot(r_16,Y_exact_16,'ko'); hold on; plot([0.25 0.25],[0 1],'k-'); plot([0.75 0.75],[0 1],'k-') -% figure; plot(r_32,Y_exact_32,'ko'); hold on; plot([0.25 0.25],[0 1],'k-'); plot([0.75 0.75],[0 1],'k-') -% figure; plot(r_64,Y_exact_64,'ko'); hold on; plot([0.25 0.25],[0 1],'k-'); plot([0.75 0.75],[0 1],'k-') -% figure; plot(r_128,Y_exact_128,'ko'); hold on; plot([0.25 0.25],[0 1],'k-'); plot([0.75 0.75],[0 1],'k-') - -e_charm_16 = norm(Y_charm_16-Y_exact_16,1)/length(r_16); -e_charm_32 = norm(Y_charm_32-Y_exact_32,1)/length(r_32); -e_charm_64 = norm(Y_charm_64-Y_exact_64,1)/length(r_64); -e_charm_128 = norm(Y_charm_128-Y_exact_128,1)/length(r_128); - -e_superbee_16 = norm(Y_superbee_16-Y_exact_16,1)/length(r_16); -e_superbee_32 = norm(Y_superbee_32-Y_exact_32,1)/length(r_32); -e_superbee_64 = norm(Y_superbee_64-Y_exact_64,1)/length(r_64); -e_superbee_128 = norm(Y_superbee_128-Y_exact_128,1)/length(r_128); -e_superbee_128_1mesh = norm(Y_superbee_128_1mesh-Y_exact_128,1)/length(r_128); - -% format long e -% Y_superbee_128_1mesh-Y_superbee_128 -% abs(e_superbee_128_1mesh - e_superbee_128) -if abs(e_superbee_128_1mesh - e_superbee_128)>1.e-10 - display(['Error: soborot_superbee_square_wave_128 single mesh and multi-mesh out of tolerance']) -end - -e_godunov_16 = norm(Y_godunov_16-Y_exact_16,1)/length(r_16); -e_godunov_32 = norm(Y_godunov_32-Y_exact_32,1)/length(r_32); -e_godunov_64 = norm(Y_godunov_64-Y_exact_64,1)/length(r_64); -e_godunov_128 = norm(Y_godunov_128-Y_exact_128,1)/length(r_128); - -dx = L./[16 32 64 128]; - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) -H(1)=loglog(dx,dx.^.5,'k-.'); hold on -H(2)=loglog(dx,dx.^1,'k--'); -H(3)=loglog(dx,[e_godunov_16 e_godunov_32 e_godunov_64 e_godunov_128],'ksq-'); -H(4)=loglog(dx,[e_superbee_16 e_superbee_32 e_superbee_64 e_superbee_128],'k*-'); -H(5)=loglog(dx,[e_charm_16 e_charm_32 e_charm_64 e_charm_128],'ko-'); - -% trap square wave error -if e_godunov_128>4.2e-02 - display(['Error: soborot_godunov_square_wave_128 out of tolerance']) -end -if e_charm_128>1.4e-02 - display(['Error: soborot_charm_square_wave_128 out of tolerance']) -end -if e_superbee_128>1.0e-02 - display(['Error: soborot_superbee_square_wave_128 out of tolerance']) -end - -axis([min(dx) .1 min(dx) max(dx.^.5)]) -xlabel('Grid Spacing (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('L2 Error','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -text(.009,.18,'Square Wave Error','FontName',Font_Name,'FontSize',Label_Font_Size) - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -lh=legend(H,'{\itO}(\delta{\itx}^{1/2})','{\itO}(\delta{\itx})','Godunov','Superbee','CHARM'); -set(lh,'Location','Southeast') -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) -legend boxoff - -Git_Filename = [data_dir,'soborot_superbee_square_wave_128_git.txt']; -addverstr(gca,Git_Filename,'loglog') - -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'soborot_square_wave_error']); - -%%%%%% COSINE WAVE %%%%%% - -% FLUX_LIMITER='CHARM' - -M = importdata([data_dir,'soborot_charm_cos_wave_16_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-16')); -Y_charm_16 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_charm_cos_wave_32_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-32')); -Y_charm_32 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_charm_cos_wave_64_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-64')); -Y_charm_64 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_charm_cos_wave_128_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-128')); -Y_charm_128 = M.data(end,col_start:col_end); - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) -Y_exact = zeros(1,length(r_exact)); -i_range = find(r_exact>0.25 & r_exact<0.75); -Y_exact(i_range) = 0.5*(1. + cos(4.*pi*r_exact(i_range))); % see PERIODIC_TEST==13 in wall.f90 -H(1)=plot(r_exact,Y_exact,'k-'); hold on -H(2)=plot(r_16,Y_charm_16,'bo-'); -H(3)=plot(r_32,Y_charm_32,'m*-'); -H(4)=plot(r_64,Y_charm_64,'r^-'); -H(5)=plot(r_128,Y_charm_128,'gsq-'); - -xlabel('Radial Position (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Scalar Mass Fraction','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -axis([0 1 0 1.2]) -text(.05,1.1,'CHARM','FontName',Font_Name,'FontSize',Label_Font_Size) - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -lh=legend(H,'Exact','{\itn}=16','{\itn}=32','{\itn}=64','{\itn}=128'); -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) -legend boxoff - -Git_Filename = [data_dir,'soborot_charm_cos_wave_16_git.txt']; -addverstr(gca,Git_Filename,'linear') - -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'soborot_charm_cos_wave']); - -% FLUX_LIMITER='SUPERBEE' - -M = importdata([data_dir,'soborot_superbee_cos_wave_16_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-16')); -Y_superbee_16 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_superbee_cos_wave_32_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-32')); -Y_superbee_32 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_superbee_cos_wave_64_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-64')); -Y_superbee_64 = M.data(end,col_start:col_end); - -M = importdata([data_dir,'soborot_superbee_cos_wave_128_devc.csv'],',',2); -col_start = find(strcmp(M.colheaders,'Y_TRACER-1')); -col_end = find(strcmp(M.colheaders,'Y_TRACER-128')); -Y_superbee_128 = M.data(end,col_start:col_end); - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) -Y_exact = zeros(1,length(r_exact)); -i_range = find(r_exact>0.25 & r_exact<0.75); -Y_exact(i_range) = 0.5*(1. + cos(4.*pi*r_exact(i_range))); % see PERIODIC_TEST==13 in wall.f90 -H(1)=plot(r_exact,Y_exact,'k-'); hold on -H(2)=plot(r_16,Y_superbee_16,'bo-'); -H(3)=plot(r_32,Y_superbee_32,'m*-'); -H(4)=plot(r_64,Y_superbee_64,'r^-'); -H(5)=plot(r_128,Y_superbee_128,'gsq-'); - -xlabel('Radial Position (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Scalar Mass Fraction','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -axis([0 1 0 1.2]) -text(.05,1.1,'Superbee','FontName',Font_Name,'FontSize',Label_Font_Size) - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -lh=legend(H,'Exact','{\itn}=16','{\itn}=32','{\itn}=64','{\itn}=128'); -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) -legend boxoff - -Git_Filename = [data_dir,'soborot_superbee_cos_wave_16_git.txt']; -addverstr(gca,Git_Filename,'linear') - -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'soborot_superbee_cos_wave']); - -% plot error - -Y_exact_16 = interp1(r_exact,Y_exact,r_16); -Y_exact_32 = interp1(r_exact,Y_exact,r_32); -Y_exact_64 = interp1(r_exact,Y_exact,r_64); -Y_exact_128 = interp1(r_exact,Y_exact,r_128); - -e_charm_16 = norm(Y_charm_16-Y_exact_16,1)/length(r_16); -e_charm_32 = norm(Y_charm_32-Y_exact_32,1)/length(r_32); -e_charm_64 = norm(Y_charm_64-Y_exact_64,1)/length(r_64); -e_charm_128 = norm(Y_charm_128-Y_exact_128,1)/length(r_128); - -e_superbee_16 = norm(Y_superbee_16-Y_exact_16,1)/length(r_16); -e_superbee_32 = norm(Y_superbee_32-Y_exact_32,1)/length(r_32); -e_superbee_64 = norm(Y_superbee_64-Y_exact_64,1)/length(r_64); -e_superbee_128 = norm(Y_superbee_128-Y_exact_128,1)/length(r_128); - -dx = L./[16 32 64 128]; - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) -H(1)=loglog(dx,dx.^1,'k-.'); hold on -H(2)=loglog(dx,dx.^2,'k--'); -H(3)=loglog(dx,[e_charm_16 e_charm_32 e_charm_64 e_charm_128],'ko-'); -H(4)=loglog(dx,[e_superbee_16 e_superbee_32 e_superbee_64 e_superbee_128],'k*-'); - -% trap cosine wave error -if e_charm_128>2.9e-04 - display(['Error: soborot_charm_cos_wave_128 out of tolerance']) -end -if e_superbee_128>6.4e-04 - display(['Error: soborot_superbee_cos_wave_128 out of tolerance']) -end - -axis([min(dx) .1 min(dx.^2) max(dx)]) -xlabel('Grid Spacing (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('L2 Error','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -text(.009,.04,'Cosine Wave Error','FontName',Font_Name,'FontSize',Label_Font_Size) - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -lh=legend(H(1:4),'{\itO}(\delta{\itx})','{\itO}(\delta{\itx}^2)','CHARM','Superbee'); -set(lh,'Location','Southeast') -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) -legend boxoff - -Git_Filename = [data_dir,'soborot_superbee_cos_wave_128_git.txt']; -addverstr(gca,Git_Filename,'loglog') - -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[plot_dir,'soborot_cos_wave_error']); - diff --git a/Utilities/Matlab/scripts/terminal_velocity_convergence.m b/Utilities/Matlab/scripts/terminal_velocity_convergence.m deleted file mode 100644 index 525d3dafef2..00000000000 --- a/Utilities/Matlab/scripts/terminal_velocity_convergence.m +++ /dev/null @@ -1,162 +0,0 @@ -% Trettel - -close all -clear all - -plot_style - -repository = '../../Verification/Sprinklers_and_Sprays/'; - -skip_case = 0; - -if ~exist([repository, 'terminal_velocity_dt_1_0_1.prt5']) - display(['Error: File ' [repository, 'terminal_velocity_dt_1_0_1.prt5'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([repository, 'terminal_velocity_dt_0_1_1.prt5']) - display(['Error: File ' [repository, 'terminal_velocity_dt_0_1_1.prt5'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([repository, 'terminal_velocity_dt_0_01_1.prt5']) - display(['Error: File ' [repository, 'terminal_velocity_dt_0_01_1.prt5'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([repository, 'terminal_velocity_dt_0_001_1.prt5']) - display(['Error: File ' [repository, 'terminal_velocity_dt_0_001_01.prt5'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([repository, 'terminal_velocity_dt_0_0001_1.prt5']) - display(['Error: File ' [repository, 'terminal_velocity_dt_0_0001_1.prt5'] ' does not exist. Skipping case.']) - skip_case = 1; -end - -if skip_case - return -end - -% get precise ambient density -M0 = importdata([repository, 'terminal_velocity_dt_1_0_devc.csv'],',',2); -rhoa = M0.data(end,4); - -g = 9.8; -Cd = 1; -rhod = 1000; -D = 10e-3; - -tend = 20; -eps = 1e-10; -ttest = 0.1; - -K = 3 * rhoa * Cd / (4 * rhod * D); - -dtvec = [1.0 0.1 0.01 0.001 0.0001]; -errvec = []; -Linf = []; -STIME = 20.; -vtexact = sqrt(g / K); -zexact = @(t) -log(cosh(sqrt(g * K) * t)) / K; - -M1 = importdata([repository, 'terminal_velocity_dt_1_0_devc.csv'],',',2); -QP = M1.data(end,2); -ZP = M1.data(end,3); -errvec(1) = abs(abs(QP) - vtexact); -Linf(1) = abs(ZP - zexact(STIME)); - -M2 = importdata([repository, 'terminal_velocity_dt_0_1_devc.csv'],',',2); -QP = M2.data(end,2); -ZP = M2.data(end,3); -errvec(2) = abs(abs(QP) - vtexact); -Linf(2) = abs(ZP - zexact(STIME)); - -M3 = importdata([repository, 'terminal_velocity_dt_0_01_devc.csv'],',',2); -QP = M3.data(end,2); -ZP = M3.data(end,3); -errvec(3) = abs(abs(QP) - vtexact); -Linf(3) = abs(ZP - zexact(STIME)); - -M4 = importdata([repository, 'terminal_velocity_dt_0_001_devc.csv'],',',2); -QP = M4.data(end,2); -ZP = M4.data(end,3); -errvec(4) = abs(abs(QP) - vtexact); -Linf(4) = abs(ZP - zexact(STIME)); - -M5 = importdata([repository, 'terminal_velocity_dt_0_0001_devc.csv'],',',2); -QP = M5.data(end,2); -ZP = M5.data(end,3); -errvec(5) = abs(abs(QP) - vtexact); -Linf(5) = abs(ZP - zexact(STIME)); - -if errvec(5) > 1e-6 - display(['Matlab Warning: The velocity in the terminal_velocity* cases is out of tolerance.']) -end - -if Linf(5) > 1e-3 - display(['Matlab Warning: The position in the terminal_velocity* cases is out of tolerance.']) -end - -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -H(1) = loglog(dtvec, errvec, '-*k'); -hold on -H(2) = loglog(dtvec, dtvec, '--k'); -H(3) = loglog(dtvec, dtvec.^2, '-k'); -hold off -dto = dtvec((length(dtvec) - 1):length(dtvec)); -erro = errvec((length(errvec) - 1):length(errvec)); -[a, b] = polyfit(log(dto), log(erro), 1); - -set(gca, 'FontName', Font_Name) -set(gca, 'FontSize', Label_Font_Size) - -xlabel('Time Step (s)', 'Interpreter', Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Terminal Velocity Error (m/s)','FontSize',Label_Font_Size) -h = legend(H, {'FDS', '$\mathcal{O}(\delta t)$', ... - '$\mathcal{O}(\delta t^2)$'}, 'Location', 'East','Interpreter', 'LaTeX','FontSize', Key_Font_Size); - -set(gcf, 'Visible', Figure_Visibility); -set(gcf, 'Units', Paper_Units); -set(gcf, 'PaperUnits',Paper_Units); -set(gcf, 'PaperSize', [Paper_Width Paper_Height]); -set(gcf, 'Position', [0 0 Paper_Width Paper_Height]); - -Git_Filename = [repository, 'terminal_velocity_dt_1_0_git.txt']; -addverstr(gca,Git_Filename,'loglog') - -print(gcf, '-dpdf', '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/terminal_velocity_convergence'); - -close all -clear H -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -H(1) = loglog(dtvec, Linf, '-*k'); -hold on -H(2) = loglog(dtvec, dtvec, '--k'); -H(3) = loglog(dtvec, dtvec.^2, '-k'); -hold off -dto = dtvec((length(dtvec) - 1):length(dtvec)); -erro = Linf((length(Linf) - 1):length(Linf)); -[a, b] = polyfit(log(dto), log(erro), 1); - -set(gca, 'FontName', Font_Name) -set(gca, 'FontSize', Label_Font_Size) - -xlabel('Time Step (s)', 'Interpreter', Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Position Error (m)','FontSize',Label_Font_Size) -h = legend(H, {'FDS', '$\mathcal{O}(\delta t)$',... - '$\mathcal{O}(\delta t^2)$'}, 'Location', 'Southeast','Interpreter','LaTeX','FontSize', Key_Font_Size); - -set(gcf, 'Visible', Figure_Visibility); -set(gcf, 'Units', Paper_Units); -set(gcf, 'PaperUnits',Paper_Units); -set(gcf, 'PaperSize', [Paper_Width Paper_Height]); -set(gcf, 'Position', [0 0 Paper_Width Paper_Height]); - -Git_Filename = [repository, 'terminal_velocity_dt_1_0_git.txt']; -addverstr(gca,Git_Filename,'loglog') - -print(gcf, '-dpdf', '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/position_convergence'); - diff --git a/Utilities/Matlab/scripts/tree_shapes.m b/Utilities/Matlab/scripts/tree_shapes.m deleted file mode 100644 index 3bd374cc882..00000000000 --- a/Utilities/Matlab/scripts/tree_shapes.m +++ /dev/null @@ -1,78 +0,0 @@ -% Mueller -% 06-15-2023 -% tree_shape.m - -% This script compares the actual mass generated with various tree crown -% geometries to the expected value (assuming a bulk density of 5 kg/m3) - -close all -clear all - -out_dir = '../../Verification/WUI/'; -plot_dir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/'; - -% import mass totals -CHID = [out_dir,'tree_shapes']; -if ~exist([out_dir,CHID,'_devc.csv'],'file') - disp(['Error: File ',CHID,'_devc.csv does not exist. Skipping case.']); - return; -end -DEVC = importdata([out_dir,[CHID,'_devc.csv']],',', 2); - -random_part_mass=DEVC.data(end,2:6); -one_part_mass=DEVC.data(end,7:end); - - -% compute ideal input volumes -box_vol = 0.6*0.6*0.4; -cone_vol = 0.6*0.3^2*pi/3; -cyl_vol = 0.6*0.2^2*pi; -cone_shell_vol = 0.6*(0.3^2-0.2^2)*pi/3; -cyl_shell_vol = 0.6*(0.2^2-0.15^2)*pi; - -input_vol=[box_vol,cone_vol,cyl_vol,cone_shell_vol,cyl_shell_vol]; - -% relative error in input volume -% large tolerance because error in mass does not necessarily imply an issue -% as long as MASS_PER_VOLUME is preserved -rel_err=abs([random_part_mass one_part_mass]-5*[input_vol input_vol])./... - (5*[input_vol input_vol]); -if max(rel_err) > 0.1 - display(['Matlab Warning: The mass in tree_shapes is out of tolerance.']) -end - -% figure setup -figure -plot_style -colors=['k','r','b','g']; -clf -hold on -box on - -% plot -plot([0,.2],[0,1],'k--','displayname','ideal'); -plot(input_vol,random_part_mass,'ro','displayname','1000 random particles'); -plot(input_vol,one_part_mass,'bo','displayname','1 particle per cell'); - -% standardize figure -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Scat_Label_Font_Size) -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); - -% label axes -axis([0 .15 0 .8]) -xlabel('Input volume (m^3)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Tree crown mass (kg)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -% add legend -lh=legend(); -set(lh,'FontSize',Key_Font_Size,'location','southeast') -% add Git revision -Git_Filename = [out_dir,CHID,'_git.txt']; -addverstr(gca,Git_Filename,'linear') -% save figure -print(gcf,Image_File_Type,[plot_dir,'tree_shapes']) - diff --git a/Utilities/Matlab/scripts/tunnel_fire.m b/Utilities/Matlab/scripts/tunnel_fire.m deleted file mode 100644 index ec36b1c7c3b..00000000000 --- a/Utilities/Matlab/scripts/tunnel_fire.m +++ /dev/null @@ -1,57 +0,0 @@ -% McGrattan -% 3-12-2021 -% tunnel_fire.m -% Test of pressure drop for a tunnel fire -% - -close all -clear all - -datadir = '../../../out/Moody_Chart/'; -pltdir = '../../Manuals/FDS_User_Guide/SCRIPT_FIGURES/'; - -plot_style - -chid='tunnel_fire'; -res={'10','20','40'}; -lines={'k:','k--','k-'}; - -for j=1:length(res) - M = importdata([datadir,chid,'_',res{j},'_line.csv'],',',2); - x = M.data(:,find(strcmp(M.colheaders,'p-x'))); - p = M.data(:,find(strcmp(M.colheaders,'p')))'; - hh(j)=plot(x,p,lines{j}); hold on; -end - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Label_Font_Size) - -lh=legend(hh,'1 m','0.5 m','0.25 m'); -set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) - -Min_Ind = 0.; -Max_Ind = 1600.; -Min_Dep = 0.; -Max_Dep = 40.; -Title_Position = [0.05 0.90]; -X_Title_Position = Min_Ind+Title_Position(1)*(Max_Ind-Min_Ind); -Y_Title_Position = Min_Dep+Title_Position(2)*(Max_Dep-Min_Dep); -text(X_Title_Position,Y_Title_Position,'1600 m Tunnel, 50 MW Fire','FontSize',Title_Font_Size,'FontName',Font_Name,'Interpreter',Font_Interpreter); - -axis([Min_Ind Max_Ind Min_Dep Max_Dep]) -xlabel('Distance (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -ylabel('Gauge Pressure (Pa)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) -set(gca,'XTick',[0 400 800 1200 1600]) - -% add version string if file is available - -Git_Filename = [datadir,chid,'_10_git.txt']; -addverstr(gca,Git_Filename,'linear') - -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf',[pltdir,chid]) - diff --git a/Utilities/Matlab/scripts/tunnel_pressure_drop.m b/Utilities/Matlab/scripts/tunnel_pressure_drop.m deleted file mode 100644 index 837121a6e07..00000000000 --- a/Utilities/Matlab/scripts/tunnel_pressure_drop.m +++ /dev/null @@ -1,175 +0,0 @@ -% McDermott -% 8-2-2018 -% tunnel_pressure_drop.m -% Test of tunnel friction factor -% -% Case matrix -% ----------- -% -% Case A: Vel = 2 m/s, Roughness = 1.E-4 m -% Case B: Vel = 2 m/s, Roughness = 1.E-1 m -% Case C: Vel = 10 m/s, Roughness = 1.E-4 m -% Case D: Vel = 10 m/s, Roughness = 1.E-1 m -% Case E: Vel = 4 m/s, Roughness = 1.E-2 m - -close all -clear all - -datadir = '../../../out/Moody_Chart/'; -pltdir = '../../Manuals/FDS_User_Guide/SCRIPT_FIGURES/'; - -plot_style - -chid='tunnel_pressure_drop'; -cases={'a','b','c','d','e'}; -CASES={'A','B','C','D','E'}; -res={'10','20'}; -markers={'ko','k+'}; -lines={'k--','k:'}; - -VEL = [2 2 10 10 4]; -s = [1.0E-4 1.0E-1 1.0E-4 1.0E-1 1.0E-2]; % sand grain roughness (m) from input file -H = [10 10 10 10 7.2]; % tunnel height (m) from input file -L = [1600 1600 1600 1600 1600]; % tunnel length (m) - -f_save = zeros(1,length(cases)); -f_fds_save = zeros(length(res),length(cases)); - -for i=1:length(cases) - - figure - set(gca,'Units',Plot_Units) - set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - nh= 1; % legend handle index - - x = [10:10:90,100:100:L(i)]'; - - for j=1:length(res) - - % check steady state - - M = importdata([datadir,chid,'_',cases{i},'_',res{j},'_devc.csv'],',',2); - t = M.data(:,find(strcmp(M.colheaders,'Time'))); - U = M.data(:,find(strcmp(M.colheaders,'UBAR'))); - % plot(t,U) - % xlabel('time (s)') - % ylabel('u velocity (m/s)') - - % compute friction factor (f) from Colebrook equation - mu = M.data(end,find(strcmp(M.colheaders,'MU'))); % dynamic viscosity of AIR - rho = M.data(end,find(strcmp(M.colheaders,'RHO'))); % density of AIR - - Re = rho*H(i)*VEL(i)/mu; - [f,error,iter] = colebrook(Re,s(i)/H(i),.001,1e-9); - dpdx_exact = -f/H(i) * 0.5 * rho*VEL(i)^2; - f_save(i) = f; - - % pressure drop - - P = M.data(end,find(strcmp(M.colheaders,'P10')):end)'; - - hh(nh)=plot(x,P,markers{j}); hold on; - nh=nh+1; - - set(gca,'FontName',Font_Name) - set(gca,'FontSize',Label_Font_Size) - - % least squares to get slope (pressure drop) - - rsub = find(x>=10); - xsub = x(rsub); - A = [ones(length(xsub),1), xsub]; - y = inv(A'*A)*(A'*P(rsub)); - hh(nh)=plot(x,[y(1)+x*y(2)],lines{j}); nh=nh+1; - - % compute friction factor from DEVC pressure drop - - dpdx = y(2); % pressure drop (Pa/m) - f_fds = 2*(-dpdx)*H(i)/(rho*U(end)^2); % f from FDS - f_fds_save(j,i) = f_fds; - - end - - hh(nh)=plot(x,[(x-L(i))*dpdx_exact],'k-'); - - lh=legend(hh,'DEVC Pressure 10','Least squares fit 10','DEVC Pressure 20','Least squares fit 20','Exact pressure drop'); - set(lh,'FontName',Font_Name,'FontSize',Key_Font_Size) - - % add plot title - - Min_Ind = 0; - Max_Ind = L(i); - YLimits = get(gca,'YLim'); - Min_Dep = YLimits(1); - Max_Dep = 1.2*YLimits(2); - Title_Position = [0.05 0.90]; - X_Title_Position = Min_Ind+Title_Position(1)*(Max_Ind-Min_Ind); - Y_Title_Position = Min_Dep+Title_Position(2)*(Max_Dep-Min_Dep); - Plot_Title = ['Case ',CASES{i}]; - text(X_Title_Position,Y_Title_Position,Plot_Title,'FontSize',Title_Font_Size,'FontName',Font_Name,'Interpreter',Font_Interpreter); - Plot_Title = ['{\itU} = ',num2str(VEL(i)),' m/s, {\its} = ',num2str(s(i)),' m']; - text(X_Title_Position,0.9*Y_Title_Position,Plot_Title,'FontSize',Title_Font_Size,'FontName',Font_Name,'Interpreter',Font_Interpreter); - - % axis labels - - axis([Min_Ind Max_Ind Min_Dep Max_Dep]) - xlabel('Distance (m)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) - ylabel('Gauge Pressure (Pa)','Interpreter',Font_Interpreter,'FontSize',Label_Font_Size) - set(gca,'XTick',[0 400 800 1200 1600]) - - % add version string if file is available - - Git_Filename = [datadir,chid,'_',cases{i},'_10_git.txt']; - addverstr(gca,Git_Filename,'linear') - - set(gcf,'Visible',Figure_Visibility); - set(gcf,'Units',Paper_Units); - set(gcf,'PaperUnits',Paper_Units); - set(gcf,'PaperSize',[Paper_Width Paper_Height]); - set(gcf,'Position',[0 0 Paper_Width Paper_Height]); - print(gcf,'-dpdf',[pltdir,chid,'_',cases{i}]) - -end - -% compute errors - -for i=1:length(cases) - err10 = abs((f_save(i)-f_fds_save(1,i))/f_save(i)); - err20 = abs((f_save(i)-f_fds_save(2,i))/f_save(i)); - max_error(i) = max(err10,err20)*100; -end - -% write friction factors to latex - -fid = fopen([pltdir,'tunnel_pressure_drop.tex'],'wt'); -fprintf(fid, '%s\n', '\scriptsize'); -fprintf(fid, '%s\n', '\caption[Friction factors in tunnels]{Friction factors for {\ct tunnel\_pressure\_drop} cases.}'); -fprintf(fid, '%s\n', '\label{tab:tunnel_pressure_drop}'); -fprintf(fid, '%s\n', '\centering'); -fprintf(fid, '%s\n', '\begin{tabular}{lccccccc}'); -fprintf(fid, '%s\n', '\hline'); -fprintf(fid, '%s\n', 'Case & Velocity (m/s) & Roughness (m) & Hydraulic Dia. (m) & $f$ Colebrook & $f$ FDS 10 & $f$ FDS 20 & Max Rel. Error (\%)\\'); -fprintf(fid, '%s\n', '\hline'); -fprintf(fid, '%s\n', ['A & ',num2str(VEL(1)),' & ',num2str(s(1)),' & ',num2str(H(1)),' & ',num2str(f_save(1),3),' & ',num2str(f_fds_save(1,1),3),' & ',num2str(f_fds_save(2,1),3),' & ',num2str(max_error(1),2),' \\']); -fprintf(fid, '%s\n', ['B & ',num2str(VEL(2)),' & ',num2str(s(2)),' & ',num2str(H(2)),' & ',num2str(f_save(2),3),' & ',num2str(f_fds_save(1,2),3),' & ',num2str(f_fds_save(2,2),3),' & ',num2str(max_error(2),2),' \\']); -fprintf(fid, '%s\n', ['C & ',num2str(VEL(3)),' & ',num2str(s(3)),' & ',num2str(H(3)),' & ',num2str(f_save(3),3),' & ',num2str(f_fds_save(1,3),3),' & ',num2str(f_fds_save(2,3),3),' & ',num2str(max_error(3),2),' \\']); -fprintf(fid, '%s\n', ['D & ',num2str(VEL(4)),' & ',num2str(s(4)),' & ',num2str(H(4)),' & ',num2str(f_save(4),3),' & ',num2str(f_fds_save(1,4),3),' & ',num2str(f_fds_save(2,4),3),' & ',num2str(max_error(4),2),' \\']); -fprintf(fid, '%s\n', ['E & ',num2str(VEL(5)),' & ',num2str(s(5)),' & ',num2str(H(5)),' & ',num2str(f_save(5),3),' & ',num2str(f_fds_save(1,5),3),' & ',num2str(f_fds_save(2,5),3),' & ',num2str(max_error(5),2),' \\']); -fprintf(fid, '%s\n', '\hline'); -fprintf(fid, '%s\n', '\end{tabular}'); -fprintf(fid, '%s\n', '\normalsize'); -fclose(fid); - - - - - - - - - - - - - - diff --git a/Utilities/Matlab/scripts/wall_internal_radiation.m b/Utilities/Matlab/scripts/wall_internal_radiation.m deleted file mode 100644 index f8b49c24179..00000000000 --- a/Utilities/Matlab/scripts/wall_internal_radiation.m +++ /dev/null @@ -1,31 +0,0 @@ -%Roger Wang -%6-29-11 -%wall_internal_radiation.m - -close all -clear all - -infile = '../../Verification/Radiation/wall_internal_radiation_devc.csv'; -if ~exist(infile) - display(['Error: File ',infile,' does not exist. Skipping case.']) - return -end -M = csvread(infile,3,0); - t = M(1,1); - flux(1:5) = M(1,2:6)'; - -filename = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/wall_internal_radiation.tex'; -fid = fopen(filename,'wt'); - -fprintf(fid,'%s\n','\begin{center}'); -fprintf(fid,'%s\n', '\begin{tabular}{|c|c|c|} \hline'); -fprintf(fid,'%s\n', '$\tau$ & $S(\tau)$ & FDS \\'); -fprintf(fid,'%s\n', ' & (kW/m$^2$) & (kW/m$^2$) \\ \hline\hline'); -fprintf(fid,'%s %6.3f %s\n', '0.01 & 2.897 &',-flux(1),' \\'); -fprintf(fid,'%s %5.2f %s\n', '0.1 & 24.94 &',-flux(2),' \\'); -fprintf(fid,'%s %5.2f %s\n', '0.5 & 82.95 &',-flux(3),' \\'); -fprintf(fid,'%s %5.1f %s\n', '1.0 & 116.3 &',-flux(4),' \\'); -fprintf(fid,'%s %5.1f %s\n', '10. & 149.0 &',-flux(5),' \\ \hline'); -fprintf(fid,'%s\n','\end{tabular}'); -fprintf(fid,'%s\n','\end{center}'); - diff --git a/Utilities/Matlab/scripts/wall_model.m b/Utilities/Matlab/scripts/wall_model.m deleted file mode 100644 index 8afb968b482..00000000000 --- a/Utilities/Matlab/scripts/wall_model.m +++ /dev/null @@ -1,19 +0,0 @@ -% McDermott -% 5-20-2009 -% wall_model.m -% -% This script generates all plots necessary for the wall model section -% of the verification guide. - -law_of_the_wall % The law of the wall -poiseuille_convergence % Convergence for 2D Poiseuille flow -poiseuille_convergence_cc % Convergence for 2D Poiseuille flow -fds_moody_chart % The FDS Moody chart -yplus % Near-wall grid resolution -heated_channel % Heated Channel Flow -blasius % Blasius boundary layer -blasius_thermal % Pohlhausen boundary layer -ribbed_channel % Ribbed channel flow -tunnel_pressure_drop % Test of measuring pressure drop with DEVC -tunnel_fire % Test of a big fire in a long tunnel - diff --git a/Utilities/Matlab/scripts/yplus.m b/Utilities/Matlab/scripts/yplus.m deleted file mode 100644 index e7d82a829e3..00000000000 --- a/Utilities/Matlab/scripts/yplus.m +++ /dev/null @@ -1,73 +0,0 @@ -% Abbas -% 7-3-12 -% yplus.m - -close all -clear all - -dir = '../../Verification/Turbulence/'; - -skip_case = 0; -if ~exist([dir,'yplus_8_devc.csv']) - display(['Error: File ' [dir,'yplus_8_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([dir,'yplus_16_devc.csv']) - display(['Error: File ' [dir,'yplus_16_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if ~exist([dir,'yplus_32_devc.csv']) - display(['Error: File ' [dir,'yplus_32_devc.csv'] ' does not exist. Skipping case.']) - skip_case = 1; -end -if skip_case - return -end - -M_8 = importdata([dir,'yplus_8_devc.csv'],',',2); -M_16 = importdata([dir,'yplus_16_devc.csv'],',',2); -M_32 = importdata([dir,'yplus_32_devc.csv'],',',2); - -yp = [M_8.data(end,2),M_16.data(end,2),M_32.data(end,2)]; - -n = [8 16 32]; -y = 0.5*(1./n); -mu = 1; -rho = 1.199; -tau_w = 0.5; -u_tau = sqrt(tau_w/rho); -d_nu = (mu/rho)/u_tau; -yp_exact = y/d_nu; - -plot_style -figure -set(gca,'Units',Plot_Units) -set(gca,'Position',[Plot_X Plot_Y Plot_Width Plot_Height]) - -plot(yp_exact,yp_exact,'ro'); hold on -plot(yp_exact,yp,'b--') - -set(gca,'FontName',Font_Name) -set(gca,'FontSize',Title_Font_Size) - -xlabel('{\it y}^+ specified','Interpreter',Font_Interpreter,'Fontname',Font_Name), -ylabel('{\it y}^+ predicted','Interpreter',Font_Interpreter,'Fontname',Font_Name), -leg = legend('exact','FDS'); -set(leg,'Location','SouthEast') -set(leg,'Interpreter',Font_Interpreter) -set(leg,'FontName',Font_Name) -set(leg,'FontSize',Key_Font_Size) - -% add git version if file is available - -git_file = [dir,'yplus_8_git.txt']; -addverstr(gca,git_file,'linear') - -% print pdf -set(gcf,'Visible',Figure_Visibility); -set(gcf,'Units',Paper_Units); -set(gcf,'PaperUnits',Paper_Units); -set(gcf,'PaperSize',[Paper_Width Paper_Height]); -set(gcf,'Position',[0 0 Paper_Width Paper_Height]); -print(gcf,'-dpdf','../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/yplus') - diff --git a/Utilities/Python/FDS_verification_dataplot_config.csv b/Utilities/Python/FDS_verification_dataplot_config.csv deleted file mode 100644 index 57af1aaa18c..00000000000 --- a/Utilities/Python/FDS_verification_dataplot_config.csv +++ /dev/null @@ -1,15 +0,0 @@ -Dataname,VerStr_Filename,Exp_Filename,Exp_Header_Row,Exp_Data_Row,Exp_x_Col_Name,Exp_y_Col_Name,Exp_y_Error_Col_Name,Exp_Data_Markevery,Exp_Error_Absolute,Exp_Error_Relative,Exp_Data_Label,Exp_Marker_Style,Exp_Marker_Edge_Color,Exp_Marker_Fill_Color,Exp_Marker_Size,Exp_Line_Style,Exp_Line_Color,Exp_Line_Width,Cmp_Filename,Cmp_Header_Row,Cmp_Data_Row,Cmp_x_Col_Name,Cmp_y_Col_Name,Cmp_Data_Markevery,Cmp_Data_Label,Cmp_Marker_Style,Cmp_Marker_Edge_Color,Cmp_Marker_Fill_Color,Cmp_Marker_Size,Cmp_Line_Style,Cmp_Line_Color,Cmp_Line_Width,Plot_Title,Plot_Subtitle,Plot_x_Label,Plot_y_Label,Plot_Use_TeX,Plot_x_Min,Plot_x_Max,Plot_x_Tick,Plot_x_Nticks,Plot_y_Min,Plot_y_Max,Plot_y_Tick,Plot_y_Nticks,Plot_x_Axis_Exponent_Min,Plot_x_Axis_Exponent_Max,Plot_y_Axis_Exponent_Min,Plot_y_Axis_Exponent_Max,Plot_Left_Adjust,Plot_Bottom_Adjust,Plot_Right_Adjust,Plot_Top_Adjust,Plot_Figure_Width,Plot_Figure_Height,Plot_Flip_Axis,Plot_Show_Legend,Plot_Legend_Location,Plot_Filename -1_step_2_step_M,Species/1_step_2_step_compare_git.txt,Species/1_step_2_step_compare_devc.csv,2,3,Time,"Q1S",,,,,1-Step Q,o,black,,,,,,Species/1_step_2_step_compare_devc.csv,2,3,Time,"Q2S",,2-Step Q,,,,,-,red,,Q Check (1_step_2_step_compare) MLRPUA,,Time (s),Integrated Heat Release (kJ),,0.0,10.0,,,0,200,,,,,,,,,,,,,,,center left,FDS_Verification_Guide/SCRIPT_FIGURES/1_step_2_step_compare_MLRPUA.pdf -1_step_2_step_M,Species/1_step_2_step_compare_git.txt,Species/1_step_2_step_compare_devc.csv,2,3,Time,"Q1S",,,,,1-Step Q,o,black,,,,,,Species/1_step_2_step_compare_devc.csv,2,3,Time,"Q2S",,2-Step Q,,,,,-,red,,Q Check (1_step_2_step_compare) MLRPUA,,$\mathcal{O}(x^2)$,$\int \dot{q}''' \mathrm{d}V$ (kJ),True,0.0,10.0,,,0,200,,,,,,,,,,,,,,,center left,FDS_Verification_Guide/SCRIPT_FIGURES/LaTeX_test.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time1,TMP1,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time1,TMP1,,FDS,,,,,--,,,Ignition Delay,900 K; $\phi=0.6$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_900_0p6.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time2,TMP2,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time2,TMP2,,FDS,,,,,--,,,Ignition Delay,1000 K; $\phi=0.6$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1000_0p6.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time3,TMP3,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time3,TMP3,,FDS,,,,,--,,,Ignition Delay,1100 K; $\phi=0.6$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1100_0p6.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time4,TMP4,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time4,TMP4,,FDS,,,,,--,,,Ignition Delay,1200 K; $\phi=0.6$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1200_0p6.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time5,TMP5,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time5,TMP5,,FDS,,,,,--,,,Ignition Delay,900 K; $\phi=1.0$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_900_1p0.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time6,TMP6,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time6,TMP6,,FDS,,,,,--,,,Ignition Delay,1000 K; $\phi=1.0$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1000_1p0.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time7,TMP7,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time7,TMP7,,FDS,,,,,--,,,Ignition Delay,1100 K; $\phi=1.0$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1100_1p0.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time8,TMP8,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time8,TMP8,,FDS,,,,,--,,,Ignition Delay,1200 K; $\phi=1.0$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1200_1p0.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time9,TMP9,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time9,TMP9,,FDS,,,,,--,,,Ignition Delay,900 K; $\phi=1.4$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_900_1p4.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time10,TMP10,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time10,TMP10,,FDS,,,,,--,,,Ignition Delay,1000 K; $\phi=1.4$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1000_1p4.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time11,TMP11,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time11,TMP11,,FDS,,,,,--,,,Ignition Delay,1100 K; $\phi=1.4$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1100_1p4.pdf -cantera_ignition_delay,,Chemistry/cantera_ignition_delay.csv,1,2,Time12,TMP12,,,,,Cantera,o,,,,,,,Chemistry/cantera_ignition_delay.csv,1,2,Time12,TMP12,,FDS,,,,,--,,,Ignition Delay,1200 K; $\phi=1.4$,Time (s),Temperature (K),,0.0,10.0,,,750,3000,,,,,-4,4,0.15,,,,,,,,lower right,FDS_Verification_Guide/SCRIPT_FIGURES/ignition_delay_1200_1p4.pdf \ No newline at end of file diff --git a/Utilities/Python/FDS_verification_script.py b/Utilities/Python/FDS_verification_script.py index c0f1e6c9e6e..a5e3865458c 100644 --- a/Utilities/Python/FDS_verification_script.py +++ b/Utilities/Python/FDS_verification_script.py @@ -30,8 +30,22 @@ # Special cases -print("jet_decay..."); subprocess.run(["python","./scripts/jet_decay.py"]) -print("pyrolysis..."); subprocess.run(["python","./scripts/pyrolysis.py"]) -print("turb_model..."); subprocess.run(["python","./scripts/turb_model.py"]) +print("blasius..."); subprocess.run(["python","./scripts/blasius.py"]) +print("fds_moody_chart..."); subprocess.run(["python","./scripts/fds_moody_chart.py"]) +print("heated_channel..."); subprocess.run(["python","./scripts/heated_channel.py"]) +print("jet_decay..."); subprocess.run(["python","./scripts/jet_decay.py"]) +print("law_of_the_wall..."); subprocess.run(["python","./scripts/law_of_the_wall.py"]) +print("plate_view_factor..."); subprocess.run(["python","./scripts/plate_view_factor.py"]) +print("pulsating..."); subprocess.run(["python","./scripts/pulsating.py"]) +print("pyrolysis..."); subprocess.run(["python","./scripts/pyrolysis.py"]) +print("ribbed_channel..."); subprocess.run(["python","./scripts/ribbed_channel.py"]) +print("saad_mms..."); subprocess.run(["python","./scripts/saad_mms_temporal_error.py"]) +print("shunn_mms..."); subprocess.run(["python","./scripts/shunn_mms.py"]) +print("soborot_mass_transport..."); subprocess.run(["python","./scripts/soborot_mass_transport.py"]) +print("terminal_velocity_convergence..."); subprocess.run(["python","./scripts/terminal_velocity_convergence.py"]) +print("tree_shapes..."); subprocess.run(["python","./scripts/tree_shapes.py"]) +print("turb_model..."); subprocess.run(["python","./scripts/turb_model.py"]) +print("wall_internal_radiation..."); subprocess.run(["python","./scripts/wall_internal_radiation.py"]) +print("yplus..."); subprocess.run(["python","./scripts/yplus.py"]) print("verification scripts completed successfully!") diff --git a/Utilities/Python/fdsplotlib.py b/Utilities/Python/fdsplotlib.py index 9876d5a8a59..5d11671f6da 100644 --- a/Utilities/Python/fdsplotlib.py +++ b/Utilities/Python/fdsplotlib.py @@ -461,12 +461,29 @@ def plot_to_fig(x_data,y_data,**kwargs): # print ("%s == %s" %(key, value)) plot_style = get_plot_style("fds") - plt.rcParams["font.family"] = plot_style["Font_Name"] - plt.rcParams["font.size"] = plot_style["Label_Font_Size"] - # print(plot_style) - plt.rcParams['text.usetex'] = True # supports latex math (set per plot below) - plt.rcParams["pdf.use14corefonts"] = True # forces matplotlib to write native pdf fonts rather than embed + import matplotlib.pyplot as plt + + plt.rcParams.update({ + "pdf.use14corefonts": True, + "text.usetex": False, + + # Text and math in Times New Roman + "font.family": "serif", + "font.serif": ["Times", "Times New Roman"], + + "mathtext.fontset": "custom", + "mathtext.rm": "Times", + "mathtext.it": "Times New Roman:italic", + "mathtext.bf": "Times:bold", + "mathtext.cal": "Times New Roman:italic", + "mathtext.tt": "Courier New", + "mathtext.default": "it", + + "axes.unicode_minus": False, + "pdf.compression": 9, + }) + import logging # Suppress just the 'findfont' warnings from matplotlib's font manager logging.getLogger('matplotlib.font_manager').setLevel(logging.ERROR) @@ -518,6 +535,31 @@ def plot_to_fig(x_data,y_data,**kwargs): bottom = plot_origin[1] / figure_size[1] ax = fig.add_axes([left, bottom, ax_w, ax_h]) + # widen paper if legend is outside, keeping axes fixed in physical size + if kwargs.get('legend_location') == 'outside': + legend_expand = kwargs.get('legend_expand', 1.25) + old_size = fig.get_size_inches() + + # Compute current axes rectangle in *inches* + bbox = ax.get_position() + ax_left_in = bbox.x0 * old_size[0] + ax_bottom_in = bbox.y0 * old_size[1] + ax_w_in = bbox.width * old_size[0] + ax_h_in = bbox.height * old_size[1] + + # Widen the figure canvas + new_width = old_size[0] * legend_expand + fig.set_size_inches(new_width, old_size[1]) + + # Recompute normalized coordinates to keep the axes fixed in size and location + left_new = ax_left_in / new_width + bottom_new = ax_bottom_in / old_size[1] + ax_w_new = ax_w_in / new_width + ax_h_new = ax_h_in / old_size[1] + + ax.set_position([left_new, bottom_new, ax_w_new, ax_h_new]) + + # select plot type plot_type=kwargs.get('plot_type','linear') @@ -652,12 +694,52 @@ def plot_to_fig(x_data,y_data,**kwargs): legend_fontsize=kwargs.get('legend_fontsize',default_legend_fontsize) - if data_label: - if kwargs.get('legend_location')=='outside': - plt.legend(fontsize=legend_fontsize,bbox_to_anchor=(1,1),loc='upper left',framealpha=legend_framealpha) + # --- always get current handles and labels --- + handles, labels = ax.get_legend_handles_labels() + + # --- case 1 or 2: creating a new figure --- + if not using_existing_figure: + # record legend display properties on the Axes + if legend_location == 'outside': + ax._legend_loc = 'center left' + ax._legend_bbox = (1.02, 0.5) + ax.figure.subplots_adjust(right=0.8) + else: + ax._legend_loc = legend_location + ax._legend_bbox = None + + ax._legend_fontsize = legend_fontsize + ax._legend_framealpha = legend_framealpha + + # if we already have labeled data, draw legend now + if labels: + ax.legend(handles, labels, + loc=ax._legend_loc, + bbox_to_anchor=ax._legend_bbox, + fontsize=ax._legend_fontsize, + framealpha=ax._legend_framealpha) else: - # if kwargs.get('show_legend'): - plt.legend(fontsize=legend_fontsize,loc=legend_location,framealpha=legend_framealpha) + # optionally show empty placeholder (for consistent layout) + ax.legend([], [], + loc=ax._legend_loc, + bbox_to_anchor=ax._legend_bbox, + fontsize=ax._legend_fontsize, + frameon=False) + + # --- case 3: existing figure, adding more data --- + else: + loc = getattr(ax, '_legend_loc', 'best') + bbox = getattr(ax, '_legend_bbox', None) + fontsize = getattr(ax, '_legend_fontsize', legend_fontsize) + framealpha = getattr(ax, '_legend_framealpha', legend_framealpha) + + if labels: + ax.legend(handles, labels, + loc=loc, + bbox_to_anchor=bbox, + fontsize=fontsize, + framealpha=framealpha) + # plot title if kwargs.get('plot_title'): diff --git a/Utilities/Python/scripts/Heskestad_Flame_Height_2.py b/Utilities/Python/scripts/Heskestad_Flame_Height_2.py index edebe76717a..0caac7eb2ea 100644 --- a/Utilities/Python/scripts/Heskestad_Flame_Height_2.py +++ b/Utilities/Python/scripts/Heskestad_Flame_Height_2.py @@ -86,7 +86,7 @@ plot_title = 'Flame Height Variation', plot_type='loglog', x_label='$Q^*$', - y_label='$L_{\\hbox{f}}/D$') + y_label=r'$L_{\rm f}/D$') # Load experimental data M = pd.read_csv(os.path.join(expdir, 'flame_lengths.csv'), skiprows=0) diff --git a/Utilities/Python/scripts/McCaffrey_Plume.py b/Utilities/Python/scripts/McCaffrey_Plume.py index 33ff67c1b83..7c6e2eba3dd 100644 --- a/Utilities/Python/scripts/McCaffrey_Plume.py +++ b/Utilities/Python/scripts/McCaffrey_Plume.py @@ -40,10 +40,10 @@ # Plot velocity correlation and measurement points -fig1 = fdsplotlib.plot_to_fig(x_data=zq, y_data=vq, data_label='$(z/Q^{2/5})^\\eta$', +fig1 = fdsplotlib.plot_to_fig(x_data=zq, y_data=vq, data_label=r'$(z/Q^{2/5})^\eta$', marker_style='b--', x_min=0.01, x_max=1, y_min=0.5, y_max=3, - x_label='$z/Q^{2/5}$ $(\\hbox{m kW}^{-2/5})$', + x_label=r'$z/Q^{2/5}$ $({\rm m kW}^{-2/5})$', y_label='${V/Q}^{1/5}$ (m s$^{-1}$ kW$^{-1/5}$)', legend_location='lower right', plot_type='loglog') @@ -57,20 +57,20 @@ marker_style=mark[i], data_label=f'{Q[i]:.1f} kW') ax = plt.gca() -ax.text(0.012,1.2, '$\\eta=1/2$' , fontsize=plot_style['Label_Font_Size']) -ax.text(0.100,2.3, '$\\eta=0$' , fontsize=plot_style['Label_Font_Size']) -ax.text(0.400,1.8, '$\\eta=-1/3$', fontsize=plot_style['Label_Font_Size']) +ax.text(0.012,1.2, r'$\eta=1/2$' , fontsize=plot_style['Label_Font_Size']) +ax.text(0.100,2.3, r'$\eta=0$' , fontsize=plot_style['Label_Font_Size']) +ax.text(0.400,1.8, r'$\eta=-1/3$', fontsize=plot_style['Label_Font_Size']) fig1.savefig(os.path.join(pltdir, 'McCaffrey_Velocity_Correlation.pdf'), format='pdf') plt.close(fig1) # Plot temperature correlation and measurement points -fig2 = fdsplotlib.plot_to_fig(x_data=zq, y_data=Tq, data_label='$(z/Q^{2/5})^\\eta$', +fig2 = fdsplotlib.plot_to_fig(x_data=zq, y_data=Tq, data_label=r'$(z/Q^{2/5})^\eta$', marker_style='r--', x_min=0.008, x_max=1, y_min=100, y_max=1200, - x_label='$z/Q^{2/5}$ $(\\hbox{m kW}^{-2/5})$', - y_label='$\\Delta T \\; (^\\circ$C)', + x_label=r'$z/Q^{2/5}$ $({\rm m kW}^{-2/5})$', + y_label=r'$\Delta T \; (^\circ$C)', legend_location='lower left', plot_type='loglog') @@ -83,9 +83,9 @@ marker_style=mark[i], data_label=f'{Q[i]:.1f} kW') ax = plt.gca() -ax.text(0.012,500, '$\\eta=0$' , fontsize=plot_style['Label_Font_Size']) -ax.text(0.060,400, '$\\eta=-1$' , fontsize=plot_style['Label_Font_Size']) -ax.text(0.100,150, '$\\eta=-5/3$', fontsize=plot_style['Label_Font_Size']) +ax.text(0.012,500, r'$\eta=0$' , fontsize=plot_style['Label_Font_Size']) +ax.text(0.060,400, r'$\eta=-1$' , fontsize=plot_style['Label_Font_Size']) +ax.text(0.100,150, r'$\eta=-5/3$', fontsize=plot_style['Label_Font_Size']) fig2.savefig(os.path.join(pltdir, 'McCaffrey_Temperature_Correlation.pdf'), format='pdf') plt.close(fig2) @@ -101,11 +101,11 @@ ZS = M.iloc[:, 0].values TC = M.iloc[:, 1].values - fig = fdsplotlib.plot_to_fig(x_data=zq, y_data=Tq, data_label='$(z/Q^{2/5})^\\eta$', + fig = fdsplotlib.plot_to_fig(x_data=zq, y_data=Tq, data_label=r'$(z/Q^{2/5})^\eta$', marker_style='r--', x_min=0.008, x_max=1, y_min=100, y_max=1200, - x_label='$z/Q^{2/5}$ $(\\hbox{m kW}^{-2/5})$', - y_label='$\\Delta T \\; (^\\circ$C)', + x_label=r'$z/Q^{2/5}$ $({\rm m kW}^{-2/5})$', + y_label=r'$\Delta T \; (^\circ$C)', legend_location='lower left', plot_title=f'McCaffrey Centerline Temperature Data, {Q[i]:.1f} kW', plot_type='loglog') @@ -128,7 +128,7 @@ T2 = x[0]*z2 + x[1] fdsplotlib.plot_to_fig(x_data=[z1,z2], y_data=[T1,T2], marker_style='g-', figure_handle=fig, data_label='Least Squares Fit') ax = plt.gca() - ax.text(0.009, 400., '$T_{\\rm surf}$='+f'{T_surf:3.0f} $^\\circ$C', fontsize=plot_style['Label_Font_Size']) + ax.text(0.009, 400., r'$T_{\rm surf}$='+f'{T_surf:3.0f}'+r'$^\circ$C', fontsize=plot_style['Label_Font_Size']) else: T_surf = np.nan @@ -156,8 +156,8 @@ marker_style='b--', x_min=0.01, x_max=1, y_min=0.5, y_max=3, revision_label=version_string, - x_label='$z/Q^{2/5}$ $(\\hbox{m kW}^{-2/5})$', - y_label='$V/Q^{1/5}$ $(\\hbox{m s}^{-1} \\; \\hbox{kW}^{-1/5})$', + x_label=r'$z/Q^{2/5}$ $({\rm m kW}^{-2/5})$', + y_label=r'$V/Q^{1/5}$ $({\rm m s}^{-1} \; {\rm kW}^{-1/5})$', plot_title=f'McCaffrey Centerline Velocity, {res}', legend_location='lower right', plot_type='loglog') @@ -182,12 +182,12 @@ # Temperature correlation figures (one for each resolution) - fig_t = fdsplotlib.plot_to_fig(x_data=zq, y_data=Tq, data_label='$(z/Q^{2/5})^\\eta$', + fig_t = fdsplotlib.plot_to_fig(x_data=zq, y_data=Tq, data_label=r'$(z/Q^{2/5})^\eta$', marker_style='r--', x_min=0.008, x_max=1, y_min=100, y_max=1200, revision_label=version_string, - x_label='$z/Q^{2/5}$ $(\\hbox{m kW}^{-2/5})$', - y_label='$\\Delta{T}$ ($^\\circ$C)', + x_label=r'$z/Q^{2/5}$ $({\rm m kW}^{-2/5})$', + y_label=r'$\Delta{T}$ ($^\circ$C)', plot_title=f'McCaffrey Centerline Temperature, {res}', legend_location='lower right', plot_type='loglog') diff --git a/Utilities/Python/scripts/blasius.py b/Utilities/Python/scripts/blasius.py index 3812d41eb76..8eb2797d524 100644 --- a/Utilities/Python/scripts/blasius.py +++ b/Utilities/Python/scripts/blasius.py @@ -1,109 +1,255 @@ -#!/usr/bin/python -#McDermott -#2016-03-02 -from __future__ import division # make floating point division default as in Matlab, e.g., 1/2=0.5 -import blaslib as bl -import math +# Plot comparisons of FDS vs Blasius boundary layer and Pohlausen thermal boundary layer + import numpy as np -import scipy.special as sp -from scipy.interpolate import interp1d -import matplotlib import matplotlib.pyplot as plt -from matplotlib import rc -rc('font',**{'family':'sans-serif','sans-serif':['Helvetica'],'size':16}) -matplotlib.rcParams['mathtext.fontset'] = 'custom' -matplotlib.rcParams['mathtext.rm'] = 'Helvetica' #'Bitstream Vera Sans' -matplotlib.rcParams['mathtext.it'] = 'Helvetica:italic' #'Bitstream Vera Sans:italic' -matplotlib.rcParams['mathtext.bf'] = 'Helvetica:bold' #'Bitstream Vera Sans:bold' +import pandas as pd +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../Verification/Flowfields/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'blasius_16_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + + +def blasius_analytic(u0, zmax, mu, rho, x, steps, fpp_init): + """ + Parameters: + u0 - free stream velocity + zmax - maximum z coordinate for calculation + mu - dynamic viscosity + rho - density + x - streamwise coordinate + steps - number of steps between 0 and etamax + fpp_init - initial (wall) value of 2nd derivative of Blasius function + + Returns: + eta - the similarity coordinate normal to the wall + f, fp - the Blasius function and its first derivative + """ + + etamax = zmax / np.sqrt(mu / rho * x / u0) + deta = etamax / (steps - 1) + eta = np.zeros(steps) + f = np.zeros(steps) + fp = np.zeros(steps) + fpp = np.zeros(steps) + fppp = np.zeros(steps) + + # initial guess for fpp + fpp[0] = fpp_init + + for i in range(steps - 1): + eta[i + 1] = eta[i] + deta + + # predictor + # 1st + k1 = np.zeros(3) + k1[0] = fp[i] + k1[1] = fpp[i] + k1[2] = -f[i] * fpp[i] / 2 + + fbar = f[i] + 0.5 * deta * k1[0] + fpbar = fp[i] + 0.5 * deta * k1[1] + fppbar = fpp[i] + 0.5 * deta * k1[2] + + # 2nd + k2 = np.zeros(3) + k2[0] = fpbar + k2[1] = fppbar + k2[2] = -fbar * fppbar / 2 + + fbar = f[i] + 0.5 * deta * k2[0] + fpbar = fp[i] + 0.5 * deta * k2[1] + fppbar = fpp[i] + 0.5 * deta * k2[2] + + # 3rd + k3 = np.zeros(3) + k3[0] = fpbar + k3[1] = fppbar + k3[2] = -fbar * fppbar / 2 + + fbar = f[i] + deta * k3[0] + fpbar = fp[i] + deta * k3[1] + fppbar = fpp[i] + deta * k3[2] + + # 4th + k4 = np.zeros(3) + k4[0] = fpbar + k4[1] = fppbar + k4[2] = -fbar * fppbar / 2 + + # corrector + f[i + 1] = f[i] + deta * (k1[0] + 2 * k2[0] + 2 * k3[0] + k4[0]) / 6 + fp[i + 1] = fp[i] + deta * (k1[1] + 2 * k2[1] + 2 * k3[1] + k4[1]) / 6 + fpp[i + 1] = fpp[i] + deta * (k1[2] + 2 * k2[2] + 2 * k3[2] + k4[2]) / 6 + fppp[i + 1] = -f[i + 1] * fpp[i + 1] / 2 + + return eta, f, fp + + +M = pd.read_csv(outdir + 'blasius_16_line.csv', skiprows=2, header=None).values +u_16 = M[:, 1] +z_16 = M[:, 0] + +M = pd.read_csv(outdir + 'blasius_32_line.csv', skiprows=2, header=None).values +u_32 = M[:, 1] +z_32 = M[:, 0] + +M = pd.read_csv(outdir + 'blasius_64_line.csv', skiprows=2, header=None).values +u_64 = M[:, 1] +z_64 = M[:, 0] + +# Plot Blasius profiles of FDS solutions + +u0 = np.max(u_64) +zmax = 0.3 +mu = 0.001 +rho = 1.2 +xc = 0.05 +eta, f, fp = blasius_analytic(u0, zmax, mu, rho, xc, 257, 0.3318) +z_blasius = eta * np.sqrt(mu / rho * xc / u0) +u_blasius = fp * u0 -ddir = '../../Verification/Flowfields/' +range_indices = np.arange(0, len(u_blasius), 4) -M_16 = np.genfromtxt(ddir+'blasius_16_line.csv', delimiter=',', skip_header=1, names=True) -z_16 = M_16['Up05z'] -u_16 = M_16['Up05'] +fig = fdsplotlib.plot_to_fig(x_data=u_blasius[range_indices], y_data=z_blasius[range_indices], marker_style='ko', data_label='Blasius', + x_min=0, x_max=1.1, y_min=0, y_max=0.15, + revision_label=version_string, + x_label='$u$ (m/s)', + y_label='$z$ (m)') -M_32 = np.genfromtxt(ddir+'blasius_32_line.csv', delimiter=',', skip_header=1, names=True) -z_32 = M_32['Up05z'] -u_32 = M_32['Up05'] +fdsplotlib.plot_to_fig(x_data=u_16, y_data=z_16, figure_handle=fig, marker_style='k-.', data_label='$N_z=16$') +fdsplotlib.plot_to_fig(x_data=u_32, y_data=z_32, figure_handle=fig, marker_style='k--', data_label='$N_z=32$') +fdsplotlib.plot_to_fig(x_data=u_64, y_data=z_64, figure_handle=fig, marker_style='k-' , data_label='$N_z=64$') -# M_64 = np.genfromtxt(ddir+'blasius_64_line.csv', delimiter=',', skip_header=1, names=True) -# z_64 = M_64['Up05z'] -# u_64 = M_64['Up05'] +plt.savefig(pltdir + 'blasius_profile.pdf', format='pdf') +plt.close() -u0 = u_32[-1] -mu = 0.001 -rho = 1.199 -xc = 0.05 +# Error between FDS with Blasius solution -delta = math.sqrt(mu/rho*xc/u0) -zmax = 0.3 -etamax = zmax/delta -n = 256 -deta = etamax/n +err = np.zeros(3) -[eta, fp] = bl.blasius_analytic(u0,zmax,mu,rho,xc) +#print(u_blasius) +for i in range(len(u_16)): + err[0] = err[0] + (np.abs(u_16[i] - u_blasius[8 + i*16]))**2 +err[0] = err[0] / 16 +err[0] = np.sqrt(err[0]) -z_bl=eta*delta -u_bl=fp*u0 +for i in range(len(u_32)): + err[1] = err[1] + (np.abs(u_32[i] - u_blasius[4 + i*8]))**2 +err[1] = err[1] / 32 +err[1] = np.sqrt(err[1]) -# create a cubic interpolation from samples of the Blasius exact solution -# to be evaluated at FDS cell face centroid locations, where the u velocity -# component is stored. +for i in range(len(u_64)): + err[2] = err[2] + (np.abs(u_64[i] - u_blasius[2 + i*4]))**2 +err[2] = err[2] / 64 +err[2] = np.sqrt(err[2]) -u_interp = interp1d(z_bl, u_bl, kind='cubic') +dz = np.zeros(3) +dz[0] = np.abs(z_16[9] - z_16[8]) +dz[1] = np.abs(z_32[9] - z_32[8]) +dz[2] = np.abs(z_64[9] - z_64[8]) -# plot FDS results +fig = fdsplotlib.plot_to_fig(x_data=dz, y_data=err, marker_style='k*-', data_label='FDS', + x_min=1e-3, x_max=1e-1, y_min=1e-3, y_max=1, + plot_type='loglog', + revision_label=version_string, + x_label=r'Grid Spacing, $\delta z$ (m)', + y_label='RMS Error (m/s)') -plt.figure +fdsplotlib.plot_to_fig(x_data=dz, y_data=10*dz , figure_handle=fig, marker_style='k--', data_label=r'$O(\delta z)$') +fdsplotlib.plot_to_fig(x_data=dz, y_data=100*dz**2, figure_handle=fig, marker_style='k-', data_label=r'$O(\delta z^2)$') -marker_style = dict(color='red', linestyle='--', marker='o', fillstyle='none', markersize=5) -plt.plot(u_16,z_16,label='FDS $N$=16',**marker_style) +plt.savefig(pltdir + 'blasius_convergence.pdf', format='pdf') +plt.close() -marker_style = dict(color='green', linestyle='--', marker='+', fillstyle='none', markersize=5) -plt.plot(u_32,z_32,label='FDS $N$=32',**marker_style) -# marker_style = dict(color='blue', linestyle='--', marker='^', fillstyle='none', markersize=5) -# plt.plot(u_64,z_64,label='FDS $N$=64',**marker_style) +# Pohlhausen solution, 1921. -# here is the exact Blasius solution -marker_style = dict(color='black', linestyle='-', marker='o', fillstyle='none', markersize=0) -plt.plot(u_bl,z_bl,label='Blasius exact',**marker_style) +outdir = '../../../out/Convection/' +chid = ['Pohlhausen_Pr_p5', 'Pohlhausen_Pr_1', 'Pohlhausen_Pr_2'] +git_file = outdir + 'Pohlhausen_Pr_2_git.txt' +version_string = fdsplotlib.get_version_string(git_file) -# here is the Blasius solution sampled at the location of the N=16 u velocity component locations -marker_style = dict(color='red', linestyle='', marker='o', fillstyle='none', markersize=5) -plt.plot(u_interp(z_16),z_16,label='Blasius sample 16',**marker_style) +# Blasius profile -# here is the Blasius solution sampled at the location of the N=32 u velocity component locations -marker_style = dict(color='green', linestyle='', marker='+', fillstyle='none', markersize=5) -plt.plot(u_interp(z_32),z_32,label='Blasius sample 32',**marker_style) +Pr = [0.5, 1, 2] # Prandtl numbers +u0 = 1.0 # see FDS input file +zmax = 1.0 # see FDS input file +mu = 0.001 # see FDS input and output files +rho = 1.2 # taken from FDS output file +nu = mu / rho +x = 5.0 # corresponds to the position of the DEVC array in the FDS input file +neta = 500 +eta, f, fp = blasius_analytic(u0, zmax, mu, rho, x, neta, 0.3318) +etamax = eta[-1] -plt.axis([0., 1.1, 0., 0.10]) -plt.xlabel('u (m/s)') -plt.ylabel('z (m)') -plt.legend(loc='upper left', numpoints=1, frameon=False) -#plt.show() -plt.savefig('blasius_prof.pdf', format='pdf') -plt.close() +# thermal profile from Pohlhausen solution, Holman eq. (B-14) -# error vectors +fds_marker = ['k-','r-','g-'] -error_16 = u_16 - u_interp(z_16) # this creates a vector of errors of length len(z_16) -error_32 = u_32 - u_interp(z_32) +fig = fdsplotlib.plot_to_fig(x_data=[-1,-1], y_data=[-1,-1], + x_min=0, x_max=8, y_min=0, y_max=1, + revision_label=version_string, + x_label=r'$\eta=z/\sqrt{\nu x/u_0}$', + y_label=r'$\frac{T-T_0}{T_w-T_0}=1-\theta$') -# RMS error +for p in range(len(Pr)): -rms_16 = math.sqrt(np.linalg.norm(error_16)/len(z_16)) -rms_32 = math.sqrt(np.linalg.norm(error_32)/len(z_32)) + deta = eta[1] - eta[0] -print rms_16, rms_32 + I = np.where(eta <= etamax)[0] + theta = np.zeros(len(I)) + for i in range(len(I)): + ieta = I[i] + num = 0.0 + for j in range(ieta + 1): + intf = np.trapz(f[:j + 1]) * deta + num = num + np.exp(-Pr[p] / 2.0 * intf) * deta + denom = num + for j in range(ieta + 1, neta): + intf = np.trapz(f[:j + 1]) * deta + denom = denom + np.exp(-Pr[p] / 2.0 * intf) * deta + theta[i] = (num - deta) / (denom - deta) + fdsplotlib.plot_to_fig(x_data=eta[I], y_data=1-theta, figure_handle=fig, marker_style=fds_marker[p], data_label=f'Pr={Pr[p]}') +plt.savefig(pltdir + 'Pohlhausen_similarity_solution.pdf', format='pdf') +plt.close() + +# now plot the temperature profile in physical space + +Tw = 21.0 # wall temperature +T0 = 20.0 # ambient temperature +fds_marker = ['ko-','ro-','go-'] +p_marker = ['k-','r-','g-'] +fig = fdsplotlib.plot_to_fig(x_data=[-1,-1], y_data=[-1,-1], + x_min=T0-0.1, x_max=Tw+0.1, y_min=0, y_max=1, + revision_label=version_string, + x_label=r'$T$ ($^\circ$C)', + y_label=r'$z$ (m)') +for p in range(len(Pr)): + T = Tw * np.ones(len(theta)) + (T0 - Tw) * theta + z = eta[I] * np.sqrt(nu * x / u0) + fdsplotlib.plot_to_fig(x_data=T, y_data=z, figure_handle=fig, marker_style=p_marker[p], data_label=f'Pohlhausen Pr={Pr[p]}') + M = pd.read_csv(outdir + chid[p] + '_line.csv', skiprows=1) + zfds = M['z'].values + Tfds = M['Tz'].values + Ufds = M['Uz'].values + + fdsplotlib.plot_to_fig(x_data=Tfds[1:], y_data=zfds[1:], figure_handle=fig, marker_style=fds_marker[p], data_label=f'FDS Pr={Pr[p]}') + +plt.savefig(pltdir + 'Pohlhausen_Tz_profile.pdf', format='pdf') +plt.close() diff --git a/Utilities/Python/scripts/compression_wave.py b/Utilities/Python/scripts/compression_wave.py new file mode 100644 index 00000000000..304d464e779 --- /dev/null +++ b/Utilities/Python/scripts/compression_wave.py @@ -0,0 +1,142 @@ + +# compression_wave case + +import os +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../Verification/Scalar_Analytical_Solution/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'compression_wave_FL0_16_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + + +def compression_wave_soln(rho0, x, y, a, c, t): + + b = np.sqrt(-1 + a**2) + d = np.sqrt(-1 + c**2) + + x0 = 2 * np.arctan(b/a * np.tan(np.arctan((1 + a*np.tan(x/2))/b) - b*t/2) - 1/a) + y0 = 2 * np.arctan(d/c * np.tan(np.arctan((1 + c*np.tan(y/2))/d) - d*t/2) - 1/c) + + Ix0 = np.log(-a**2 - np.cos(2*np.arctan((1 + a*np.tan(x0/2))/b)) + b*np.sin(2*np.arctan((1 + a*np.tan(x0/2))/b))) + Iy0 = np.log(-c**2 - np.cos(2*np.arctan((1 + c*np.tan(y0/2))/d)) + d*np.sin(2*np.arctan((1 + c*np.tan(y0/2))/d))) + + Ix = np.log(-a**2 - np.cos(b*t + 2*np.arctan((1 + a*np.tan(x0/2))/b)) + b*np.sin(b*t + 2*np.arctan((1 + a*np.tan(x0/2))/b))) + Iy = np.log(-c**2 - np.cos(d*t + 2*np.arctan((1 + c*np.tan(y0/2))/d)) + d*np.sin(d*t + 2*np.arctan((1 + c*np.tan(y0/2))/d))) + + q0 = np.log(rho0) + q = q0 + Ix - Ix0 + Iy - Iy0 + + rho = np.exp(q) + + return rho + + +# central differencing, FL=0 +M_FL0_16 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL0_16_devc.csv'), skiprows=2, header=None).values +M_FL0_32 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL0_32_devc.csv'), skiprows=2, header=None).values +M_FL0_64 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL0_64_devc.csv'), skiprows=2, header=None).values +M_FL0_128 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL0_128_devc.csv'), skiprows=2, header=None).values +t_FL0_16 = M_FL0_16[:, 0]; rho_fds_FL0_16 = M_FL0_16[:, 2] +t_FL0_32 = M_FL0_32[:, 0]; rho_fds_FL0_32 = M_FL0_32[:, 2] +t_FL0_64 = M_FL0_64[:, 0]; rho_fds_FL0_64 = M_FL0_64[:, 2] +t_FL0_128 = M_FL0_128[:, 0]; rho_fds_FL0_128 = M_FL0_128[:, 2] + +# Superbee limiter, FL=2 +M_FL2_16 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL2_16_devc.csv'), skiprows=2, header=None).values +M_FL2_32 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL2_32_devc.csv'), skiprows=2, header=None).values +M_FL2_64 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL2_64_devc.csv'), skiprows=2, header=None).values +M_FL2_128 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL2_128_devc.csv'), skiprows=2, header=None).values +t_FL2_16 = M_FL2_16[:, 0]; rho_fds_FL2_16 = M_FL2_16[:, 2] +t_FL2_32 = M_FL2_32[:, 0]; rho_fds_FL2_32 = M_FL2_32[:, 2] +t_FL2_64 = M_FL2_64[:, 0]; rho_fds_FL2_64 = M_FL2_64[:, 2] +t_FL2_128 = M_FL2_128[:, 0]; rho_fds_FL2_128 = M_FL2_128[:, 2] + +# CHARM limiter, FL=4 +M_FL4_16 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL4_16_devc.csv'), skiprows=2, header=None).values +M_FL4_32 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL4_32_devc.csv'), skiprows=2, header=None).values +M_FL4_64 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL4_64_devc.csv'), skiprows=2, header=None).values +M_FL4_128 = pd.read_csv(os.path.join(outdir, 'compression_wave_FL4_128_devc.csv'), skiprows=2, header=None).values +t_FL4_16 = M_FL4_16[:, 0]; rho_fds_FL4_16 = M_FL4_16[:, 2] +t_FL4_32 = M_FL4_32[:, 0]; rho_fds_FL4_32 = M_FL4_32[:, 2] +t_FL4_64 = M_FL4_64[:, 0]; rho_fds_FL4_64 = M_FL4_64[:, 2] +t_FL4_128 = M_FL4_128[:, 0]; rho_fds_FL4_128 = M_FL4_128[:, 2] + +# analytical solution + +a = 2 +c = 3 + +L = 2*np.pi +x = 1.5*np.pi +y = 1.5*np.pi + +rho_FL0_16 = compression_wave_soln(rho_fds_FL0_16[0], x-L/32, y-L/32, a, c, t_FL0_16) +error_FL0_16 = np.linalg.norm(rho_fds_FL0_16-rho_FL0_16)/len(t_FL0_16) +rho_FL0_32 = compression_wave_soln(rho_fds_FL0_32[0], x-L/64, y-L/64, a, c, t_FL0_32) +error_FL0_32 = np.linalg.norm(rho_fds_FL0_32-rho_FL0_32)/len(t_FL0_32) +rho_FL0_64 = compression_wave_soln(rho_fds_FL0_64[0], x-L/128, y-L/128, a, c, t_FL0_64) +error_FL0_64 = np.linalg.norm(rho_fds_FL0_64-rho_FL0_64)/len(t_FL0_64) +rho_FL0_128 = compression_wave_soln(rho_fds_FL0_128[0], x-L/256, y-L/256, a, c, t_FL0_128) +error_FL0_128 = np.linalg.norm(rho_fds_FL0_128-rho_FL0_128)/len(t_FL0_128) + +rho_FL2_16 = compression_wave_soln(rho_fds_FL2_16[0], x-L/32, y-L/32, a, c, t_FL2_16) +error_FL2_16 = np.linalg.norm(rho_fds_FL2_16-rho_FL2_16)/len(t_FL2_16) +rho_FL2_32 = compression_wave_soln(rho_fds_FL2_32[0], x-L/64, y-L/64, a, c, t_FL2_32) +error_FL2_32 = np.linalg.norm(rho_fds_FL2_32-rho_FL2_32)/len(t_FL2_32) +rho_FL2_64 = compression_wave_soln(rho_fds_FL2_64[0], x-L/128, y-L/128, a, c, t_FL2_64) +error_FL2_64 = np.linalg.norm(rho_fds_FL2_64-rho_FL2_64)/len(t_FL2_64) +rho_FL2_128 = compression_wave_soln(rho_fds_FL2_128[0], x-L/256, y-L/256, a, c, t_FL2_128) +error_FL2_128 = np.linalg.norm(rho_fds_FL2_128-rho_FL2_128)/len(t_FL2_128) + +rho_FL4_16 = compression_wave_soln(rho_fds_FL4_16[0], x-L/32, y-L/32, a, c, t_FL4_16) +error_FL4_16 = np.linalg.norm(rho_fds_FL4_16-rho_FL4_16)/len(t_FL4_16) +rho_FL4_32 = compression_wave_soln(rho_fds_FL4_32[0], x-L/64, y-L/64, a, c, t_FL4_32) +error_FL4_32 = np.linalg.norm(rho_fds_FL4_32-rho_FL4_32)/len(t_FL4_32) +rho_FL4_64 = compression_wave_soln(rho_fds_FL4_64[0], x-L/128, y-L/128, a, c, t_FL4_64) +error_FL4_64 = np.linalg.norm(rho_fds_FL4_64-rho_FL4_64)/len(t_FL4_64) +rho_FL4_128 = compression_wave_soln(rho_fds_FL4_128[0], x-L/256, y-L/256, a, c, t_FL4_128) +error_FL4_128 = np.linalg.norm(rho_fds_FL4_128-rho_FL4_128)/len(t_FL4_128) + +fig = fdsplotlib.plot_to_fig(x_data=t_FL4_128, y_data=rho_FL4_128, marker_style='k-', data_label='Analytical Solution', + x_min=0, x_max=12.5, y_min=0, y_max=8, + revision_label=version_string, + x_label='Time (s)', + y_label='Density (kg/m$^3$)') + +fdsplotlib.plot_to_fig(x_data=t_FL4_16, y_data=rho_fds_FL4_16, marker_style='c--', data_label='FDS $N=16$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=t_FL4_32, y_data=rho_fds_FL4_32, marker_style='g--', data_label='FDS $N=32$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=t_FL4_64, y_data=rho_fds_FL4_64, marker_style='b--', data_label='FDS $N=64$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=t_FL4_128,y_data=rho_fds_FL4_128,marker_style='r--', data_label='FDS $N=128$',figure_handle=fig) + +plt.savefig(os.path.join(pltdir, 'compression_wave_time_series.pdf'), format='pdf') +plt.close() + +# convergence plot + +h = 2*np.pi/np.array([16, 32, 64, 128]) +e_FL0 = np.array([error_FL0_16, error_FL0_32, error_FL0_64, error_FL0_128]) +e_FL2 = np.array([error_FL2_16, error_FL2_32, error_FL2_64, error_FL2_128]) +e_FL4 = np.array([error_FL4_16, error_FL4_32, error_FL4_64, error_FL4_128]) + +fig = fdsplotlib.plot_to_fig(x_data=h, y_data=0.1*h, marker_style='k--', data_label=r'$O(\delta x)$', + x_min=1e-2, x_max=1, y_min=1e-4, y_max=1e-1, + plot_type='loglog', + revision_label=version_string, + x_label='Grid Spacing (m)', + y_label='L$_2$ Error (kg/m$^3$)') + +fdsplotlib.plot_to_fig(x_data=h, y_data=0.1*h**2, marker_style='k-', data_label=r'$O(\delta x^2)$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=h, y_data=e_FL0, marker_style='b*-', data_label='Central', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=h, y_data=e_FL2, marker_style='ro-', data_label='Superbee', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=h, y_data=e_FL4, marker_style='g^-', data_label='CHARM', figure_handle=fig) + +plt.savefig(os.path.join(pltdir, 'compression_wave_convergence.pdf'), format='pdf') +plt.close() + diff --git a/Utilities/Python/scripts/fds_moody_chart.py b/Utilities/Python/scripts/fds_moody_chart.py new file mode 100644 index 00000000000..5036514dbde --- /dev/null +++ b/Utilities/Python/scripts/fds_moody_chart.py @@ -0,0 +1,526 @@ + +# FDS Verification Guide, Moody Chart + +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +from matplotlib import rc +import os +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../../out/Moody_Chart/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'poiseuille_N64_mu025_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +def colebrook(Re, RR, ff, tol): + """ + Solve Colebrook equation for friction factor + + Parameters: + Re - Reynolds number + RR - Relative roughness (epsilon/D) + ff - Initial guess for friction factor + tol - Tolerance for convergence + + Returns: + f_cor - Corrected friction factor + error - Final error + iter - Number of iterations + """ + max_iter = 1000 + f = ff + error = 1.0 + iter = 0 + + # Colebrook-White equation: 1/sqrt(f) = -2*log10(RR/3.7 + 2.51/(Re*sqrt(f))) + while error > tol and iter < max_iter: + f_old = f + if Re > 0 and f > 0: + sqrt_f = np.sqrt(f) + term1 = RR / 3.7 + term2 = 2.51 / (Re * sqrt_f) + f_new = 1.0 / (-2.0 * np.log10(term1 + term2))**2 + f = f_new + error = abs(f - f_old) + else: + break + iter += 1 + + f_cor = f + return f_cor, error, iter + + +def friction_factor_calc(dpdx, H, filename, *args): + """ + Calculate friction factor and Reynolds number from CSV data + + Parameters: + ----------- + dpdx : float + Pressure gradient + H : float + Channel height + filename : str + CSV filename to read + *args : optional + Optional viscosity value (mu) + + Returns: + -------- + f_fds : float + Friction factor from FDS + Re_H : float + Reynolds number based on H + """ + + # Read CSV file, skipping first 2 rows + M = np.genfromtxt(filename, delimiter=',', skip_header=2) + + # Extract velocity data from column 2 + ubar = M[:, 1] + + # Handle optional viscosity argument + if len(args) == 0: + # If no optional argument provided (nargin==3), use max of column 4 + mu = np.max(M[:, 3]) + elif len(args) == 1: + # If optional argument provided (nargin==4), use it + mu = args[0] + else: + raise ValueError("Too many arguments provided") + + # Extract density from column 5 (Matlab 1-indexed column 5 = Python 0-indexed column 4) + rho = np.max(M[:, 4]) + + # Steady state mean velocity (planar averaged) + U = ubar[-1] # Last element of ubar array + + # Reynolds number based on H + Re_H = H * U * rho / mu + + # Friction factor from FDS + f_fds = 2 * (-dpdx) * H / (rho * U**2) + + return f_fds, Re_H + + +n = 100 +Re = np.logspace(3.3, 8, n) +RR = [0, 1e-4, 1e-3, 1e-2, 1e-1] +tol = 1e-3 + +# Initialize figure +fig = fdsplotlib.plot_to_fig(x_data=[1e-3,1e-3], y_data=[1e-3,1e-3], + x_min=1e2, x_max=1e8, y_min=0.005, y_max=0.2, + plot_type='loglog', + plot_origin=(0.8,plot_style['Plot_Y']), + revision_label=version_string, + x_label='Re$_H$', + y_label='$f$') + +# Initialize storage +M = np.zeros((n, len(RR) + 1)) +f = np.zeros(n) + +for i in range(len(RR)): + + for j in range(n): + # initial guess for f + if j > 0: + ff = f[j-1] + else: + ff = 0.1 + + f[j], error, iter = colebrook(Re[j], RR[i], ff, tol) + M[j, 0] = Re[j] + M[j, i+1] = f[j] + + if i == 0: + fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='k-') + if i == 1: + fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='b-') + if i == 2: + fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='r-') + if i == 3: + fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='g-') + if i == 4: + fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='m-') + +Re_DNS = np.logspace(2, 3.3) +f_DNS = 24.0 / Re_DNS +fdsplotlib.plot_to_fig(x_data=Re_DNS, y_data=f_DNS, figure_handle=fig, marker_style='k-') + +ax = plt.gca() +ax.set_xlabel(r'Re$_H$', fontsize=plot_style['Label_Font_Size']) +ax.set_ylabel(r'$f$', fontsize=plot_style['Label_Font_Size'], rotation=0.0) + +# gather FDS results (laminar) +L = 1 +dpdx = -1 +f_fds = np.zeros(2) +Re_fds = np.zeros(2) +f_fds[0], Re_fds[0] = friction_factor_calc(dpdx, L, outdir + 'poiseuille_N64_mu025_devc.csv') +f_fds[1], Re_fds[1] = friction_factor_calc(dpdx, L, outdir + 'poiseuille_N64_mu0125_devc.csv') + +fdsplotlib.plot_to_fig(x_data=Re_fds, y_data=f_fds, figure_handle=fig, marker_style='k*') + +# gather FDS results (turbulent) +mu = 1.84e-5 + +dpdx = -0.01 +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-0p01_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='ksq') +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-0p01_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='k^') +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-0p01_N32_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='ko') + +dpdx = -1 +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-1_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='ksq') +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-1_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='k^') +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-1_N32_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='ko') + +dpdx = -100 +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-100_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='ksq', data_label='$N_z=8$, $H=1$') +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-100_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='k^', data_label='$N_z=16$, $H=1$') +f, Re = friction_factor_calc(dpdx, L, outdir + 'moody_dpdx=-100_N32_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='ko', data_label='$N_z=32$, $H=1$') + +dpdx = -0.0001 +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p0001_dpdx=-p0001_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='bsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p001_dpdx=-p0001_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='rsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p01_dpdx=-p0001_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='gsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p1_dpdx=-p0001_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='msq') + +dpdx = -0.01 +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p0001_dpdx=-p01_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='bsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p001_dpdx=-p01_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='rsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p01_dpdx=-p01_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='gsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p1_dpdx=-p01_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='msq') + +dpdx = -1 +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p0001_dpdx=-1_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='bsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p001_dpdx=-1_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='rsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p01_dpdx=-1_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='gsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p1_dpdx=-1_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='msq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p0001_dpdx=-1_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='b^') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p001_dpdx=-1_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='r^') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p01_dpdx=-1_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='g^') +f, Re = friction_factor_calc(dpdx, 2*L, outdir + 's=p02_dpdx=-1_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='g>', data_label='$N_z=16$, $H=2$') + +dpdx = -100 +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p0001_dpdx=-100_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='bsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p001_dpdx=-100_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='rsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p01_dpdx=-100_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='gsq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p1_dpdx=-100_N8_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='msq') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p0001_dpdx=-100_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='b^') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p001_dpdx=-100_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='r^') +f, Re = friction_factor_calc(dpdx, L, outdir + 's=p01_dpdx=-100_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='g^') +f, Re = friction_factor_calc(dpdx, 2*L, outdir + 's=p02_dpdx=-100_N16_devc.csv', mu) +fdsplotlib.plot_to_fig(x_data=Re, y_data=f, figure_handle=fig, marker_style='g>') + +plt.text(1.3e8, 2e-1, r'$s/H$', fontsize=plot_style['Key_Font_Size']) +plt.text(1.3e8, 1.2e-2, str(RR[1]), fontsize=plot_style['Key_Font_Size']) +plt.text(1.3e8, 1.95e-2, str(RR[2]), fontsize=plot_style['Key_Font_Size']) +plt.text(1.3e8, 3.85e-2, str(RR[3]), fontsize=plot_style['Key_Font_Size']) +plt.text(1.3e8, 1.02e-1, str(RR[4]), fontsize=plot_style['Key_Font_Size']) + +plt.savefig(pltdir + 'fds_moody_chart.pdf', format='pdf') +plt.close() + + +# Poiseuille convergence plot + +dpdx = -1 +L = 1 +N = [8, 16, 32, 64] + +f = [0.0] * 4 +Re = [0.0] * 4 + +f[0], Re[0] = friction_factor_calc(dpdx, L, outdir + 'poiseuille_N8_mu025_devc.csv') +f[1], Re[1] = friction_factor_calc(dpdx, L, outdir + 'poiseuille_N16_mu025_devc.csv') +f[2], Re[2] = friction_factor_calc(dpdx, L, outdir + 'poiseuille_N32_mu025_devc.csv') +f[3], Re[3] = friction_factor_calc(dpdx, L, outdir + 'poiseuille_N64_mu025_devc.csv') + +f = np.array(f) +Re = np.array(Re) +N = np.array(N) + +dz = L / N +error = np.abs(f - 24.0 / Re) + +fig = fdsplotlib.plot_to_fig(x_data=dz, y_data=error, marker_style='b*-', data_label='FDS', + x_min=0.01, x_max=0.2, y_min=5e-5, y_max=0.01, + plot_type='loglog', + revision_label=version_string, + x_label=r'Grid Spacing, $\delta z$ (m)', + y_label='Friction Factor Error') + +fdsplotlib.plot_to_fig(x_data=dz, y_data=0.05*dz, figure_handle=fig, marker_style='k--', data_label=r'$O(\delta z)$') +fdsplotlib.plot_to_fig(x_data=dz, y_data=0.4*dz**2, figure_handle=fig, marker_style='k-' , data_label=r'$O(\delta z^2)$') + +plt.savefig(pltdir + 'poiseuille_convergence.pdf', format='pdf') +plt.close() + + +# Poiseuille convergence plot using complex geometry + +dpdx = -1 +L = 1 +N = np.array([10, 20, 40, 80]) + +outdir = '../../Verification/Complex_Geometry/' + +# Method for cross velocity forcing: +vmethod = ['_stm'] + +for im in range(1): + + mth = vmethod[im] + + # plot convergence for Poiseuille flow aligned case theta=0 (mu = 0.025) + + f = np.zeros(4) + Re = np.zeros(4) + f2 = np.zeros(4) + Re2 = np.zeros(4) + + f[0], Re[0] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N10a_theta0' + mth + '_devc.csv') + f[1], Re[1] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N20a_theta0' + mth + '_devc.csv') + f[2], Re[2] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N40a_theta0' + mth + '_devc.csv') + f[3], Re[3] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N80a_theta0' + mth + '_devc.csv') + + f2[0], Re2[0] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N10nah_theta0' + mth + '_devc.csv') + f2[1], Re2[1] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N20nah_theta0' + mth + '_devc.csv') + f2[2], Re2[2] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N40nah_theta0' + mth + '_devc.csv') + f2[3], Re2[3] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N80nah_theta0' + mth + '_devc.csv') + + dz = L / N + error = np.abs(f - 24.0 / Re) + error2 = np.abs(f2 - 24.0 / Re2) + + fig = fdsplotlib.plot_to_fig(x_data=dz, y_data=error, marker_style='b*-', data_label='FDS, $h=0$', + x_min=0.01, x_max=0.2, y_min=5e-5, y_max=0.01, + plot_type='loglog', + revision_label=version_string, + x_label=r'Grid Spacing, $\delta z$ (m)', + y_label='Friction Factor Error') + + fdsplotlib.plot_to_fig(x_data=dz, y_data=error2, figure_handle=fig, marker_style='rx-', data_label=r'$h=\delta z/3$') + fdsplotlib.plot_to_fig(x_data=dz, y_data=0.12*dz, figure_handle=fig, marker_style='k--', data_label=r'$O(\delta z)$') + fdsplotlib.plot_to_fig(x_data=dz, y_data=0.4*dz**2,figure_handle=fig, marker_style='k-' , data_label=r'$O(\delta z^2)$') + + output_file = pltdir + 'geom_poiseuille_convergence_theta0a' + mth + '.pdf' + plt.savefig(output_file, format='pdf') + plt.close() + + # plot convergence for Poiseuille flow not aligned case theta=0 (mu = 0.025) + + f = np.zeros(4) + Re = np.zeros(4) + f2 = None + Re2 = None + H = [] + + f[0], Re[0] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N10na_theta0' + mth + '_devc.csv') + f[1], Re[1] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N20na_theta0' + mth + '_devc.csv') + f[2], Re[2] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N40na_theta0' + mth + '_devc.csv') + f[3], Re[3] = friction_factor_calc(dpdx, L, outdir + 'geom_poiseuille_N80na_theta0' + mth + '_devc.csv') + + dz = L / N + error = np.abs(f - 24.0 / Re) + + fig = fdsplotlib.plot_to_fig(x_data=dz, y_data=error, marker_style='b*-', data_label=r'FDS, $h=\delta z_{10}/11$', + x_min=0.01, x_max=0.2, y_min=5e-5, y_max=0.01, + plot_type='loglog', + revision_label=version_string, + x_label=r'Grid Spacing, $\delta z$ (m)', + y_label='Friction Factor Error') + + fdsplotlib.plot_to_fig(x_data=dz, y_data=0.05*dz, figure_handle=fig, marker_style='k--', data_label=r'$O(\delta z)$') + fdsplotlib.plot_to_fig(x_data=dz, y_data=0.4*dz**2,figure_handle=fig, marker_style='k-' , data_label=r'$O(\delta z^2)$') + + output_file = pltdir + 'geom_poiseuille_convergence_theta0na' + mth + '.pdf' + plt.savefig(output_file, format='pdf') + plt.close() + + +# Test of tunnel friction factor + +# Case matrix +# ----------- +# +# Case A: Vel = 2 m/s, Roughness = 1.E-4 m +# Case B: Vel = 2 m/s, Roughness = 1.E-1 m +# Case C: Vel = 10 m/s, Roughness = 1.E-4 m +# Case D: Vel = 10 m/s, Roughness = 1.E-1 m +# Case E: Vel = 4 m/s, Roughness = 1.E-2 m + +outdir = '../../../out/Moody_Chart/' +pltdir = '../../Manuals/FDS_User_Guide/SCRIPT_FIGURES/' + +chid = 'tunnel_pressure_drop' +cases = ['a', 'b', 'c', 'd', 'e'] +CASES = ['A', 'B', 'C', 'D', 'E'] +res = ['10', '20'] +markers = ['ko', 'k+'] +lines = ['k--', 'k:'] + +VEL = [2, 2, 10, 10, 4] +s = [1.0E-4, 1.0E-1, 1.0E-4, 1.0E-1, 1.0E-2] # sand grain roughness (m) from input file +H = [10, 10, 10, 10, 7.2] # tunnel height (m) from input file +L = [1600, 1600, 1600, 1600, 1600] # tunnel length (m) +pmin = [-1, 0, -20, 0, -10] +pmax = [6, 18, 120, 460, 60] + +f_save = np.zeros(len(cases)) +f_fds_save = np.zeros((len(res), len(cases))) + +for i in range(len(cases)): + + fig = fdsplotlib.plot_to_fig(x_data=[-1,-1], y_data=[-1,-1], + x_min=0, x_max=1600, y_min=pmin[i], y_max=pmax[i], + revision_label=version_string, + plot_title=f'Case {CASES[i]}', + x_label='Distance (m)', + y_label='Gauge Pressure (Pa)') + + x = np.concatenate([np.arange(10, 100, 10), np.arange(100, L[i]+1, 100)]) + + for j in range(len(res)): + + filename = f"{outdir}{chid}_{cases[i]}_{res[j]}_devc.csv" + M = pd.read_csv(filename, skiprows=1) + + t = M['Time'].values + U = M['UBAR'].values + + # compute friction factor (f) from Colebrook equation + mu = M['MU'].values[-1] # dynamic viscosity of AIR + rho = M['RHO'].values[-1] # density of AIR + Re = rho * H[i] * VEL[i] / mu + f, error, iter = colebrook(Re, s[i]/H[i], 0.001, 1e-9) + dpdx_exact = -f/H[i] * 0.5 * rho * VEL[i]**2 + f_save[i] = f + + # Get all pressure columns (P10 onwards) + p_cols = [col for col in M.columns if col.startswith('P')] + p_start_idx = M.columns.get_loc('P10') + P = M.iloc[-1, p_start_idx:].values + fdsplotlib.plot_to_fig(x_data=x, y_data=P, figure_handle=fig, marker_style=markers[j], data_label=f'DEVC Pressure {res[j]}') + + # least squares to get slope (pressure drop) + rsub = np.where(x >= 10)[0] + xsub = x[rsub] + A = np.column_stack([np.ones(len(xsub)), xsub]) + y = np.linalg.lstsq(A, P[rsub], rcond=None)[0] + fdsplotlib.plot_to_fig(x_data=x, y_data=y[0]+x*y[1], figure_handle=fig, marker_style=lines[j], data_label=f'Least squares fit {res[j]}') + + # compute friction factor from DEVC pressure drop + dpdx = y[1] # pressure drop (Pa/m) + f_fds = 2*(-dpdx)*H[i]/(rho*U[-1]**2) # f from FDS + f_fds_save[j, i] = f_fds + + fdsplotlib.plot_to_fig(x_data=x, y_data=(x-L[i])*dpdx_exact, figure_handle=fig, marker_style='k-', data_label='Exact pressure drop') + + # add plot title + + plt.text(80, pmin[i]+0.8*(pmax[i]-pmin[i]), f'$U$ = {VEL[i]} m/s, $s$ = {s[i]} m', fontsize=plot_style['Title_Font_Size']) + ax = plt.gca() + ax.set_xticks([0, 400, 800, 1200, 1600]) + + output_file = f"{pltdir}{chid}_{cases[i]}.pdf" + plt.savefig(output_file, format='pdf') + plt.close() + +# compute errors + +max_error = np.zeros(len(cases)) +for i in range(len(cases)): + err10 = abs((f_save[i] - f_fds_save[0, i]) / f_save[i]) + err20 = abs((f_save[i] - f_fds_save[1, i]) / f_save[i]) + max_error[i] = max(err10, err20) * 100 + +# write friction factors to latex + +fid = open(f'{pltdir}tunnel_pressure_drop.tex', 'w') +fid.write(r'\scriptsize'+'\n') +fid.write(r'\caption[Friction factors in tunnels]{Friction factors for \ct{tunnel_pressure_drop} cases.}'+'\n') +fid.write(r'\label{tab:tunnel_pressure_drop}'+'\n') +fid.write(r'\centering'+'\n') +fid.write(r'\begin{tabular}{lccccccc}'+'\n') +fid.write(r'\hline'+'\n') +fid.write(r'Case & Velocity (m/s) & Roughness (m) & Hydraulic Dia. (m) & $f$ Colebrook & $f$ FDS 10 & $f$ FDS 20 & Max Rel. Error (\%) \\'+'\n') +fid.write(r'\hline'+'\n') +fid.write(f'A & {VEL[0]} & {s[0]} & {H[0]} & {f_save[0]:.3g} & {f_fds_save[0,0]:.3g} & {f_fds_save[1,0]:.3g} & {max_error[0]:.2g} \\\\'+'\n') +fid.write(f'B & {VEL[1]} & {s[1]} & {H[1]} & {f_save[1]:.3g} & {f_fds_save[0,1]:.3g} & {f_fds_save[1,1]:.3g} & {max_error[1]:.2g} \\\\'+'\n') +fid.write(f'C & {VEL[2]} & {s[2]} & {H[2]} & {f_save[2]:.3g} & {f_fds_save[0,2]:.3g} & {f_fds_save[1,2]:.3g} & {max_error[2]:.2g} \\\\'+'\n') +fid.write(f'D & {VEL[3]} & {s[3]} & {H[3]} & {f_save[3]:.3g} & {f_fds_save[0,3]:.3g} & {f_fds_save[1,3]:.3g} & {max_error[3]:.2g} \\\\'+'\n') +fid.write(f'E & {VEL[4]} & {s[4]} & {H[4]} & {f_save[4]:.3g} & {f_fds_save[0,4]:.3g} & {f_fds_save[1,4]:.3g} & {max_error[4]:.2g} \\\\'+'\n') +fid.write(r'\hline'+'\n') +fid.write(r'\end{tabular}'+'\n') +fid.write(r'\normalsize'+'\n') +fid.close() + + +# Test of pressure drop for a tunnel fire + +res = ['10', '20', '40'] +lines = ['k:', 'k--', 'k-'] +labels = ['1 m', '0.5 m', '0.25 m'] + +fig = fdsplotlib.plot_to_fig(x_data=[-1,-1], y_data=[-1,-1], + x_min=0, x_max=1600, y_min=0, y_max=40, + revision_label=version_string, + plot_title='1600 m Tunnel, 50 MW Fire', + x_label='Distance (m)', + y_label='Gauge Pressure (Pa)') + +for j in range(len(res)): + filepath = os.path.join(outdir, f'tunnel_fire_{res[j]}_line.csv') + M = pd.read_csv(filepath, skiprows=1) + + x = M['p-x'].values + p = M['p'].values + + fdsplotlib.plot_to_fig(x_data=x, y_data=p, figure_handle=fig, marker_style=lines[j], data_label=labels[j]) + +ax = plt.gca() +ax.set_xticks([0, 400, 800, 1200, 1600]) + +fig.savefig(pltdir + 'tunnel_fire.pdf', format='pdf') +plt.close() + diff --git a/Utilities/Python/scripts/heated_channel.py b/Utilities/Python/scripts/heated_channel.py new file mode 100644 index 00000000000..5b4adbe77cc --- /dev/null +++ b/Utilities/Python/scripts/heated_channel.py @@ -0,0 +1,131 @@ + +# Create plots for heated_channel cases +# +# References: +# +# Moser, Kim, and Mansour. DNS of Turbulent Channel Flow up to Re_tau=590. +# Physics of Fluids, vol 11, 943-945, 1999. +# +# Kim, Moin & Moser. [Numerical Method, Re_tau = 178.12]. J. Fluid Mech. +# vol 177, 133-166, 1987. + +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../../out/Heated_Channel_Flow/' +expdir = '../../../exp/Heated_Channel_Flow/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'heated_channel_Pr_0p10_16_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +# Plot DNS results + +M = pd.read_csv(expdir + 'heated_channel_dns_data.csv', skiprows=0) + +yp_up_mean = M['yp_up_mean'].values +up_mean = M['up_mean'].values +yp_Tp_mean = M['yp_Tp_mean'].values +Tp_mean_Pr0p10 = M['Tp_mean_Pr0p1'].values +Tp_mean_Pr0p71 = M['Tp_mean_Pr0p71'].values +Tp_mean_Pr2p00 = M['Tp_mean_Pr2p0'].values +range_indices = slice(0, len(yp_up_mean), 3) + +fig1 = fdsplotlib.plot_to_fig(x_data=yp_up_mean, y_data=up_mean, marker_style='ro', data_label=r'DNS Re$_\tau=180$', + x_min=1, x_max=1000, y_min=0, y_max=30, + plot_type='semilogx', + revision_label=version_string, + x_label='$z^+$', + y_label='$u^+$') + +fig2 = fdsplotlib.plot_to_fig(x_data=yp_Tp_mean[range_indices], y_data=Tp_mean_Pr0p10[range_indices], marker_style='bo', data_label=r'DNS Re$_\tau=180$', + x_min=1, x_max=1000, y_min=0, y_max=30, + plot_type='semilogx', + revision_label=version_string, + x_label='$z^+$', + y_label='$T^+$') + +fdsplotlib.plot_to_fig(x_data=yp_Tp_mean[range_indices], y_data=Tp_mean_Pr0p71[range_indices], marker_style='bo', figure_handle=fig2) +fdsplotlib.plot_to_fig(x_data=yp_Tp_mean[range_indices], y_data=Tp_mean_Pr2p00[range_indices], marker_style='bo', figure_handle=fig2) + +a2 = fig2.gca() +a2.text(225, 26, 'Pr=2.0', fontsize=plot_style['Label_Font_Size']) +a2.text(225, 15, 'Pr=0.71', fontsize=plot_style['Label_Font_Size']) +a2.text(225, 5, 'Pr=0.10', fontsize=plot_style['Label_Font_Size']) + +# plot the FDS results + +H = 2 +dpdx = 9.0088e-6 +tau_w = 0.5 * dpdx * H +cp = 1 +mu = 1.8216e-5 +T_w = 20 + +devcfile = ['heated_channel_Pr_0p10_16_devc.csv', + 'heated_channel_Pr_0p71_16_devc.csv', + 'heated_channel_Pr_1p00_16_devc.csv', + 'heated_channel_Pr_2p00_16_devc.csv'] + +linefile = ['heated_channel_Pr_0p10_16_line.csv', + 'heated_channel_Pr_0p71_16_line.csv', + 'heated_channel_Pr_1p00_16_line.csv', + 'heated_channel_Pr_2p00_16_line.csv'] + +err = np.zeros(4) + +for i in range(4): + + M = pd.read_csv(outdir + devcfile[i], skiprows=1) + + rho = M['RHO'].iloc[-1] # should be about 1.19 + u_tau = np.sqrt(tau_w / rho) + delta_nu = (mu / rho) / u_tau + + # Find columns starting with HF0B and HF0T + j1 = [j for j, col in enumerate(M.columns) if col == 'HF0B'][0] + j2 = [j for j, col in enumerate(M.columns) if col == 'HF0T'][0] + q_w = M.iloc[-1, j1:j2+1].mean() + T_tau = q_w / (rho * u_tau * cp) + + M = pd.read_csv(outdir + linefile[i], skiprows=1) + + zp = M.iloc[0:16, 0].values / delta_nu + + if i in [0, 1, 3]: + j1 = [j for j, col in enumerate(M.columns) if col == 'T11'][0] + j2 = [j for j, col in enumerate(M.columns) if col == 'T115'][0] + T1 = M.iloc[0:16, j1:j2+1].mean(axis=1).values # bottom wall + T2 = M.iloc[31:15:-1, j1:j2+1].mean(axis=1).values # top wall + Tp = (0.5 * (T1 + T2) - T_w) / T_tau + if i==0: + fdsplotlib.plot_to_fig(x_data=zp, y_data=Tp, marker_style='ksq-', data_label='FDS', figure_handle=fig2) + else: + fdsplotlib.plot_to_fig(x_data=zp, y_data=Tp, marker_style='ksq-', figure_handle=fig2) + elif i == 2: + j1 = [j for j, col in enumerate(M.columns) if col == 'U11'][0] + j2 = [j for j, col in enumerate(M.columns) if col == 'U115'][0] + u1 = M.iloc[0:16, j1:j2+1].mean(axis=1).values # bottom wall + u2 = M.iloc[31:15:-1, j1:j2+1].mean(axis=1).values # top wall + up = 0.5 * (u1 + u2) / u_tau + fdsplotlib.plot_to_fig(x_data=zp, y_data=up, marker_style='ksq-', data_label='FDS', figure_handle=fig1) + + if i == 0: + err[i] = abs(np.mean(Tp) - np.nanmean(Tp_mean_Pr0p10)) / np.nanmean(Tp_mean_Pr0p10) + elif i == 1: + err[i] = abs(np.mean(Tp) - np.nanmean(Tp_mean_Pr0p71)) / np.nanmean(Tp_mean_Pr0p71) + elif i == 2: + err[i] = abs(np.mean(up) - np.nanmean(up_mean)) / np.nanmean(up_mean) + elif i == 3: + err[i] = abs(np.mean(Tp) - np.nanmean(Tp_mean_Pr2p00)) / np.nanmean(Tp_mean_Pr2p00) + + if err[i] > 1: + print('Python Warning: heated_channel case ' + str(i+1) + ' out of tolerance') + +fig1.savefig(pltdir + 'heated_channel_uplus.pdf', format='pdf') +fig2.savefig(pltdir + 'heated_channel_Tplus.pdf', format='pdf') + diff --git a/Utilities/Python/scripts/jet_decay.py b/Utilities/Python/scripts/jet_decay.py index c14ade9ecfc..28641f631ba 100644 --- a/Utilities/Python/scripts/jet_decay.py +++ b/Utilities/Python/scripts/jet_decay.py @@ -71,10 +71,11 @@ x_min=0, x_max=25, y_min=0, y_max=1.2, revision_label=version_string, plot_title='Jet Centerline Velocity Decay', - legend_location='upper right', + legend_location='outside', + legend_expand=1.25, #optional (default 1.25 for legend_location=='outside') legend_fontsize=8, - x_label='$x/h$', - y_label='$u_{\\hbox{\\tiny max}}/u_0$') + x_label=r'$x/h$', + y_label=r'$u_{\rm max}/u_0$') fdsplotlib.plot_to_fig(x_data=x/h, y_data=u_1/u_0, figure_handle=fig, marker_style='k--', data_label='analytical, $m=0.12$') fdsplotlib.plot_to_fig(x_data=x/h, y_data=u_2/u_0, figure_handle=fig, marker_style='k-' , data_label='analytical, $m=0.20$') diff --git a/Utilities/Python/scripts/law_of_the_wall.py b/Utilities/Python/scripts/law_of_the_wall.py new file mode 100644 index 00000000000..3981d98d314 --- /dev/null +++ b/Utilities/Python/scripts/law_of_the_wall.py @@ -0,0 +1,47 @@ + +# Plot Werner and Wengle velocity profile for FDS Technical Reference Guide + +import numpy as np +import matplotlib.pyplot as plt +import matplotlib +import os +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +pltdir = '../../Manuals/FDS_Technical_Reference_Guide/SCRIPT_FIGURES/' + +A = 8.3 +B = 1/7 +n = 100 +zp = np.logspace(0, 4, n) +uu = zp.copy() # log law +up = np.zeros(n) + +for j in range(n): + if zp[j] < 11.81: + up[j] = zp[j] + else: + up[j] = A * zp[j]**B # Werner and Wengle (power law) + uu[j] = (1/0.41) * np.log(zp[j]) + 5.2 # log law + +# Create figure +fig = fdsplotlib.plot_to_fig(x_data=[11.8,11.8], y_data=[0,32], marker_style='k--', + x_min=1, x_max=10000, y_min=0, y_max=32, + plot_type='semilogx', + x_label='$z^+$', + y_label='$u^+$') + +fdsplotlib.plot_to_fig(x_data=zp, y_data=up, figure_handle=fig, marker_style='b-') +fdsplotlib.plot_to_fig(x_data=zp, y_data=uu, figure_handle=fig, marker_style='r--') + +# Add text annotations +ax = plt.gca() +ax.text(1.5, 8, r'$u^+ = z^+$', fontsize=plot_style['Label_Font_Size']) +ax.text(200, 15, r'$u^+ = 2.4 \ln z^+ + 5.2$', fontsize=plot_style['Label_Font_Size'], color=[1, 0, 0]) +ax.text(500, 30, r'$u^+ = A(z^+)^B$', fontsize=plot_style['Label_Font_Size'], color=[0, 0, 1]) +ax.text(15, 5, r'$z^+ = 11.81$', fontsize=plot_style['Label_Font_Size']) + +fig.savefig(pltdir + 'lawofthewall.pdf', format='pdf') +plt.close() + diff --git a/Utilities/Python/scripts/plate_view_factor.py b/Utilities/Python/scripts/plate_view_factor.py new file mode 100644 index 00000000000..abe517ef849 --- /dev/null +++ b/Utilities/Python/scripts/plate_view_factor.py @@ -0,0 +1,77 @@ + +# Plate View Factor + +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../Verification/Radiation/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'plate_view_factor_2D_30_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +NRA = np.array([30, 60, 100]) + +Exact_Flux_2D = 105.34 +Exact_Flux_cart = 81.8 +Exact_Flux_cyl = 74.1 + +Flux_2D = np.zeros(3) +Flux_cart = np.zeros(3) +Flux_cyl = np.zeros(3) +Flux_ibm = np.zeros(3) + +# 2D +M = pd.read_csv(outdir+'plate_view_factor_2D_30_devc.csv', skiprows=2, header=None) +Flux_2D[0] = M.iloc[:, 1].max() +M = pd.read_csv(outdir+'plate_view_factor_2D_60_devc.csv', skiprows=2, header=None) +Flux_2D[1] = M.iloc[:, 1].max() +M = pd.read_csv(outdir+'plate_view_factor_2D_100_devc.csv', skiprows=2, header=None) +Flux_2D[2] = M.iloc[:, 1].max() + +# Cart +M = pd.read_csv(outdir+'plate_view_factor_cart_30_devc.csv', skiprows=2, header=None) +Flux_cart[0] = M.iloc[:, 1].max() +M = pd.read_csv(outdir+'plate_view_factor_cart_60_devc.csv', skiprows=2, header=None) +Flux_cart[1] = M.iloc[:, 1].max() +M = pd.read_csv(outdir+'plate_view_factor_cart_100_devc.csv', skiprows=2, header=None) +Flux_cart[2] = M.iloc[:, 1].max() + +# Cylindrical +M = pd.read_csv(outdir+'plate_view_factor_cyl_30_devc.csv', skiprows=2, header=None) +Flux_cyl[0] = M.iloc[:, 1].max() +M = pd.read_csv(outdir+'plate_view_factor_cyl_60_devc.csv', skiprows=2, header=None) +Flux_cyl[1] = M.iloc[:, 1].max() +M = pd.read_csv(outdir+'plate_view_factor_cyl_100_devc.csv', skiprows=2, header=None) +Flux_cyl[2] = M.iloc[:, 1].max() + +# IBM +M = pd.read_csv(outdir+'plate_view_factor_ibm_30_devc.csv', skiprows=2, header=None) +Flux_ibm[0] = M.iloc[:, 1].max() +M = pd.read_csv(outdir+'plate_view_factor_ibm_60_devc.csv', skiprows=2, header=None) +Flux_ibm[1] = M.iloc[:, 1].max() +M = pd.read_csv(outdir+'plate_view_factor_ibm_100_devc.csv', skiprows=2, header=None) +Flux_ibm[2] = M.iloc[:, 1].max() + + +fig = fdsplotlib.plot_to_fig(x_data=[0,0], y_data=[0,0], + x_min=20, x_max=110, y_min=30, y_max=120, + revision_label=version_string, + plot_title=r'Radiative Heat Flux (plate_view_factor)', + x_label='Number of Radiation Angles', + y_label='Heat Flux (kW/m$^2$)') + +fdsplotlib.plot_to_fig(x_data=NRA, y_data=Exact_Flux_2D*np.ones(3), marker_style='r-', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=NRA, y_data=Flux_2D , marker_style='ro', data_label='FDS 2D', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=NRA, y_data=Exact_Flux_cart*np.ones(3), marker_style='b-', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=NRA, y_data=Flux_cart , marker_style='bs', data_label='FDS 3D', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=NRA, y_data=Exact_Flux_cyl*np.ones(3), marker_style='g-', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=NRA, y_data=Flux_cyl , marker_style='gd', data_label='FDS Cyl.', figure_handle=fig) + +plt.savefig(pltdir + 'plate_view_factor.pdf', format='pdf') +plt.close(fig) + diff --git a/Utilities/Python/scripts/pulsating.py b/Utilities/Python/scripts/pulsating.py new file mode 100644 index 00000000000..5b8a99b2afb --- /dev/null +++ b/Utilities/Python/scripts/pulsating.py @@ -0,0 +1,153 @@ + +# Analytical Solution, Pulsating Wave + +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../Verification/Scalar_Analytical_Solution/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'pulsating_FL0_16_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + + +def section2_soln(rho0, x, y, B, w, t): + + x0 = 2 * np.arctan(np.tan(x/2) * np.exp(-B/w * np.sin(w*t))) + y0 = 2 * np.arctan(np.tan(y/2) * np.exp(-B/w * np.sin(w*t))) + + q0 = np.log(rho0) + q = q0 + np.log((1 + (np.tan(x0/2))**2 * np.exp(2*B/w * np.sin(w*t))) / (1 + (np.tan(x0/2))**2)) \ + + np.log((1 + (np.tan(y0/2))**2 * np.exp(2*B/w * np.sin(w*t))) / (1 + (np.tan(y0/2))**2)) \ + - 2*B/w * np.sin(w*t) # q(x,y,t) in Verification Guide + + rho = np.exp(q) + + return rho + + +devc_col = 3 # (x,y)=(pi,pi)-->devc_col=2, (x,y)=(1.5*pi,1.5*pi)-->devc_col=3 + +# Superbee limiter, FL=2 +M_FL2_16 = np.genfromtxt(outdir + 'pulsating_FL2_16_devc.csv', delimiter=',', skip_header=2) +M_FL2_32 = np.genfromtxt(outdir + 'pulsating_FL2_32_devc.csv', delimiter=',', skip_header=2) +M_FL2_64 = np.genfromtxt(outdir + 'pulsating_FL2_64_devc.csv', delimiter=',', skip_header=2) +M_FL2_128 = np.genfromtxt(outdir + 'pulsating_FL2_128_devc.csv', delimiter=',', skip_header=2) +t_FL2_16 = M_FL2_16[:, 0] +rho_fds_FL2_16 = M_FL2_16[:, devc_col-1] +t_FL2_32 = M_FL2_32[:, 0] +rho_fds_FL2_32 = M_FL2_32[:, devc_col-1] +t_FL2_64 = M_FL2_64[:, 0] +rho_fds_FL2_64 = M_FL2_64[:, devc_col-1] +t_FL2_128 = M_FL2_128[:, 0] +rho_fds_FL2_128 = M_FL2_128[:, devc_col-1] + +# CHARM limiter, FL=4 +M_FL4_16 = np.genfromtxt(outdir + 'pulsating_FL4_16_devc.csv', delimiter=',', skip_header=2) +M_FL4_32 = np.genfromtxt(outdir + 'pulsating_FL4_32_devc.csv', delimiter=',', skip_header=2) +M_FL4_64 = np.genfromtxt(outdir + 'pulsating_FL4_64_devc.csv', delimiter=',', skip_header=2) +M_FL4_128 = np.genfromtxt(outdir + 'pulsating_FL4_128_devc.csv', delimiter=',', skip_header=2) +t_FL4_16 = M_FL4_16[:, 0] +rho_fds_FL4_16 = M_FL4_16[:, devc_col-1] +t_FL4_32 = M_FL4_32[:, 0] +rho_fds_FL4_32 = M_FL4_32[:, devc_col-1] +t_FL4_64 = M_FL4_64[:, 0] +rho_fds_FL4_64 = M_FL4_64[:, devc_col-1] +t_FL4_128 = M_FL4_128[:, 0] +rho_fds_FL4_128 = M_FL4_128[:, devc_col-1] + +# central differencing, FL=0 +M_FL0_16 = np.genfromtxt(outdir + 'pulsating_FL0_16_devc.csv', delimiter=',', skip_header=2) +M_FL0_32 = np.genfromtxt(outdir + 'pulsating_FL0_32_devc.csv', delimiter=',', skip_header=2) +M_FL0_64 = np.genfromtxt(outdir + 'pulsating_FL0_64_devc.csv', delimiter=',', skip_header=2) +M_FL0_128 = np.genfromtxt(outdir + 'pulsating_FL0_128_devc.csv', delimiter=',', skip_header=2) +t_FL0_16 = M_FL0_16[:, 0] +rho_fds_FL0_16 = M_FL0_16[:, devc_col-1] +t_FL0_32 = M_FL0_32[:, 0] +rho_fds_FL0_32 = M_FL0_32[:, devc_col-1] +t_FL0_64 = M_FL0_64[:, 0] +rho_fds_FL0_64 = M_FL0_64[:, devc_col-1] +t_FL0_128 = M_FL0_128[:, 0] +rho_fds_FL0_128 = M_FL0_128[:, devc_col-1] + +# analytical solution + +B = 1 +w = 1 + +L = 2*np.pi +if devc_col == 2: + x = np.pi + y = np.pi +if devc_col == 3: + x = 1.5*np.pi + y = 1.5*np.pi + +rho_FL2_16 = section2_soln(rho_fds_FL2_16[0], x-L/32, y-L/32, B, w, t_FL2_16) +error_FL2_16 = np.linalg.norm(rho_fds_FL2_16 - rho_FL2_16) / len(t_FL2_16) +rho_FL2_32 = section2_soln(rho_fds_FL2_32[0], x-L/64, y-L/64, B, w, t_FL2_32) +error_FL2_32 = np.linalg.norm(rho_fds_FL2_32 - rho_FL2_32) / len(t_FL2_32) +rho_FL2_64 = section2_soln(rho_fds_FL2_64[0], x-L/128, y-L/128, B, w, t_FL2_64) +error_FL2_64 = np.linalg.norm(rho_fds_FL2_64 - rho_FL2_64) / len(t_FL2_64) +rho_FL2_128 = section2_soln(rho_fds_FL2_128[0], x-L/256, y-L/256, B, w, t_FL2_128) +error_FL2_128 = np.linalg.norm(rho_fds_FL2_128 - rho_FL2_128) / len(t_FL2_128) + +rho_FL4_16 = section2_soln(rho_fds_FL4_16[0], x-L/32, y-L/32, B, w, t_FL4_16) +error_FL4_16 = np.linalg.norm(rho_fds_FL4_16 - rho_FL4_16) / len(t_FL4_16) +rho_FL4_32 = section2_soln(rho_fds_FL4_32[0], x-L/64, y-L/64, B, w, t_FL4_32) +error_FL4_32 = np.linalg.norm(rho_fds_FL4_32 - rho_FL4_32) / len(t_FL4_32) +rho_FL4_64 = section2_soln(rho_fds_FL4_64[0], x-L/128, y-L/128, B, w, t_FL4_64) +error_FL4_64 = np.linalg.norm(rho_fds_FL4_64 - rho_FL4_64) / len(t_FL4_64) +rho_FL4_128 = section2_soln(rho_fds_FL4_128[0], x-L/256, y-L/256, B, w, t_FL4_128) +error_FL4_128 = np.linalg.norm(rho_fds_FL4_128 - rho_FL4_128) / len(t_FL4_128) + +rho_FL0_16 = section2_soln(rho_fds_FL0_16[0], x-L/32, y-L/32, B, w, t_FL0_16) +error_FL0_16 = np.linalg.norm(rho_fds_FL0_16 - rho_FL0_16) / len(t_FL0_16) +rho_FL0_32 = section2_soln(rho_fds_FL0_32[0], x-L/64, y-L/64, B, w, t_FL0_32) +error_FL0_32 = np.linalg.norm(rho_fds_FL0_32 - rho_FL0_32) / len(t_FL0_32) +rho_FL0_64 = section2_soln(rho_fds_FL0_64[0], x-L/128, y-L/128, B, w, t_FL0_64) +error_FL0_64 = np.linalg.norm(rho_fds_FL0_64 - rho_FL0_64) / len(t_FL0_64) +rho_FL0_128 = section2_soln(rho_fds_FL0_128[0], x-L/256, y-L/256, B, w, t_FL0_128) +error_FL0_128 = np.linalg.norm(rho_fds_FL0_128 - rho_FL0_128) / len(t_FL0_128) + +fig = fdsplotlib.plot_to_fig(x_data=t_FL2_128, y_data=rho_FL2_128, marker_style='k-', data_label='Analytical Solution', + x_min=0, x_max=12.5, y_min=0, y_max=2, + revision_label=version_string, + x_label='Time (s)', + y_label='Density (kg/m$^3$)') + +fdsplotlib.plot_to_fig(x_data=t_FL2_16, y_data=rho_fds_FL2_16, marker_style='c--', data_label='FDS $N=16$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=t_FL2_32, y_data=rho_fds_FL2_32, marker_style='g--', data_label='FDS $N=32$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=t_FL2_64, y_data=rho_fds_FL2_64, marker_style='b--', data_label='FDS $N=64$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=t_FL2_128,y_data=rho_fds_FL2_128,marker_style='r--', data_label='FDS $N=128$',figure_handle=fig) + +plt.savefig(pltdir + 'pulsating_time_series.pdf', format='pdf') +plt.close() + +# convergence plot + +h = 2*np.pi / np.array([16, 32, 64, 128]) + +fig = fdsplotlib.plot_to_fig(x_data=h, y_data=0.1*h, marker_style='k--', data_label=r'$O(\delta x)$', + x_min=1e-2, x_max=1, y_min=1e-6, y_max=1e-1, + plot_type='loglog', + revision_label=version_string, + x_label='Grid Spacing (m)', + y_label='L$_2$ Error (kg/m$^3$)') + +e_FL2 = np.array([error_FL2_16, error_FL2_32, error_FL2_64, error_FL2_128]) +e_FL4 = np.array([error_FL4_16, error_FL4_32, error_FL4_64, error_FL4_128]) +e_FL0 = np.array([error_FL0_16, error_FL0_32, error_FL0_64, error_FL0_128]) + +fdsplotlib.plot_to_fig(x_data=h, y_data=0.1*h**2, marker_style='k-', data_label=r'$O(\delta x^2)$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=h, y_data=e_FL0, marker_style='b*-', data_label='FDS Central', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=h, y_data=e_FL2, marker_style='ro-', data_label='FDS Superbee', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=h, y_data=e_FL4, marker_style='g^-', data_label='FDS CHARM', figure_handle=fig) + +plt.savefig(pltdir + 'pulsating_convergence.pdf', format='pdf') +plt.close() + diff --git a/Utilities/Python/scripts/ribbed_channel.py b/Utilities/Python/scripts/ribbed_channel.py new file mode 100644 index 00000000000..b87f4cc9f03 --- /dev/null +++ b/Utilities/Python/scripts/ribbed_channel.py @@ -0,0 +1,168 @@ + +# Casara Art Ribbed Channel cases + +import os +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +import sys +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../../out/Casara_Arts_Ribbed_Channel/' +expdir = '../../../exp/Casara_Arts_Ribbed_Channel/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'ribbed_channel_20_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +nx = [20, 40, 80, 160] +lnx = len(nx) +Ub = 6.2 # exp bulk velocity +L = 0.3 # channel length +D = 0.1 # channel height +h = 0.03 +dx = L / np.array([10, 20, 40, 80]) +fds_marker = ['r+-', 'c^-', 'g>-', 'k-'] +fds_key = [r'FDS $h/\delta x=3$', r'FDS $h/\delta x=6$', r'FDS $h/\delta x=12$', r'FDS $h/\delta x=24$'] +geom = ['_', '_geom_'] + +DATA = pd.read_csv(os.path.join(expdir, 'ribbed_channel_data.csv')) + +# Main loop over regular and complex geometry types + +for ii in range(len(geom)): + + # Bulk velocity + + M = {} + for i in range(lnx): + filename = os.path.join(outdir, f'ribbed_channel{geom[ii]}{nx[i]}_devc.csv') + M[i] = pd.read_csv(filename, skiprows=1) + + fig = fdsplotlib.plot_to_fig(x_data=[0,100], y_data=[Ub,Ub], marker_style='k-', data_label='Exp Bulk Velocity', + x_min=0, x_max=10, y_min=0, y_max=1.5*Ub, + revision_label=version_string, + x_label='Time (s)', + y_label='Bulk Velocity (m/s)') + + for i in range(lnx): + t_fds = M[i].iloc[:, 0].values + Ub_fds = M[i].iloc[:, 1].values + fdsplotlib.plot_to_fig(x_data=t_fds, y_data=Ub_fds, figure_handle=fig, marker_style=fds_marker[i], data_label=fds_key[i]) + t_range = np.where(t_fds > 2)[0] + if abs(np.mean(Ub_fds[t_range]) - Ub) / Ub > 0.01: + print(f'Matlab Warning: Ub mean nx {geom[ii]}{nx[i]} = {np.mean(Ub_fds[t_range])}') + + plt.savefig(os.path.join(pltdir, f'ribbed_channel{geom[ii]}Ubulk.pdf'), format='pdf') + plt.close() + + # Streamwise U along bottom of channel + + for i in range(lnx): + filename = os.path.join(outdir, f'ribbed_channel{geom[ii]}{nx[i]}_line.csv') + M[i] = pd.read_csv(filename, skiprows=1) + + j = DATA.columns.get_loc('x/h U strm') + xoh = DATA.iloc[:, j].values + j = DATA.columns.get_loc('U strm') + u_data = DATA.iloc[:, j].values + + fig = fdsplotlib.plot_to_fig(x_data=xoh, y_data=u_data, marker_style='bo', data_label='PIV Data', + x_min=0, x_max=10, y_min=-0.6, y_max=0.6, + revision_label=version_string, + x_label='$x/h$', + y_label=r'$U/U_{\rm b}$') + + for i in range(lnx): + j = M[i].columns.get_loc('u_strm_bot-x') + x = M[i].iloc[:, j].values + I = np.where(x < 0)[0] + x[I] = x[I] + L + I = np.argsort(x) + x = x[I] + j = M[i].columns.get_loc('u_strm_bot') + u_fds = M[i].iloc[:, j].values + u_fds = u_fds[I] + fdsplotlib.plot_to_fig(x_data=x/h, y_data=u_fds/Ub, figure_handle=fig, marker_style=fds_marker[i], data_label=fds_key[i]) + + plt.savefig(os.path.join(pltdir, f'ribbed_channel{geom[ii]}u_strm.pdf'), format='pdf') + plt.close() + + # Streamwise urms along bottom of channel + + j = DATA.columns.get_loc('x/h urms strm') + xoh = DATA.iloc[:, j].values + j = DATA.columns.get_loc('urms strm') + urms_data = DATA.iloc[:, j].values + + fig = fdsplotlib.plot_to_fig(x_data=xoh, y_data=urms_data, marker_style='bo', data_label='PIV Data', + x_min=0, x_max=10, y_min=0, y_max=0.6, + revision_label=version_string, + x_label='$x/h$', + y_label=r'$U_{\rm rms}/U_{\rm b}$') + + for i in range(lnx): + j = M[i].columns.get_loc('urms_strm_bot-x') + x = M[i].iloc[:, j].values + I = np.where(x < 0)[0] + x[I] = x[I] + L + I = np.argsort(x) + x = x[I] + j = M[i].columns.get_loc('urms_strm_bot') + urms_fds = M[i].iloc[:, j].values + urms_fds = urms_fds[I] + fdsplotlib.plot_to_fig(x_data=x/h, y_data=urms_fds/Ub, figure_handle=fig, marker_style=fds_marker[i], data_label=fds_key[i]) + + plt.savefig(os.path.join(pltdir, f'ribbed_channel{geom[ii]}urms_strm.pdf'), format='pdf') + plt.close() + + # Streamwise U profile at x/h=0 (center of rib) + + j = DATA.columns.get_loc('y/h U prof') + yoh = DATA.iloc[:, j].values + j = DATA.columns.get_loc('U prof') + u_data = DATA.iloc[:, j].values + + fig = fdsplotlib.plot_to_fig(x_data=u_data, y_data=yoh, marker_style='bo', data_label='PIV Data', + x_min=0, x_max=2, y_min=1, y_max=D/h, + revision_label=version_string, + x_label='$z/h$', + y_label=r'$U/U_{\rm b}$') + + for i in range(lnx): + j = M[i].columns.get_loc('u_prof_rib-z') + I = np.where((M[i].iloc[:, j].values > h) & (M[i].iloc[:, j].values < D))[0] + y = M[i].iloc[I, j].values + j = M[i].columns.get_loc('u_prof_rib') + u_fds = M[i].iloc[I, j].values + fdsplotlib.plot_to_fig(x_data=u_fds/Ub, y_data=y/h, figure_handle=fig, marker_style=fds_marker[i], data_label=fds_key[i]) + + plt.savefig(os.path.join(pltdir, f'ribbed_channel{geom[ii]}u_prof.pdf'), format='pdf') + plt.close() + + # Streamwise urms profile at x/h=0 (center of rib) + + j = DATA.columns.get_loc('y/h urms prof') + yoh = DATA.iloc[:, j].values + j = DATA.columns.get_loc('urms prof') + urms_data = DATA.iloc[:, j].values + + fig = fdsplotlib.plot_to_fig(x_data=urms_data, y_data=yoh, marker_style='bo', data_label='PIV Data', + x_min=0, x_max=1, y_min=1, y_max=D/h, + revision_label=version_string, + x_label='$z/h$', + y_label=r'$U_{\rm rms}/U_{\rm b}$') + + for i in range(lnx): + j = M[i].columns.get_loc('urms_prof_rib-z') + I = np.where((M[i].iloc[:, j].values > h) & (M[i].iloc[:, j].values < D))[0] + y = M[i].iloc[I, j].values + j = M[i].columns.get_loc('urms_prof_rib') + urms_fds = M[i].iloc[I, j].values + fdsplotlib.plot_to_fig(x_data=urms_fds/Ub, y_data=y/h, figure_handle=fig, marker_style=fds_marker[i], data_label=fds_key[i]) + + plt.savefig(os.path.join(pltdir, f'ribbed_channel{geom[ii]}urms_prof.pdf'), format='pdf') + plt.close() + diff --git a/Utilities/Python/scripts/saad_mms_temporal_error.py b/Utilities/Python/scripts/saad_mms_temporal_error.py new file mode 100644 index 00000000000..eff82dfa5d1 --- /dev/null +++ b/Utilities/Python/scripts/saad_mms_temporal_error.py @@ -0,0 +1,294 @@ +#!/usr/bin/env python3 +# McDermott +# 7-9-2015 +# saad_mms_temporal_error.m +# +# Converted by Floyd +# 10-14-2025 + +import os +import numpy as np +import pandas as pd +import math +import matplotlib.pyplot as plt +import fdsplotlib + + +# Problem 1 parameters +r = 0.5 +nx = 512 +L = 2 +dx = L/nx +x = np.arange(-L/2+dx/2, L/2, dx) +rho0 = 5 +rho1 = .5 +f = .5*(1+np.sin(2*np.pi*x/L)) +rho = 1./((1-f)/rho0 + f/rho1) + +# Output files + +datadir = '../../Verification/Scalar_Analytical_Solution/'; +plotdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/'; +filename = ['saad_512_cfl_1_mms.csv','saad_512_cfl_p5_mms.csv','saad_512_cfl_p25_mms.csv','saad_512_cfl_p125_mms.csv','saad_512_cfl_p0625_mms.csv'] + +skip_case = False + +for i in range(len(filename)): + name = datadir+filename[i] + if not os.path.exists(name): + skip_case = True + print('Error: File ', filename[i], ' does not exist. Skipping case.') + +if skip_case: quit() + +# Gather FDS results + +M1 = pd.read_csv(datadir+filename[2],skiprows=2,header=None) +M2 = pd.read_csv(datadir+filename[3],skiprows=2,header=None) +M3 = pd.read_csv(datadir+filename[4],skiprows=2,header=None) + +ii = np.arange(nx,2*nx) +rho_1 = M1.iloc[ii,0] +rho_2 = M2.iloc[ii,0] +rho_3 = M3.iloc[ii,0] +Z_1 = M1.iloc[ii,1] +Z_2 = M2.iloc[ii,1] +Z_3 = M3.iloc[ii,1] + +p_rho = np.log(np.abs(rho_3-rho_2)/np.abs(rho_2-rho_1) )/np.log(r); +p_Z = np.log( abs(Z_3-Z_2)/np.abs(Z_2-Z_1) )/np.log(r); + +# print('Saad temporal order') +# print(' ') +# print('L1 p rho = ', np.linalg.norm(p_rho,ord=1)/nx) +# print('L2 p rho = ' ,np.linalg.norm(p_rho,2)/math.sqrt(nx)) +# print('Linf p rho = ',np.linalg.norm(p_rho,ord=np.inf)) +# print(' ') +# print('L1 p Z = ',np.linalg.norm(p_Z,ord=1)/nx) +# print('L2 p Z = ',np.linalg.norm(p_Z,ord=2)/math.sqrt(nx)) +# print('Linf p Z = ',np.linalg.norm(p_Z,ord=npinf)) +# print(' ') + +# flag errors + +L2_rho = np.linalg.norm(p_rho,ord=2)/math.sqrt(nx) +if L2_rho<1.99: + print('Matlab Warning: L2_rho = ',L2_rho,' in Saad MMS') + +L2_Z = np.linalg.norm(p_Z,ord=2)/math.sqrt(nx); +if L2_Z<1.99: + print('Matlab Warning: L2_Z = ',L2_Z,' in Saad MMS') + +# write the l2 norm to latex + +with open(plotdir+'saad_l2_norm.tex', 'w') as fid: + fid.write(f'{L2_rho:.4f}\n') + +# Tony Saad's way... +p1_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,ord=1)/np.linalg.norm(rho_2-rho_1,ord=1) )/np.log(r) +p2_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,ord=2)/np.linalg.norm(rho_2-rho_1,ord=2) )/np.log(r) +pinf_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,ord=np.inf)/np.linalg.norm(rho_2-rho_1,ord=np.inf) )/np.log(r) +# print('L1 p rho Saad = ', p1_rho_saad)) +# print('L2 p rho Saad = ', p2_rho_saad ) +# print('Linf p rho Saad = ', pinf_rho_saad)) +# print(' ') +p1_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,ord=1)/np.linalg.norm(Z_2-Z_1,ord=1) )/np.log(r) +p2_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,ord=2)/np.linalg.norm(Z_2-Z_1,ord=2) )/np.log(r) +pinf_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,ord=np.inf)/np.linalg.norm(Z_2-Z_1,ord=np.inf) )/np.log(r) +# print('L1 p Z Saad = ',p1_Z_saad ) +# print('L2 p Z Saad = ',p2_Z_saad ) +# print('Linf p Z Saad = ', pinf_Z_saad ) +# print(' ') + +git_file = datadir+'saad_512_cfl_p0625_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=p_rho, marker_style='b-', + revision_label=version_string,x_min=-1,x_max=1,y_min=0,y_max=4, + x_label='$x$ (m)', + y_label='$p$ order density') + +plotname = plotdir + 'saad_temporal_order_rho.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=p_Z, marker_style='b-', + revision_label=version_string,x_min=-1,x_max=1,y_min=0,y_max=4, + x_label='$x$ (m)', + y_label='$p$ order mixture fraction') + +plotname = plotdir + 'saad_temporal_order_Z.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=rho, marker_style='r--', + revision_label=version_string,x_min=-1,x_max=1,y_min=0,y_max=5, + data_label = 'Initial field', + x_label='$x$ (m)', + y_label='Density (kg/m$^3$') + +fdsplotlib.plot_to_fig(x_data=x, y_data=rho_3, marker_style='r-', + figure_handle=fig, + data_label='Final field') + +plotname = plotdir + 'saad_rho.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=f, marker_style='b--', + revision_label=version_string,x_min=-1,x_max=1,y_min=0,y_max=1, + data_label = 'Initial field', + x_label='$x$ (m)', + y_label='Mixture Fraction') + +fdsplotlib.plot_to_fig(x_data=x, y_data=Z_3, marker_style='b-', + figure_handle=fig, + data_label='Final field') + +plotname = plotdir + 'saad_Z.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=rho_3-rho_2, marker_style='b-', + revision_label=version_string,x_min=-1,x_max=1,y_min=-0.0006,y_max=0.0006, + data_label = '$\\rho_3$ - $\\rho_2$', + x_label='$x$ (m)', + y_label='Density (kg/m$^3$)') + +fdsplotlib.plot_to_fig(x_data=x, y_data=rho_2-rho_1, marker_style='r-', + figure_handle=fig, + data_label = '$\\rho_2$ - $\\rho_1$') + +plotname = plotdir + 'saad_rho_diff.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +#Vanella - from McDermotts saad_mms_temporal_error.m +#02-20-2018 +#saad_cc_mms_temporal_error.m +# +# Converted by Floyd +# 10-14-2025 + +datadir = '../../Verification/Complex_Geometry/' +filename = ['saad_CC_explicit_512_cfl_p25_mms.csv','saad_CC_explicit_512_cfl_p125_mms.csv','saad_CC_explicit_512_cfl_p0625_mms.csv'] + +M1 = pd.read_csv(datadir+filename[0],skiprows=2,header=None) +M2 = pd.read_csv(datadir+filename[1],skiprows=2,header=None) +M3 = pd.read_csv(datadir+filename[2],skiprows=2,header=None) + +ii = np.arange(nx,2*nx) +rho_1 = M1.iloc[ii,0] +rho_2 = M2.iloc[ii,0] +rho_3 = M3.iloc[ii,0] +Z_1 = M1.iloc[ii,1] +Z_2 = M2.iloc[ii,1] +Z_3 = M3.iloc[ii,1] + +p_rho = np.log(np.abs(rho_3-rho_2)/np.abs(rho_2-rho_1) )/np.log(r); +p_Z = np.log( abs(Z_3-Z_2)/np.abs(Z_2-Z_1) )/np.log(r); + +# print('Saad CC temporal order') +# print(' ') +# print('L1 p rho = ', np.linalg.norm(p_rho,ord=1)/nx) +# print('L2 p rho = ' ,np.linalg.norm(p_rho,2)/math.sqrt(nx)) +# print('Linf p rho = ',np.linalg.norm(p_rho,ord=np.inf)) +# print(' ') +# print('L1 p Z = ',np.linalg.norm(p_Z,ord=1)/nx) +# print('L2 p Z = ',np.linalg.norm(p_Z,ord=2)/math.sqrt(nx)) +# print('Linf p Z = ',np.linalg.norm(p_Z,ord=npinf)) +# print(' ') + +# flag errors + +L2_rho = np.linalg.norm(p_rho,ord=2)/math.sqrt(nx) +if L2_rho<1.99: + print('Matlab Warning: L2_rho = ',L2_rho,' in Saad CC MMS') + +L2_Z = np.linalg.norm(p_Z,ord=2)/math.sqrt(nx); +if L2_Z<1.99: + print('Matlab Warning: L2_Z = ',L2_Z,' in Saad CC MMS') + +# write the l2 norm to latex + +with open(plotdir+'saad_CC_explicit_l2_norm.tex', 'w') as fid: + fid.write(f'{L2_rho:.4f}\n') + +# Tony Saad's way... +p1_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,ord=1)/np.linalg.norm(rho_2-rho_1,ord=1) )/np.log(r) +p2_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,ord=2)/np.linalg.norm(rho_2-rho_1,ord=2) )/np.log(r) +pinf_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,ord=np.inf)/np.linalg.norm(rho_2-rho_1,ord=np.inf) )/np.log(r) +# print('L1 p rho Saad = ', p1_rho_saad)) +# print('L2 p rho Saad = ', p2_rho_saad ) +# print('Linf p rho Saad = ', pinf_rho_saad)) +# print(' ') +p1_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,ord=1)/np.linalg.norm(Z_2-Z_1,ord=1) )/np.log(r) +p2_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,ord=2)/np.linalg.norm(Z_2-Z_1,ord=2) )/np.log(r) +pinf_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,ord=np.inf)/np.linalg.norm(Z_2-Z_1,ord=np.inf) )/np.log(r) +# print('L1 p Z Saad = ',p1_Z_saad ) +# print('L2 p Z Saad = ',p2_Z_saad ) +# print('Linf p Z Saad = ', pinf_Z_saad ) +# print(' ') + +git_file = datadir+'saad_CC_explicit_512_cfl_p0625_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=p_rho, marker_style='b-', + revision_label=version_string,x_min=-1,x_max=1,y_min=0,y_max=4, + x_label='$x$ (m)', + y_label='$p$ order density') + +plotname = plotdir + 'saad_CC_temporal_order_rho.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=p_Z, marker_style='b-', + revision_label=version_string,x_min=-1,x_max=1,y_min=0,y_max=4, + x_label='$x$ (m)', + y_label='$p$ order mixture fraction') + +plotname = plotdir + 'saad_CC_temporal_order_Z.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=rho, marker_style='r--', + revision_label=version_string,x_min=-1,x_max=1,y_min=0,y_max=5, + data_label = 'Initial field', + x_label='$x$ (m)', + y_label='Density (kg/m$^3$') + +fdsplotlib.plot_to_fig(x_data=x, y_data=rho_3, marker_style='r-', + figure_handle=fig, + data_label='Final field') + +plotname = plotdir + 'saad_CC_rho.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=f, marker_style='b--', + revision_label=version_string,x_min=-1,x_max=1,y_min=0,y_max=1, + data_label = 'Initial field', + x_label='$x$ (m)', + y_label='Mixture Fraction') + +fdsplotlib.plot_to_fig(x_data=x, y_data=Z_3, marker_style='b-', + figure_handle=fig, + data_label='Final field') + +plotname = plotdir + 'saad_CC_Z.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +fig = fdsplotlib.plot_to_fig(x_data=x, y_data=rho_3-rho_2, marker_style='b-', + revision_label=version_string,x_min=-1,x_max=1,y_min=-0.0006,y_max=0.0006, + data_label = '$\\rho_3$ - $\\rho_2$', + x_label='$x$ (m)', + y_label='Density (kg/m$^3$)') + +fdsplotlib.plot_to_fig(x_data=x, y_data=rho_2-rho_1, marker_style='r-', + figure_handle=fig, + data_label = '$\\rho_2$ - $\\rho_1$') + +plotname = plotdir + 'saad_CC_rho_diff.pdf' +plt.savefig(plotname, format='pdf') +plt.close() \ No newline at end of file diff --git a/Utilities/Python/scripts/shunn_mms.py b/Utilities/Python/scripts/shunn_mms.py new file mode 100644 index 00000000000..13eb440eecc --- /dev/null +++ b/Utilities/Python/scripts/shunn_mms.py @@ -0,0 +1,251 @@ +# shun_mms_py +#!/usr/bin/env python3 +# McDermott +# 8-3-2015 +# shunn_mms_temporal_error.m +# +# Converted by Floyd +# 10-14-2025 + +import os +import numpy as np +import pandas as pd +import math +import matplotlib.pyplot as plt +import fdsplotlib + +r =0.5 +nx = 256 + +datadir = '../../Verification/Scalar_Analytical_Solution/' +plotdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' +filename = ['shunn3_256_cfl_1_mms.csv', + 'shunn3_256_cfl_p5_mms.csv', + 'shunn3_256_cfl_p25_mms.csv', + 'shunn3_256_cfl_p125_mms.csv', + 'shunn3_256_cfl_p0625_mms.csv'] + +skip_case = False + +for i in range(len(filename)): + name = datadir+filename[i] + if not os.path.exists(name): + skip_case = True + print('Error: File ', filename[i], ' does not exist. Skipping case.') + +if skip_case: quit() + +M1 = pd.read_csv(datadir+filename[2],skiprows=2,header=None) +M2 = pd.read_csv(datadir+filename[3],skiprows=2,header=None) +M3 = pd.read_csv(datadir+filename[4],skiprows=2,header=None) + +rho_1 = M1.iloc[:,0] +rho_2 = M2.iloc[:,0] +rho_3 = M3.iloc[:,0] +Z_1 = M1.iloc[:,1] +Z_2 = M2.iloc[:,1] +Z_3 = M3.iloc[:,1] +U_1 = M1.iloc[:,2] +U_2 = M2.iloc[:,2] +U_3 = M3.iloc[:,2] +H_1 = M1.iloc[:,4] +H_2 = M2.iloc[:,4] +H_3 = M3.iloc[:,4] + +p_rho = np.log(np.abs(rho_3-rho_2)/np.abs(rho_2-rho_1) )/np.log(r); +p_Z = np.log(np.abs(Z_3-Z_2)/np.abs(Z_2-Z_1) )/np.log(r); +p_U = np.log(np.abs(U_3-U_2)/np.abs(U_2-U_1) )/np.log(r); +p_H = np.log(np.abs(H_3-H_2)/np.abs(H_2-H_1) )/np.log(r); + + +# print('Shunn 3 temporal order') +# print(' ') +# print('L1 p rho = ',( np.linalg.norm(p_rho,ord=1)/(nx*nx) )) +# print('L2 p rho = ',( np.linalg.norm(p_rho,2ord=)/nx )) +# print('Linf p rho = ',( np.linalg.norm(p_rho,ord=np.inf) )) +# print(' ') +# print('L1 p Z = ',( np.linalg.norm(p_Z,ord=1)/(nx*nx) )) +# print('L2 p Z = ',( np.linalg.norm(p_Z,ord=2)/nx )) +# print('Linf p Z = ',( np.linalg.norm(p_Z,ord=np.inf) )) +# print(' ') +# print('L1 p U = ',( np.linalg.norm(p_U,ord=1)/(nx*nx) )) +# print('L2 p U = ',( np.linalg.norm(p_U,ord=2)/nx )) +# print('Linf p U = ',( np.linalg.norm(p_U,ord=np.nf) )) +# print(' ') +# print('L1 p H = ',( np.linalg.norm(p_H,ord=1)/(nx*nx) )) +# print('L2 p H = ',( np.linalg.norm(p_H,ord=2)/nx )) +# print('Linf p H = ',( np.linalg.norm(p_H,ord=np.inf) )) +# print(' ') + +L2_rho = np.linalg.norm(p_rho,ord=2)/nx; +if L2_rho<1.99: + disp(['Matlab Warning: L2_rho = ',L2_rho,' in Shunn 3 MMS temporal order']) + +L2_Z = np.linalg.norm(p_Z,ord=2)/nx; +if L2_Z<1.99: + print('Python Warning: L2_Z = ',L2_Z,' in Shunn 3 MMS temporal order') + +L2_U = np.linalg.norm(p_U,ord=2)/nx; +if L2_U<1.99: + print('Python Warning: L2_U = ',L2_U,' in Shunn 3 MMS temporal order') + +L2_H = np.linalg.norm(p_H,ord=2)/nx; +if L2_H<0.99: + print('Python Warning: L2_H = ',L2_H,' in Shunn 3 MMS temporal order') + + +# Tony Saad's way... +p1_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,1)/np.linalg.norm(rho_2-rho_1,ord=1) )/np.log(r); +p2_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,2)/np.linalg.norm(rho_2-rho_1,ord=2) )/np.log(r); +pinf_rho_saad = np.log( np.linalg.norm(rho_3-rho_2,ord=np.inf)/np.linalg.norm(rho_2-rho_1,ord=np.inf) )/np.log(r); +# print('L1 p rho Saad = ',num2str( p1_rho_saad )) +# print('L2 p rho Saad = ',num2str( p2_rho_saad )) +# print('Lord=np.inf p rho Saad = ',num2str( pord=np.inf_rho_saad )) +# print(' ') +p1_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,1)/np.linalg.norm(Z_2-Z_1,ord=1) )/np.log(r); +p2_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,2)/np.linalg.norm(Z_2-Z_1,ord=2) )/np.log(r); +pinf_Z_saad = np.log( np.linalg.norm(Z_3-Z_2,ord=np.inf)/np.linalg.norm(Z_2-Z_1,ord=np.inf) )/np.log(r); +# print('L1 p Z Saad = ',num2str( p1_Z_saad )) +# print('L2 p Z Saad = ',num2str( p2_Z_saad )) +# print('Lord=np.inf p Z Saad = ',num2str( pord=np.inf_Z_saad )) +# print(' ') +p1_U_saad = np.log( np.linalg.norm(U_3-U_2,1)/np.linalg.norm(U_2-U_1,ord=1) )/np.log(r); +p2_U_saad = np.log( np.linalg.norm(U_3-U_2,2)/np.linalg.norm(U_2-U_1,ord=2) )/np.log(r); +pinf_U_saad = np.log( np.linalg.norm(U_3-U_2,ord=np.inf)/np.linalg.norm(U_2-U_1,ord=np.inf) )/np.log(r); +# print('L1 p U Saad = ',num2str( p1_U_saad )) +# print('L2 p U Saad = ',num2str( p2_U_saad )) +# print('Lord=np.inf p U Saad = ',num2str( pord=np.inf_U_saad )) +# print(' ') +p1_H_saad = np.log( np.linalg.norm(H_3-H_2,1)/np.linalg.norm(H_2-H_1,ord=1) )/np.log(r); +p2_H_saad = np.log( np.linalg.norm(H_3-H_2,2)/np.linalg.norm(H_2-H_1,ord=2) )/np.log(r); +pinf_H_saad = np.log( np.linalg.norm(H_3-H_2,ord=np.inf)/np.linalg.norm(H_2-H_1,ord=np.inf) )/np.log(r); +# print('L1 p H Saad = ',num2str( p1_H_saad )) +# print('L2 p H Saad = ',num2str( p2_H_saad )) +# print('Linf p H Saad = ',num2str( pinf_H_saad )) + +# write the norms to a latex table + +with open(plotdir+'shunn_terr_norms.tex', 'w') as fid: + tmp_str = f'$L_1$ & {np.linalg.norm(p_rho, ord=1) / (nx * nx):.4f} & {np.linalg.norm(p_Z, ord=1) / (nx * nx):.4f} & {np.linalg.norm(p_U, ord=1) / (nx * nx):.4f} & {np.linalg.norm(p_H, ord=1) / (nx * nx):.4f} \\\\' + fid.write(f"{tmp_str}\n") + tmp_str = f'$L_2$ & {np.linalg.norm(p_rho, ord=2) / (nx * nx):.4f} & {np.linalg.norm(p_Z, ord=2) / (nx * nx):.4f} & {np.linalg.norm(p_U, ord=2) / (nx * nx):.4f} & {np.linalg.norm(p_H, ord=2) / (nx * nx):.4f} \\\\' + fid.write(f"{tmp_str}\n") + tmp_str = f'$L_1$ Saad & {p1_rho_saad:.4f} & {p1_Z_saad:.4f} & {p1_U_saad:.4f} & {p1_H_saad:.4f} \\\\' + fid.write(f"{tmp_str}\n") + tmp_str = f'$L_2$ Saad & {p2_rho_saad:.4f} & {p2_Z_saad:.4f} & {p2_U_saad:.4f} & {p2_H_saad:.4f} \\\\' + fid.write(f"{tmp_str}\n") + tmp_str = f'$L_{{\\infty}}$ Saad & {pinf_rho_saad:.4f} & {pinf_Z_saad:.4f} & {pinf_U_saad:.4f} & {pinf_H_saad:.4f} \\\\' + fid.write(f"{tmp_str}\n") + +# McDermott +# 9-4-2013 +# shunn_mms_favreZr.m +# +# Converted by Floyd +# 10-14-2025 +# shunn_mms_favre_error.py + +r0 = 5. +r1 = 1. +uf = 0.5 +vf = 0.5 +k = 2. +w = 2. +mu = 0.001 +D = 0.001 + + +def vd2d_mms_z(x, y, t): + numerator = 1.0 + math.sin(math.pi * k * (x - uf * t)) * \ + math.sin(math.pi * k * (y - vf * t)) * \ + math.cos(math.pi * w * t) + + denominator = (1 + r0 / r1) + (1 - r0 / r1) * \ + math.sin(math.pi * k * (x - uf * t)) * \ + math.sin(math.pi * k * (y - vf * t)) * \ + math.cos(math.pi * w * t) + + return numerator / denominator + +def vd2d_mms_rho(x, y, t): + numerator = 1.0 + denominator =vd2d_mms_z(x, y, t)/r1 + (1-vd2d_mms_z(x, y, t))/r0 + + return numerator / denominator + +X = 0 +Y = 0 +T = 10 +N = 1000 +dt = T/N + +Zbar = 0 +rhoZbar = 0 +rhobar = 0 +for n in list(range(1,N+1)): + t = n*dt + Zbar = Zbar + vd2d_mms_z(X,Y,t)*dt + rhoZbar = rhoZbar + vd2d_mms_rho(X,Y,t)*vd2d_mms_z(X,Y,t)*dt + rhobar = rhobar + vd2d_mms_rho(X,Y,t)*dt + +Zbar_mms = Zbar/T +rhoZbar = rhoZbar/T +rhobar = rhobar/T + +FavreZ_mms = rhoZbar/rhobar + +filename = ['shunn3_FavreZ_32_devc.csv','shunn3_FavreZ_64_devc.csv'] +git_file = datadir+'shunn3_FavreZ_32_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +skip_case = False + +for i in range(len(filename)): + name = datadir+filename[i] + if not os.path.exists(name): + skip_case = True + print('Error: File ', filename[i], ' does not exist. Skipping case.') + +if skip_case: quit() + +fig = fdsplotlib.plot_to_fig(x_data=[0,T], y_data=[FavreZ_mms,FavreZ_mms], marker_style='k-', + revision_label=version_string,x_min=0,x_max=T,y_min=0,y_max=0.2, + data_label='Analytical Favre', + x_label='Time (s)', + y_label='Mass Fraction') + +fdsplotlib.plot_to_fig(x_data=[0,T], y_data=[Zbar_mms,Zbar_mms], marker_style='k--', + figure_handle=fig, + data_label='Analytical Average') + +linestyle = ['m-','m--','b-','b--'] +pltlabel = ['FDS 32 Favre','FDS 32 Average','FDS 64 Favre','FDS 64 Average'] + +k=0 +for i in range(len(filename)): + M = pd.read_csv(datadir+filename[i],skiprows=2,header=None) + t = M.iloc[:,0] + Zbar = M.iloc[:,1] + FavreZ= M.iloc[:,2] + fdsplotlib.plot_to_fig(x_data=t, y_data=FavreZ, marker_style=linestyle[k], + figure_handle=fig, + data_label=pltlabel[k]) + k = k + 1 + fdsplotlib.plot_to_fig(x_data=t, y_data=Zbar, marker_style=linestyle[k], + figure_handle=fig, + data_label=pltlabel[k]) + k = k + 1 + +plotname = plotdir + 'shunn_mms_FavreZ.pdf' +plt.savefig(plotname, format='pdf') +plt.close() + +# check errors + +FavreZ_error_64 = np.abs(FavreZ[len(FavreZ)-1]-FavreZ_mms)/FavreZ_mms; +if FavreZ_error_64 > 0.01: + print('Matlab Warning: FavreZ in shunn3_FavreZ_64 is out of tolerance. Error = ',FavreZ_error_64) + + + + diff --git a/Utilities/Python/scripts/soborot_mass_transport.py b/Utilities/Python/scripts/soborot_mass_transport.py new file mode 100644 index 00000000000..fabf4863a05 --- /dev/null +++ b/Utilities/Python/scripts/soborot_mass_transport.py @@ -0,0 +1,244 @@ + +# Solid body rotation (soborot) flow field, scalar transport + +import os +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../Verification/Scalar_Analytical_Solution/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'soborot_charm_cos_wave_16_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +chid = ['soborot_charm_cos_wave_16', + 'soborot_charm_cos_wave_32', + 'soborot_charm_cos_wave_64', + 'soborot_charm_square_wave_128', + 'soborot_charm_square_wave_16', + 'soborot_charm_square_wave_32', + 'soborot_charm_square_wave_64', + 'soborot_godunov_square_wave_128', + 'soborot_godunov_square_wave_16', + 'soborot_godunov_square_wave_32', + 'soborot_godunov_square_wave_64', + 'soborot_superbee_cos_wave_128', + 'soborot_superbee_cos_wave_16', + 'soborot_superbee_cos_wave_32', + 'soborot_superbee_cos_wave_64', + 'soborot_superbee_square_wave_128', + 'soborot_superbee_square_wave_128_1mesh', + 'soborot_superbee_square_wave_16', + 'soborot_superbee_square_wave_32', + 'soborot_superbee_square_wave_64'] + +# positions of DEVC along diagonal D +L = 1.0 +D = L * np.sqrt(2.0) +r_exact = np.linspace(0.0, D, 1000) +Y_exact = np.zeros_like(r_exact) +i_range = np.where((r_exact > 0.25) & (r_exact < 0.75))[0] +Y_exact[i_range] = 1.0 +r_16 = np.arange((D/32.0), D, (D/16.0)) +r_32 = np.arange((D/64.0), D, (D/32.0)) +r_64 = np.arange((D/128.0), D, (D/64.0)) +r_128 = np.arange((D/256.0), D, (D/128.0)) + +def read_tracers(csv_path, n_tracers): + # csv has a header row followed by column headers in the 2nd row in Matlab importdata(...,2) + # here assume the first row is a header and the next row are column names -> skiprows=0 to read header + # Many CSVs from FDS include an initial line; using skiprows=1 like in previous conversion + df = pd.read_csv(csv_path, skiprows=1) + # strip whitespace from column names + df.columns = df.columns.str.strip() + col_start = df.columns.get_loc('Y_TRACER-1') + col_end = df.columns.get_loc(f'Y_TRACER-{n_tracers}') + return df.iloc[-1, col_start:col_end+1].values + +# SQUARE WAVE: CHARM + +Y_charm_16 = read_tracers(os.path.join(outdir, 'soborot_charm_square_wave_16_devc.csv'), 16) +Y_charm_32 = read_tracers(os.path.join(outdir, 'soborot_charm_square_wave_32_devc.csv'), 32) +Y_charm_64 = read_tracers(os.path.join(outdir, 'soborot_charm_square_wave_64_devc.csv'), 64) +Y_charm_128= read_tracers(os.path.join(outdir, 'soborot_charm_square_wave_128_devc.csv'),128) + +fig = fdsplotlib.plot_to_fig(x_data=r_exact, y_data=Y_exact, data_label='Exact', line_style='k-', + x_label='Radial Position (m)', y_label='Scalar Mass Fraction', + plot_title='CHARM', + x_min=0, x_max=1, y_min=0, y_max=1.2) +fdsplotlib.plot_to_fig(x_data=r_16, y_data=Y_charm_16, figure_handle=fig, data_label='$n=16$', line_style='bo-') +fdsplotlib.plot_to_fig(x_data=r_32, y_data=Y_charm_32, figure_handle=fig, data_label='$n=32$', line_style='m*-') +fdsplotlib.plot_to_fig(x_data=r_64, y_data=Y_charm_64, figure_handle=fig, data_label='$n=64$', line_style='r^-') +fdsplotlib.plot_to_fig(x_data=r_128, y_data=Y_charm_128, figure_handle=fig, data_label='$n=128$', line_style='gsq-') + +plt.savefig(os.path.join(pltdir, 'soborot_charm_square_wave.pdf'), format='pdf') +plt.close() + +# SQUARE WAVE: SUPERBEE + +Y_superbee_16 = read_tracers(os.path.join(outdir, 'soborot_superbee_square_wave_16_devc.csv'), 16) +Y_superbee_32 = read_tracers(os.path.join(outdir, 'soborot_superbee_square_wave_32_devc.csv'), 32) +Y_superbee_64 = read_tracers(os.path.join(outdir, 'soborot_superbee_square_wave_64_devc.csv'), 64) +Y_superbee_128 = read_tracers(os.path.join(outdir, 'soborot_superbee_square_wave_128_devc.csv'), 128) +Y_superbee_128_1mesh = read_tracers(os.path.join(outdir, 'soborot_superbee_square_wave_128_1mesh_devc.csv'), 128) + +fig = fdsplotlib.plot_to_fig(x_data=r_exact, y_data=Y_exact, data_label='Exact', line_style='k-', + x_label='Radial Position (m)', y_label='Scalar Mass Fraction', + plot_title='Superbee', + x_min=0, x_max=1, y_min=0, y_max=1.2) +fdsplotlib.plot_to_fig(x_data=r_16, y_data=Y_superbee_16, figure_handle=fig, data_label='$n=16$', line_style='bo-') +fdsplotlib.plot_to_fig(x_data=r_32, y_data=Y_superbee_32, figure_handle=fig, data_label='$n=32$', line_style='m*-') +fdsplotlib.plot_to_fig(x_data=r_64, y_data=Y_superbee_64, figure_handle=fig, data_label='$n=64$', line_style='r^-') +fdsplotlib.plot_to_fig(x_data=r_128, y_data=Y_superbee_128, figure_handle=fig, data_label='$n=128$', line_style='gsq-') + +plt.savefig(os.path.join(pltdir, 'soborot_superbee_square_wave.pdf'), format='pdf') +plt.close() + +# SQUARE WAVE: GODUNOV + +Y_godunov_16 = read_tracers(os.path.join(outdir, 'soborot_godunov_square_wave_16_devc.csv'), 16) +Y_godunov_32 = read_tracers(os.path.join(outdir, 'soborot_godunov_square_wave_32_devc.csv'), 32) +Y_godunov_64 = read_tracers(os.path.join(outdir, 'soborot_godunov_square_wave_64_devc.csv'), 64) +Y_godunov_128 = read_tracers(os.path.join(outdir, 'soborot_godunov_square_wave_128_devc.csv'), 128) + +fig = fdsplotlib.plot_to_fig(x_data=r_exact, y_data=Y_exact, data_label='Exact', line_style='k-', + x_label='Radial Position (m)', y_label='Scalar Mass Fraction', + plot_title='Godunov', + x_min=0, x_max=1, y_min=0, y_max=1.2) +fdsplotlib.plot_to_fig(x_data=r_16, y_data=Y_godunov_16, figure_handle=fig, data_label='$n=16$', line_style='bo-') +fdsplotlib.plot_to_fig(x_data=r_32, y_data=Y_godunov_32, figure_handle=fig, data_label='$n=32$', line_style='m*-') +fdsplotlib.plot_to_fig(x_data=r_64, y_data=Y_godunov_64, figure_handle=fig, data_label='$n=64$', line_style='r^-') +fdsplotlib.plot_to_fig(x_data=r_128, y_data=Y_godunov_128, figure_handle=fig, data_label='$n=128$', line_style='gsq-') + +plt.savefig(os.path.join(pltdir, 'soborot_godunov_square_wave.pdf'), format='pdf') +plt.close() + +# Square wave error calculations + +Y_exact_16 = np.interp(r_16, r_exact, Y_exact) +Y_exact_32 = np.interp(r_32, r_exact, Y_exact) +Y_exact_64 = np.interp(r_64, r_exact, Y_exact) +Y_exact_128 = np.interp(r_128, r_exact, Y_exact) + +e_charm_16 = np.linalg.norm(Y_charm_16 - Y_exact_16, 1) / len(r_16) +e_charm_32 = np.linalg.norm(Y_charm_32 - Y_exact_32, 1) / len(r_32) +e_charm_64 = np.linalg.norm(Y_charm_64 - Y_exact_64, 1) / len(r_64) +e_charm_128 = np.linalg.norm(Y_charm_128 - Y_exact_128, 1) / len(r_128) + +e_superbee_16 = np.linalg.norm(Y_superbee_16 - Y_exact_16, 1) / len(r_16) +e_superbee_32 = np.linalg.norm(Y_superbee_32 - Y_exact_32, 1) / len(r_32) +e_superbee_64 = np.linalg.norm(Y_superbee_64 - Y_exact_64, 1) / len(r_64) +e_superbee_128 = np.linalg.norm(Y_superbee_128 - Y_exact_128, 1) / len(r_128) +e_superbee_128_1mesh = np.linalg.norm(Y_superbee_128_1mesh - Y_exact_128, 1) / len(r_128) + +if abs(e_superbee_128_1mesh - e_superbee_128) > 1.e-10: + print('Error: soborot_superbee_square_wave_128 single mesh and multi-mesh out of tolerance') + +e_godunov_16 = np.linalg.norm(Y_godunov_16 - Y_exact_16, 1) / len(r_16) +e_godunov_32 = np.linalg.norm(Y_godunov_32 - Y_exact_32, 1) / len(r_32) +e_godunov_64 = np.linalg.norm(Y_godunov_64 - Y_exact_64, 1) / len(r_64) +e_godunov_128 = np.linalg.norm(Y_godunov_128 - Y_exact_128, 1) / len(r_128) + +dx = L / np.array([16.0, 32.0, 64.0, 128.0]) + +fig = fdsplotlib.plot_to_fig(x_data=dx, y_data=dx**0.5, data_label=r'$O(\delta x^{1/2})$', line_style='k-.', + x_label='Grid Spacing (m)', y_label='L$_2$ Error', plot_type='loglog', + plot_title='Square Wave Error', + x_min=np.min(dx), x_max=0.1, y_min=np.min(dx), y_max=np.max(dx**0.5)) +fdsplotlib.plot_to_fig(x_data=dx, y_data=dx, figure_handle=fig, data_label=r'$O(\delta x)$', line_style='k--') +fdsplotlib.plot_to_fig(x_data=dx, y_data=np.array([e_godunov_16, e_godunov_32, e_godunov_64, e_godunov_128]), + figure_handle=fig, data_label='Godunov', line_style='ksq-') +fdsplotlib.plot_to_fig(x_data=dx, y_data=np.array([e_superbee_16, e_superbee_32, e_superbee_64, e_superbee_128]), + figure_handle=fig, data_label='Superbee', line_style='k*-') +fdsplotlib.plot_to_fig(x_data=dx, y_data=np.array([e_charm_16, e_charm_32, e_charm_64, e_charm_128]), + figure_handle=fig, data_label='CHARM', line_style='ko-') + +if e_godunov_128 > 4.2e-02: + print('Error: soborot_godunov_square_wave_128 out of tolerance') +if e_charm_128 > 1.4e-02: + print('Error: soborot_charm_square_wave_128 out of tolerance') +if e_superbee_128 > 1.0e-02: + print('Error: soborot_superbee_square_wave_128 out of tolerance') + +plt.savefig(os.path.join(pltdir, 'soborot_square_wave_error.pdf'), format='pdf') +plt.close() + +# COSINE WAVE: CHARM + +Y_charm_16 = read_tracers(os.path.join(outdir, 'soborot_charm_cos_wave_16_devc.csv'), 16) +Y_charm_32 = read_tracers(os.path.join(outdir, 'soborot_charm_cos_wave_32_devc.csv'), 32) +Y_charm_64 = read_tracers(os.path.join(outdir, 'soborot_charm_cos_wave_64_devc.csv'), 64) +Y_charm_128 = read_tracers(os.path.join(outdir, 'soborot_charm_cos_wave_128_devc.csv'), 128) + +Y_exact_cos = np.zeros_like(r_exact) +i_range = np.where((r_exact > 0.25) & (r_exact < 0.75))[0] +Y_exact_cos[i_range] = 0.5 * (1.0 + np.cos(4.0 * np.pi * r_exact[i_range])) + +fig = fdsplotlib.plot_to_fig(x_data=r_exact, y_data=Y_exact_cos, data_label='Exact', line_style='k-', + x_label='Radial Position (m)', y_label='Scalar Mass Fraction', plot_title='CHARM', + x_min=0, x_max=1, y_min=0, y_max=1.2) +fdsplotlib.plot_to_fig(x_data=r_16, y_data=Y_charm_16, figure_handle=fig, data_label='$n=16$', line_style='bo-') +fdsplotlib.plot_to_fig(x_data=r_32, y_data=Y_charm_32, figure_handle=fig, data_label='$n=32$', line_style='m*-') +fdsplotlib.plot_to_fig(x_data=r_64, y_data=Y_charm_64, figure_handle=fig, data_label='$n=64$', line_style='r^-') +fdsplotlib.plot_to_fig(x_data=r_128, y_data=Y_charm_128, figure_handle=fig, data_label='$n=128$', line_style='gsq-') + +plt.savefig(os.path.join(pltdir, 'soborot_charm_cos_wave.pdf'), format='pdf') +plt.close() + +# COSINE WAVE: SUPERBEE + +Y_superbee_16 = read_tracers(os.path.join(outdir, 'soborot_superbee_cos_wave_16_devc.csv'), 16) +Y_superbee_32 = read_tracers(os.path.join(outdir, 'soborot_superbee_cos_wave_32_devc.csv'), 32) +Y_superbee_64 = read_tracers(os.path.join(outdir, 'soborot_superbee_cos_wave_64_devc.csv'), 64) +Y_superbee_128 = read_tracers(os.path.join(outdir, 'soborot_superbee_cos_wave_128_devc.csv'), 128) + +fig = fdsplotlib.plot_to_fig(x_data=r_exact, y_data=Y_exact_cos, data_label='Exact', line_style='k-', + x_label='Radial Position (m)', y_label='Scalar Mass Fraction', plot_title='Superbee', + x_min=0, x_max=1, y_min=0, y_max=1.2) +fdsplotlib.plot_to_fig(x_data=r_16, y_data=Y_superbee_16, figure_handle=fig, data_label='$n=16$', line_style='bo-') +fdsplotlib.plot_to_fig(x_data=r_32, y_data=Y_superbee_32, figure_handle=fig, data_label='$n=32$', line_style='m*-') +fdsplotlib.plot_to_fig(x_data=r_64, y_data=Y_superbee_64, figure_handle=fig, data_label='$n=64$', line_style='r^-') +fdsplotlib.plot_to_fig(x_data=r_128, y_data=Y_superbee_128, figure_handle=fig, data_label='$n=128$', line_style='gsq-') + +plt.savefig(os.path.join(pltdir, 'soborot_superbee_cos_wave.pdf'), format='pdf') +plt.close() + +# Cosine wave error calculations + +Y_exact_16 = np.interp(r_16, r_exact, Y_exact_cos) +Y_exact_32 = np.interp(r_32, r_exact, Y_exact_cos) +Y_exact_64 = np.interp(r_64, r_exact, Y_exact_cos) +Y_exact_128 = np.interp(r_128, r_exact, Y_exact_cos) + +e_charm_16 = np.linalg.norm(Y_charm_16 - Y_exact_16, 1) / len(r_16) +e_charm_32 = np.linalg.norm(Y_charm_32 - Y_exact_32, 1) / len(r_32) +e_charm_64 = np.linalg.norm(Y_charm_64 - Y_exact_64, 1) / len(r_64) +e_charm_128 = np.linalg.norm(Y_charm_128 - Y_exact_128, 1) / len(r_128) + +e_superbee_16 = np.linalg.norm(Y_superbee_16 - Y_exact_16, 1) / len(r_16) +e_superbee_32 = np.linalg.norm(Y_superbee_32 - Y_exact_32, 1) / len(r_32) +e_superbee_64 = np.linalg.norm(Y_superbee_64 - Y_exact_64, 1) / len(r_64) +e_superbee_128 = np.linalg.norm(Y_superbee_128 - Y_exact_128, 1) / len(r_128) + +fig = fdsplotlib.plot_to_fig(x_data=dx, y_data=dx, data_label=r'$O(\delta x)$', line_style='k-.', + plot_title='Cosine Wave Error', + x_label='Grid Spacing (m)', y_label='L$_2$ Error', plot_type='loglog', + x_min=np.min(dx), x_max=0.1, y_min=np.min(dx**2), y_max=np.max(dx)) +fdsplotlib.plot_to_fig(x_data=dx, y_data=dx**2, figure_handle=fig, data_label=r'$O(\delta x^2)$', line_style='k--') +fdsplotlib.plot_to_fig(x_data=dx, y_data=np.array([e_charm_16, e_charm_32, e_charm_64, e_charm_128]), + figure_handle=fig, data_label='CHARM', line_style='ko-') +fdsplotlib.plot_to_fig(x_data=dx, y_data=np.array([e_superbee_16, e_superbee_32, e_superbee_64, e_superbee_128]), + figure_handle=fig, data_label='Superbee', line_style='k*-') + +if e_charm_128 > 2.9e-04: + print('Error: soborot_charm_cos_wave_128 out of tolerance') +if e_superbee_128 > 6.4e-04: + print('Error: soborot_superbee_cos_wave_128 out of tolerance') + +plt.savefig(os.path.join(pltdir, 'soborot_cos_wave_error.pdf'), format='pdf') +plt.close() + diff --git a/Utilities/Python/scripts/terminal_velocity_convergence.py b/Utilities/Python/scripts/terminal_velocity_convergence.py new file mode 100644 index 00000000000..956c9d41501 --- /dev/null +++ b/Utilities/Python/scripts/terminal_velocity_convergence.py @@ -0,0 +1,103 @@ + +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../Verification/Sprinklers_and_Sprays/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'terminal_velocity_dt_1_0_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +M0 = pd.read_csv(outdir + 'terminal_velocity_dt_1_0_devc.csv', sep=',', header=1) +rhoa = M0.iloc[-1, 3] + +g = 9.8 +Cd = 1 +rhod = 1000 +D = 10e-3 + +tend = 20 +eps = 1e-10 +ttest = 0.1 + +K = 3 * rhoa * Cd / (4 * rhod * D) + +dtvec = np.array([1.0, 0.1, 0.01, 0.001, 0.0001]) +errvec = [] +Linf = [] +STIME = 20. +vtexact = np.sqrt(g / K) +zexact = lambda t: -np.log(np.cosh(np.sqrt(g * K) * t)) / K + +M1 = pd.read_csv(outdir + 'terminal_velocity_dt_1_0_devc.csv', sep=',', header=1) +QP = M1.iloc[-1, 1] +ZP = M1.iloc[-1, 2] +errvec.append(np.abs(np.abs(QP) - vtexact)) +Linf.append(np.abs(ZP - zexact(STIME))) + +M2 = pd.read_csv(outdir + 'terminal_velocity_dt_0_1_devc.csv', sep=',', header=1) +QP = M2.iloc[-1, 1] +ZP = M2.iloc[-1, 2] +errvec.append(np.abs(np.abs(QP) - vtexact)) +Linf.append(np.abs(ZP - zexact(STIME))) + +M3 = pd.read_csv(outdir + 'terminal_velocity_dt_0_01_devc.csv', sep=',', header=1) +QP = M3.iloc[-1, 1] +ZP = M3.iloc[-1, 2] +errvec.append(np.abs(np.abs(QP) - vtexact)) +Linf.append(np.abs(ZP - zexact(STIME))) + +M4 = pd.read_csv(outdir + 'terminal_velocity_dt_0_001_devc.csv', sep=',', header=1) +QP = M4.iloc[-1, 1] +ZP = M4.iloc[-1, 2] +errvec.append(np.abs(np.abs(QP) - vtexact)) +Linf.append(np.abs(ZP - zexact(STIME))) + +M5 = pd.read_csv(outdir + 'terminal_velocity_dt_0_0001_devc.csv', sep=',', header=1) +QP = M5.iloc[-1, 1] +ZP = M5.iloc[-1, 2] +errvec.append(np.abs(np.abs(QP) - vtexact)) +Linf.append(np.abs(ZP - zexact(STIME))) + +# Convert to numpy arrays +errvec = np.array(errvec) +Linf = np.array(Linf) + +if errvec[4] > 1e-6: + print('Matlab Warning: The velocity in the terminal_velocity* cases is out of tolerance.') + +if Linf[4] > 1e-3: + print('Matlab Warning: The position in the terminal_velocity* cases is out of tolerance.') + +fig = fdsplotlib.plot_to_fig(x_data=dtvec, y_data=errvec, marker_style='k*-', data_label='FDS', + x_min=1e-4, x_max=1, y_min=1e-15, y_max=1, + plot_type='loglog', + revision_label=version_string, + x_label='Time Step (s)', + y_label='Terminal Velocity Error (m/s)') + +fdsplotlib.plot_to_fig(x_data=dtvec, y_data=dtvec, marker_style='k--', data_label=r'$O(\delta t)$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=dtvec, y_data=dtvec**2, marker_style='k-', data_label=r'$O(\delta t^2)$', figure_handle=fig) + +plt.savefig(pltdir + 'terminal_velocity_convergence.pdf', format='pdf') +plt.close() + +# Create second figure - position convergence + +fig = fdsplotlib.plot_to_fig(x_data=dtvec, y_data=Linf, marker_style='k*-', data_label='FDS', + x_min=1e-4, x_max=1, y_min=1e-10, y_max=1, + plot_type='loglog', + revision_label=version_string, + x_label='Time Step (s)', + y_label='Position Error (m/s)') + +fdsplotlib.plot_to_fig(x_data=dtvec, y_data=dtvec, marker_style='k--', data_label=r'$O(\delta t)$', figure_handle=fig) +fdsplotlib.plot_to_fig(x_data=dtvec, y_data=dtvec**2, marker_style='k-', data_label=r'$O(\delta t^2)$', figure_handle=fig) + +plt.savefig(pltdir + 'position_convergence.pdf', format='pdf') +plt.close() + diff --git a/Utilities/Python/scripts/tree_shapes.py b/Utilities/Python/scripts/tree_shapes.py new file mode 100644 index 00000000000..541e740ce50 --- /dev/null +++ b/Utilities/Python/scripts/tree_shapes.py @@ -0,0 +1,80 @@ +import os +import sys +import pandas as pd +import numpy as np +import matplotlib.pyplot as plt +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +# Paths and identifiers +outdir = '../../Verification/WUI/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' +CHID = 'tree_shapes' + +devc_file = os.path.join(outdir, f'{CHID}_devc.csv') +if not os.path.exists(devc_file): + print(f'Error: File {devc_file} does not exist. Skipping case.') + sys.exit() + +# Read device data +DEVC = pd.read_csv(devc_file, skiprows=1) + +# Extract data from final row +random_part_mass = DEVC.iloc[-1][1:6].values +one_part_mass = DEVC.iloc[-1][6:].values + +# Ideal input volumes +box_vol = 0.6 * 0.6 * 0.4 +cone_vol = 0.6 * (0.3 ** 2) * np.pi / 3.0 +cyl_vol = 0.6 * (0.2 ** 2) * np.pi +cone_shell_vol = 0.6 * ((0.3 ** 2) - (0.2 ** 2)) * np.pi / 3.0 +cyl_shell_vol = 0.6 * ((0.2 ** 2) - (0.15 ** 2)) * np.pi + +input_vol = np.array([box_vol, cone_vol, cyl_vol, cone_shell_vol, cyl_shell_vol]) + +# Relative error in mass (bulk density 5 kg/m^3) +expected_mass = 5.0 * np.concatenate([input_vol, input_vol]) +observed_mass = np.concatenate([random_part_mass, one_part_mass]) +rel_err = np.abs(observed_mass - expected_mass) / expected_mass +rel_err = np.nan_to_num(rel_err,nan=1.) +if np.max(rel_err) > 0.1: + print('Python Warning: The mass in tree_shapes is out of tolerance.') + +# Revision string +git_file = os.path.join(outdir, f'{CHID}_git.txt') +version_string = fdsplotlib.get_version_string(git_file) + +# Plot expected value +fig = fdsplotlib.plot_to_fig( + x_data=[0.0, 0.2], + y_data=[0.0, 1.0], + marker_style='k--', + x_min=0.0, + x_max=0.15, + y_min=0.0, + y_max=0.8, + data_label='ideal', + revision_label=version_string, + x_label=r'Input volume (m$^3$)', + y_label='Tree crown mass (kg)' +) + +# Plot results +fdsplotlib.plot_to_fig( + x_data=input_vol, + y_data=random_part_mass, + marker_style='ro', + data_label='1000 random particles', + figure_handle=fig) +fdsplotlib.plot_to_fig( + x_data=input_vol, + y_data=one_part_mass, + marker_style='bo', + data_label='1 particle per cell', + figure_handle=fig) + +# Save figure +fig.savefig(os.path.join(pltdir, 'tree_shapes.pdf'), format='pdf') +plt.close(fig) + diff --git a/Utilities/Python/scripts/wall_internal_radiation.py b/Utilities/Python/scripts/wall_internal_radiation.py new file mode 100644 index 00000000000..3950fe5937d --- /dev/null +++ b/Utilities/Python/scripts/wall_internal_radiation.py @@ -0,0 +1,32 @@ +# wall_internal_radiation.py + +import os +import pandas as pd + +# File paths +infile = '../../Verification/Radiation/wall_internal_radiation_devc.csv' +outfile = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/wall_internal_radiation.tex' + +# Check if the input file exists +if not os.path.exists(infile): + print(f'Error: File {infile} does not exist. Skipping case.') +else: + # Read CSV file starting from the 4th row + data = pd.read_csv(infile, skiprows=3, header=None) + t = data.iloc[0, 0] + flux = data.iloc[0, 1:6].values + + # Open the output file and write LaTeX content + with open(outfile, 'w') as fid: + fid.write('\\begin{center}\n') + fid.write('\\begin{tabular}{|c|c|c|} \\hline\n') + fid.write('$\\tau$ & $S(\\tau)$ & FDS \\\\\n') + fid.write(' & (kW/m$^2$) & (kW/m$^2$) \\\\ \\hline\\hline\n') + fid.write(f'0.01 & 2.897 & {-flux[0]:6.3f} \\\\\n') + fid.write(f'0.1 & 24.94 & {-flux[1]:5.2f} \\\\\n') + fid.write(f'0.5 & 82.95 & {-flux[2]:5.2f} \\\\\n') + fid.write(f'1.0 & 116.3 & {-flux[3]:5.1f} \\\\\n') + fid.write(f'10. & 149.0 & {-flux[4]:5.1f} \\\\ \\hline\n') + fid.write('\\end{tabular}\n') + fid.write('\\end{center}\n') + diff --git a/Utilities/Python/scripts/yplus.py b/Utilities/Python/scripts/yplus.py new file mode 100644 index 00000000000..64e4618c5af --- /dev/null +++ b/Utilities/Python/scripts/yplus.py @@ -0,0 +1,43 @@ + +# Create plot using the output of Verification/Turbulence/yplus_N.fds + +import os +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt +import fdsplotlib + +plot_style = fdsplotlib.get_plot_style('fds') + +outdir = '../../Verification/Turbulence/' +pltdir = '../../Manuals/FDS_Verification_Guide/SCRIPT_FIGURES/' + +git_file = outdir + 'yplus_8_git.txt' +version_string = fdsplotlib.get_version_string(git_file) + +M_8 = pd.read_csv(os.path.join(outdir, 'yplus_8_devc.csv'), skiprows=2) +M_16 = pd.read_csv(os.path.join(outdir, 'yplus_16_devc.csv'), skiprows=2) +M_32 = pd.read_csv(os.path.join(outdir, 'yplus_32_devc.csv'), skiprows=2) + +yp = np.array([M_8.iloc[-1, 1], M_16.iloc[-1, 1], M_32.iloc[-1, 1]]) + +n = np.array([8, 16, 32]) +y = 0.5 * (1.0 / n) +mu = 1 +rho = 1.199 +tau_w = 0.5 +u_tau = np.sqrt(tau_w / rho) +d_nu = (mu / rho) / u_tau +yp_exact = y / d_nu + +fig = fdsplotlib.plot_to_fig(x_data=yp_exact, y_data=yp_exact, marker_style='ko', data_label='Exact', + x_min=0.01, x_max=0.05, y_min=0.01, y_max=0.05, + revision_label=version_string, + x_label='$y^+$ specified', + y_label='$y^+$ predicted') + +fdsplotlib.plot_to_fig(x_data=yp_exact, y_data=yp, figure_handle=fig, marker_style='k-', data_label='FDS') + +plt.savefig(os.path.join(pltdir, 'yplus.pdf'), format='pdf') +plt.close() +