diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/.vim/.netrwhist b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/.vim/.netrwhist new file mode 100644 index 00000000..b9691c3b --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/.vim/.netrwhist @@ -0,0 +1,3 @@ +let g:netrw_dirhistmax =10 +let g:netrw_dirhistcnt =1 +let g:netrw_dirhist_1='/home/openfoam/postProcessing/patchIntegrate(patch=inlet,field=alpha.gas)/0' diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CO2.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/CO2.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CO2.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/CO2.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CO2.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/CO2.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CO2.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/CO2.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/H2.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/H2.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/H2.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/H2.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/H2.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/H2.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/H2.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/H2.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/N2.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/N2.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/N2.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/N2.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/T.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/T.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/T.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/T.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/T.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/T.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/T.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/T.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/U.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/U.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/U.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/U.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/U.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/U.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/U.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/U.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/Ydefault.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/Ydefault.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/Ydefault.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/Ydefault.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/Ydefault.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/Ydefault.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/Ydefault.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/Ydefault.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/alpha.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/alpha.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/alpha.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/alpha.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/alpha.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/alpha.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/alpha.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/alpha.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/alphat.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/alphat.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/alphat.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/alphat.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/alphat.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/alphat.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/alphat.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/alphat.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/epsilon.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/epsilon.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/epsilon.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/epsilon.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/epsilon.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/epsilon.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/epsilon.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/epsilon.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/f.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/f.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/f.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/f.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/k.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/k.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/k.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/k.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/k.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/k.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/k.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/k.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/nut.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/nut.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/nut.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/nut.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/nut.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/nut.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/nut.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/nut.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/p b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/p similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/p rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/p diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/p_rgh b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/p_rgh similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/p_rgh rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/0.orig/p_rgh diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/Allclean b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/Allclean similarity index 95% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/Allclean rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/Allclean index 4003a12b..f55e0ec9 100755 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/Allclean +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/Allclean @@ -12,4 +12,7 @@ cd ${0%/*} || exit 1 # Run from this directory rm -rf 0 cleanCase +#rm *.obj +#rm *.stl + #------------------------------------------------------------------------------ diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/computeQOI.sh b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/computeQOI.sh new file mode 100644 index 00000000..3756ed7f --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/computeQOI.sh @@ -0,0 +1,13 @@ +if [ ! -f qoi.txt ]; then + # Reconstruct if needed + source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc + reconstructPar -newTimes + module load anaconda3/2023 + conda activate /projects/gas2fuels/conda_env/bird + python read_history.py -cr .. -cn local -df data + python get_qoi.py + conda deactivate +else + echo "WARNING: QOI already computed" +fi + diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/dynamicMix_util.H b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/dynamicMix_util.H similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/dynamicMix_util.H rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/dynamicMix_util.H diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/fvModels b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/fvModels similarity index 87% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/fvModels rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/fvModels index 0ef33092..be989a25 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/fvModels +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/fvModels @@ -12,7 +12,7 @@ codedSource type coded; selectionMode all; field U.liquid; - //name sourceTime; + name sourceTime; codeInclude #{ @@ -36,22 +36,14 @@ codedSource const volVectorField& UL = mesh().lookupObject("U.liquid"); double pi=3.141592654; - double source_pt_x; - double source_pt_y; - double source_pt_z; - double disk_rad; - double disk_area; - double power; - double smear_factor; - double startTime; - source_pt_x=13.807637692813548; - source_pt_y=1.3807637692813548; - source_pt_z=12.426873923532193; - disk_rad=0.9665346384969483; - disk_area=pi*disk_rad*disk_rad; - power=0; - smear_factor=3.0; - startTime = 1; + double source_pt_x=0.25; + double source_pt_y=0.025; + double source_pt_z=0.225; + double disk_rad=0.017499999999999998; + double disk_area=pi*disk_rad*disk_rad; + double power=2.5; + double smear_factor=3.0; + const scalar startTime = 1; if (time.value() > startTime) { // Get V1 @@ -59,7 +51,7 @@ codedSource double V1 = 0; double V2 = 0; double rhoV; - double dist_tol = disk_rad*3; + double dist_tol = disk_rad*5; double dist_n; double upV = 0; @@ -134,5 +126,3 @@ codedSource } #}; }; - - diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/g b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/g similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/g rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/g diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/globalVars b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/globalVars new file mode 100644 index 00000000..21436f69 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/globalVars @@ -0,0 +1,83 @@ +T0 300; //initial T(K) which stays constant +VVM 1.6; +//****water Liquid properties************** +CpMixLiq 4181; +muMixLiq #calc "2.414e-5 * pow(10,247.8/($T0 - 140.0))"; //viscosity (Pa.s) of water as a function of T(K) +kThermLiq 0.62; // W/m-K +rho0MixLiq 1000; // kg/m^3 +sigmaLiq 0.07; //surface tension N/m +//Wilke-Chang params for diffusion coefficient of a given solute in water (solvent) +WC_psi 2.6; +WC_M 18; // kg/kmol +WC_V_O2 25.6e-3; // m3/kmol molar volume at normal boiling temperature (Treybal 1968) +WC_V_H2 14.3e-3; +WC_V_CO2 34e-3; +WC_V_CO 30.7e-3; +WC_V_N2 31.2e-3; +WC_V_CH4 35e-3; // V_b[cm3/mol]=0.285*V_critical^1.048 (Tyn and Calus; ESTIMATING LIQUID MOLAL VOLUME; Processing, Volume 21, Issue 4, Pages 16 - 17) +//****** diffusion coeff *********** +D_H2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_H2,0.6)"; +D_CO2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CO2,0.6)"; +D_CO #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CO,0.6)"; +D_CH4 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CH4,0.6)"; +D_N2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_N2,0.6)"; +//****** Henry coeff *************** +H_O2_298 0.032; +DH_O2 1700; +H_CO2_298 0.83; +DH_CO2 2400; +H_CO_298 0.023; +DH_CO 1300; +H_H2_298 0.019; +DH_H2 500; +H_CH4_298 0.032; +DH_CH4 1900; +H_N2_298 0.015; +DH_N2 1300; +He_H2 #calc "$H_H2_298 * exp($DH_H2 *(1. / $T0 - 1./298.15))"; +He_CO #calc "$H_CO_298 * exp($DH_CO *(1. / $T0 - 1./298.15))"; +He_CO2 #calc "$H_CO2_298 * exp($DH_CO2 *(1. / $T0 - 1./298.15))"; +He_CH4 #calc "$H_CH4_298 * exp($DH_CH4 *(1. / $T0 - 1./298.15))"; +He_N2 #calc "$H_N2_298 * exp($DH_N2 *(1. / $T0 - 1./298.15))"; +//*******inlet gas frac************* +f_H2 0.1; +f_CO2 0.9; +f_N2 0.0; +//*******inlet gas frac************* +inletA 0.0039; +liqVol 0.003625; +alphaGas 1; +alphaLiq 0; +uGasPhase #calc "$liqVol * $VVM / (60 * $inletA * $alphaGas)"; +//********************************* +LeLiqH2 #calc "$kThermLiq / $rho0MixLiq / $D_H2 / $CpMixLiq"; +LeLiqCO #calc "$kThermLiq / $rho0MixLiq / $D_CO / $CpMixLiq"; +LeLiqCO2 #calc "$kThermLiq / $rho0MixLiq / $D_CO2 / $CpMixLiq"; // = 74 +LeLiqCH4 #calc "$kThermLiq / $rho0MixLiq / $D_CH4 / $CpMixLiq"; +LeLiqN2 #calc "$kThermLiq / $rho0MixLiq / $D_N2 / $CpMixLiq"; +LeLiqMix #calc "$f_CO2*$LeLiqCO2+$f_H2*$LeLiqH2"; +PrMixLiq #calc "$CpMixLiq * $muMixLiq / $kThermLiq"; +//********************************* +kH2 #calc "$D_H2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrH2 #calc "$muMixLiq*$CpMixLiq / $kH2"; + +kCO #calc "$D_CO*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCO #calc "$muMixLiq*$CpMixLiq / $kCO"; + +kCO2 #calc "$D_CO2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCO2 #calc "$muMixLiq*$CpMixLiq / $kCO2"; + +kCH4 #calc "$D_CH4*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCH4 #calc "$muMixLiq*$CpMixLiq / $kCH4"; + +kN2 #calc "$D_N2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrN2 #calc "$muMixLiq*$CpMixLiq / $kN2"; +//********************************* +l_scale 0.5; +intensity 0.05; +k_inlet_gas #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)"; +k_inlet_liq #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)"; +eps_inlet_gas #calc "pow(0.09,0.75) * Foam::pow($k_inlet_gas, 1.5) / ($l_scale * 0.07)"; +eps_inlet_liq #calc "pow(0.09,0.75) * Foam::pow($k_inlet_liq, 1.5) / ($l_scale * 0.07)"; +omega_inlet_gas #calc "pow(0.09,-0.25) * pow($k_inlet_gas,0.5) / ($l_scale * 0.07)"; +omega_inlet_liq #calc "pow(0.09,-0.25) * pow($k_inlet_liq,0.5) / ($l_scale * 0.07)"; diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/globalVars_temp b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/globalVars_temp similarity index 99% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/globalVars_temp rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/globalVars_temp index fa630bea..fcb076a7 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/globalVars_temp +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/globalVars_temp @@ -1,5 +1,5 @@ T0 300; //initial T(K) which stays constant -VVM 0.4; +VVM 0.2; //****water Liquid properties************** CpMixLiq 4181; muMixLiq #calc "2.414e-5 * pow(10,247.8/($T0 - 140.0))"; //viscosity (Pa.s) of water as a function of T(K) @@ -42,7 +42,6 @@ He_N2 #calc "$H_N2_298 * exp($DH_N2 *(1. / $T0 - 1./298.15))"; //*******inlet gas frac************* f_H2 0.1; f_CO2 0.9; -f_CH4 0.0; f_N2 0.0; //*******inlet gas frac************* inletA ; diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/momentumTransport.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/momentumTransport.gas similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/momentumTransport.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/momentumTransport.gas diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/momentumTransport.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/momentumTransport.liquid similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/momentumTransport.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/momentumTransport.liquid diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties similarity index 76% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties index 1f6d4671..a3c90f5a 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties @@ -15,34 +15,62 @@ FoamFile #include "$FOAM_CASE/constant/globalVars" -type interfaceCompositionPhaseChangeMultiphaseSystem; +type interfaceCompositionPhaseChangePopulationBalanceMultiphaseSystem; phases (gas liquid); +populationBalances (bubbles); gas { type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel velocityGroup; - diameterModel constant; - - constantCoeffs + velocityGroupCoeffs { - d 3e-3; + populationBalance bubbles; + + shapeModel spherical; + + sizeGroups + ( + f1 {dSph 1.4e-3; value 0.0;} + f2 {dSph 1.8e-3; value 0.0;} + f3 {dSph 2.2e-3; value 0.0;} + f4 {dSph 2.6e-3; value 0.0;} + f5 {dSph 3e-3; value 1.0;} + f6 {dSph 3.4e-3; value 0.0;} + f7 {dSph 3.8e-3; value 0.0;} + f8 {dSph 4.2e-3; value 0.0;} + f9 {dSph 4.6e-3; value 0.0;} + f10 {dSph 5.0e-3; value 0.0;} + ); } + residualAlpha 1e-6; + Sc 0.7; } - liquid { - type reactingPhaseModel; + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + diameterModel constant; + constantCoeffs { d 1e-4; } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + residualAlpha 1e-6; } @@ -79,16 +107,7 @@ populationBalanceCoeffs ); nucleationModels - ( - reactionDriven - { - nucleationDiameter 3.0e-3; - velocityGroup gas; - reactingPhase liquid; - dmdtf phaseTransfer:dmidtf; - specie CH4; - } - ); + (); } } @@ -141,8 +160,8 @@ drag ( (gas in liquid) { - //type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign - type IshiiZuber; + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; residualRe 1e-3; swarmCorrection { @@ -201,8 +220,8 @@ interfaceComposition.liquid (liquid and gas) { type Henry; - species ( CO2 H2 CH4 ); - k ( $He_CO2 $He_H2 $He_CH4 ); + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); Le $LeLiqMix; } ); @@ -214,8 +233,8 @@ diffusiveMassTransfer.liquid ( (gas in liquid) { - //type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign - type Frossling; + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; Le $LeLiqMix; } @@ -227,15 +246,7 @@ diffusiveMassTransfer.liquid ); phaseTransfer -( - (gas in liquid) - { - type reactionDriven; - reactingPhase liquid; - targetPhase gas; - species (CH4); - } -); +(); lift ( diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties_constantd b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties_constantd new file mode 100644 index 00000000..e029df99 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties_constantd @@ -0,0 +1,261 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object phaseProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "$FOAM_CASE/constant/globalVars" + +type interfaceCompositionPhaseChangeMultiphaseSystem; + +phases (gas liquid); + +gas +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 3e-3; + } + residualAlpha 1e-6; + Sc 0.7; +} + +liquid +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 1e-4; + } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + + residualAlpha 1e-6; +} + +populationBalanceCoeffs +{ + bubbles + { + continuousPhase liquid; + + coalescenceModels + (); + + binaryBreakupModels + (); + + breakupModels + (); + + driftModels + (); + + nucleationModels + (); + } +} + +blending +{ + default + { + type linear; + minFullyContinuousAlpha.gas 0.7; + minPartlyContinuousAlpha.gas 0.3; + minFullyContinuousAlpha.liquid 0.7; + minPartlyContinuousAlpha.liquid 0.3; + } + heatTransfer + { + type linear; + minFullyContinuousAlpha.gas 1; + minPartlyContinuousAlpha.gas 0; + minFullyContinuousAlpha.liquid 1; + minPartlyContinuousAlpha.liquid 0; + } + massTransfer + { + $heatTransfer; + } +} + +surfaceTension +( + (gas and liquid) + { + type constant; + sigma $sigmaLiq; + } +); + +interfaceCompression +(); + +aspectRatio +( + (gas in liquid) + { + type Wellek; + } +); + + +drag +( + (gas in liquid) + { + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; + residualRe 1e-3; + swarmCorrection + { + type none; + } + } +); + +virtualMass +( + (gas in liquid) + { + type constantCoefficient; + Cvm 0.5; + } +); + +// heatTransfer +// (); + +heatTransfer.gas +( + (gas in liquid) + { + type spherical; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type RanzMarshall; + residualAlpha 1e-4; + } +); + +heatTransfer.liquid +( + (gas in liquid) + { + type RanzMarshall; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type spherical; + residualAlpha 1e-4; + } +); + +interfaceComposition.gas +(); + +interfaceComposition.liquid +( + (liquid and gas) + { + type Henry; + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); + Le $LeLiqMix; + } +); + +diffusiveMassTransfer.gas +(); + +diffusiveMassTransfer.liquid +( + (gas in liquid) + { + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; + Le $LeLiqMix; + } + + (liquid in gas) + { + type spherical; + Le 1.0; //not used for spherical + } +); + +phaseTransfer +(); + +lift +( + (gas in liquid) + { + type wallDamped; + + wallDamping + { + type cosine; + Cd 3.0; + } + + lift + { + type Tomiyama; + + swarmCorrection + { + type none; + } + } + } + +); + +wallLubrication +( + (gas in liquid) + { + type Antal; + Cw1 -0.01; + Cw2 0.05; + } +); + +turbulentDispersion +( + (gas in liquid) + { + type Burns; + sigma 0.9; + } +); + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties_pbe b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties_pbe similarity index 84% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties_pbe rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties_pbe index 458ede6d..a3c90f5a 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties_pbe +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/phaseProperties_pbe @@ -55,12 +55,22 @@ gas liquid { - type reactingPhaseModel; + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + diameterModel constant; + constantCoeffs { d 1e-4; } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + residualAlpha 1e-6; } @@ -97,16 +107,7 @@ populationBalanceCoeffs ); nucleationModels - ( - reactionDriven - { - nucleationDiameter 3.0e-3; - velocityGroup gas; - reactingPhase liquid; - dmdtf phaseTransfer:dmidtf; - specie CH4; - } - ); + (); } } @@ -159,8 +160,8 @@ drag ( (gas in liquid) { - //type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign - type IshiiZuber; + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; residualRe 1e-3; swarmCorrection { @@ -219,8 +220,8 @@ interfaceComposition.liquid (liquid and gas) { type Henry; - species ( CO2 H2 CH4 ); - k ( $He_CO2 $He_H2 $He_CH4 ); + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); Le $LeLiqMix; } ); @@ -232,8 +233,8 @@ diffusiveMassTransfer.liquid ( (gas in liquid) { - //type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign - type Frossling; + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; Le $LeLiqMix; } @@ -245,15 +246,7 @@ diffusiveMassTransfer.liquid ); phaseTransfer -( - (gas in liquid) - { - type reactionDriven; - reactingPhase liquid; - targetPhase gas; - species (CH4); - } -); +(); lift ( diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/thermophysicalProperties.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/thermophysicalProperties.gas similarity index 84% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/thermophysicalProperties.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/thermophysicalProperties.gas index b26dedb3..11b1c4b9 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/thermophysicalProperties.gas +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/thermophysicalProperties.gas @@ -31,39 +31,11 @@ species ( H2 CO2 - water - CH4 N2 ); defaultSpecie N2; -CH4 -{ - specie - { - molWeight 16.04303; - } - thermodynamics - { - Tlow 200; - Thigh 3500; - Tcommon 1000; - highCpCoeffs ( 0.074851495 0.0133909467 -5.73285809e-06 1.22292535e-09 -1.0181523e-13 -9468.34459 18.437318 ); - lowCpCoeffs ( 5.14987613 -0.0136709788 4.91800599e-05 -4.84743026e-08 1.66693956e-11 -10246.6476 -4.64130376 ); - } - transport - { - As 1.512e-06; - Ts 120; - } - elements - { - C 1; - H 4; - } -} - CO2 { specie diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/thermophysicalProperties.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/thermophysicalProperties.liquid similarity index 86% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/thermophysicalProperties.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/thermophysicalProperties.liquid index c1141906..d324ec51 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/thermophysicalProperties.liquid +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/constant/thermophysicalProperties.liquid @@ -30,7 +30,6 @@ thermoType species ( - CH4 CO2 water H2 @@ -105,28 +104,5 @@ H2 } -CH4 -{ - specie - { - molWeight 16.04; - } - equationOfState - { - rho $rho0MixLiq; - } - thermodynamics - { - Cp $CpMixLiq; - Hf -1.5879e+07;//-9402451; - } - transport - { - mu $muMixLiq; - Pr $PrCH4; - } -} - - // ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/get_qoi.py b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/get_qoi.py new file mode 100644 index 00000000..9562cc65 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/get_qoi.py @@ -0,0 +1,183 @@ +import json +import os +import pickle as pkl + +import matplotlib as mpl +import numpy as np +from prettyPlot.plotting import * +from scipy.optimize import curve_fit + + +def get_sim_folds(path): + folds = os.listdir(path) + sim_folds = [] + for fold in folds: + if fold.startswith("loop"): + sim_folds.append(fold) + return sim_folds + + +def func(t, cstar, kla): + t = t + t0 = 0 + c0 = 0 + return (cstar - c0) * (1 - np.exp(-kla * (t - t0))) + c0 + + +def get_vl(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("liqVol"): + vol = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read liqVol = {vol}m3") + return vol + + +def get_vvm(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("VVM"): + vvm = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read VVM = {vvm} [-]") + return vvm + + +def get_As(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("inletA"): + As = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read As = {As}m2") + return As + + +def get_pmix(verb=False): + with open("system/mixers.json", "r+") as f: + data = json.load(f) + mixer_list = data["mixers"] + pmix = 0 + for mix in mixer_list: + pmix += mix["power"] / 1000 + if verb: + print(f"Read Mixing power = {pmix}kW") + return pmix + + +def get_lh(verb=False): + filename = os.path.join("system", "setFieldsDict") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if "box (-1.0 -1.0 -1.0)" in line: + height = float(line.split("(")[2].split()[1]) + break + if verb: + print(f"Read Height = {height}m") + return height + + +def get_pinj(vvm, Vl, As, lh): + rhog = 1.25 # kg /m3 + Vg = Vl * vvm / (60 * As * 1) # m/s + Ptank = 101325 # Pa + # Ptank = 0 # Pa + rhoL = 1000 # kg / m3 + Pl = 101325 + rhoL * 9.8 * lh # Pa + # W + P1 = rhog * As * Vg**3 + # W + P2 = (Pl - Ptank) * As * Vg + # kg /s + MF = rhog * Vg * As + # kwh / kg + e_m = (P1 + P2) / (3600 * 1000 * MF) + + # returns kW + return (P1 + P2) * 1e-3 + + +def get_qoi(kla_co2, cs_co2, kla_h2, cs_h2, verb=False): + vvm = get_vvm(verb) + As = get_As(verb) + V_l = get_vl(verb) + liqh = get_lh(verb) + P_inj = get_pinj(vvm, V_l, As, liqh) + P_mix = get_pmix(verb) + + qoi_co2 = kla_co2 * cs_co2 * V_l * 0.04401 / (P_mix / 3600 + P_inj / 3600) + qoi_h2 = kla_h2 * cs_h2 * V_l * 0.002016 / (P_mix / 3600 + P_inj / 3600) + return qoi_co2 * qoi_h2 + + +def get_qoi_uq(kla_co2, cs_co2, kla_h2, cs_h2): + qoi = [] + for i in range(len(kla_co2)): + if i == 0: + verb = True + else: + verb = False + qoi.append(get_qoi(kla_co2[i], cs_co2[i], kla_h2[i], cs_h2[i], verb)) + qoi = np.array(qoi) + return np.mean(qoi), np.std(qoi) + + +os.makedirs("Figures", exist_ok=True) + +dataFolder = "data" +fold = "local" + +nuq = 100 +mean_cstar_co2 = np.random.uniform(12.6, 13.3, nuq) +mean_cstar_h2 = np.random.uniform(0.902, 0.96, nuq) + + +tmp_cs_h2 = [] +tmp_cs_co2 = [] +tmp_kla_h2 = [] +tmp_kla_co2 = [] +cs_co2 = mean_cstar_co2 +cs_h2 = mean_cstar_h2 + +a = np.load(os.path.join(dataFolder, fold, "conv.npz")) +endindex = -1 +if ( + "c_h2" in a + and "c_co2" in a + and len(a["time"][:endindex] > 0) + and (a["time"][:endindex][-1] > 95) +): + for i in range(nuq): + fitparamsH2, _ = curve_fit( + func, + np.array(a["time"][:endindex]), + np.array(a["c_h2"][:endindex]), + bounds=[(cs_h2[i] - 1e-6, 0), (cs_h2[i] + 1e-6, 1)], + ) + fitparamsCO2, _ = curve_fit( + func, + np.array(a["time"][:endindex]), + np.array(a["c_co2"][:endindex]), + bounds=[(cs_co2[i] - 1e-6, 0), (cs_co2[i] + 1e-6, 1)], + ) + tmp_kla_co2.append(fitparamsCO2[1]) + tmp_kla_h2.append(fitparamsH2[1]) + tmp_cs_h2.append(cs_h2[i]) + tmp_cs_co2.append(cs_co2[i]) + +qoi_m, qoi_s = get_qoi_uq(tmp_kla_co2, tmp_cs_co2, tmp_kla_h2, tmp_cs_h2) + + +with open("qoi.txt", "w+") as f: + f.write(f"{qoi_m},{qoi_s}\n") diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/presteps.sh b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/presteps.sh new file mode 100644 index 00000000..899655b8 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/presteps.sh @@ -0,0 +1,71 @@ +# Clean case +module load anaconda3/2023 +conda activate /projects/gas2fuels/conda_env/bird +source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc +./Allclean + +echo PRESTEP 1 +# Generate blockmeshDict +python /projects/gas2fuels/BioReactorDesign/applications/write_block_rect_mesh.py -i system/mesh.json -o system +#python ../../../applications/write_block_rect_mesh.py -i system/mesh.json -o system + +# Generate boundary stl +python /projects/gas2fuels/BioReactorDesign/applications/write_stl_patch.py -i system/inlets_outlets.json +#python ../../../applications/write_stl_patch.py -i system/inlets_outlets.json + +# Generate mixers +python /projects/gas2fuels/BioReactorDesign/applications/write_dynMix_fvModels_force_sign.py -i system/mixers.json -o constant +#python ../../../applications/write_dynMix_fvModels.py -i system/mixers.json -o constant + +echo PRESTEP 2 +# Mesh gen +blockMesh -dict system/blockMeshDict + +# Inlet BC +surfaceToPatch -tol 1e-3 inlets.stl +export newmeshdir=$(foamListTimes -latestTime) +rm -rf constant/polyMesh/ +cp -r $newmeshdir/polyMesh ./constant +rm -rf $newmeshdir +cp constant/polyMesh/boundary /tmp +sed -i -e 's/inlets\.stl/inlet/g' /tmp/boundary +cat /tmp/boundary > constant/polyMesh/boundary + +# Outlet BC +surfaceToPatch -tol 1e-3 outlets.stl +export newmeshdir=$(foamListTimes -latestTime) +rm -rf constant/polyMesh/ +cp -r $newmeshdir/polyMesh ./constant +rm -rf $newmeshdir +cp constant/polyMesh/boundary /tmp +sed -i -e 's/outlets\.stl/outlet/g' /tmp/boundary +cat /tmp/boundary > constant/polyMesh/boundary + + +# Scale +transformPoints "scale=(0.05 0.05 0.05)" + + +# setup IC +cp -r 0.orig 0 +setFields + +# Setup mass flow rate +# Get inlet area +postProcess -func 'patchIntegrate(patch="inlet", field="alpha.gas")' +postProcess -func writeCellVolumes +writeMeshObj + +echo PRESTEP 3 +python writeGlobalVars.py +cp constant/phaseProperties_constantd constant/phaseProperties + + +if [ -f qoi.txt ]; then + rm qoi.txt +fi +if [ -f data/local/conv.npz ]; then + rm data/local/conv.npz +fi + +conda deactivate diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/read_history.py b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/read_history.py new file mode 100644 index 00000000..264711f8 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/read_history.py @@ -0,0 +1,239 @@ +import argparse +import os +import sys + +import numpy as np +from prettyPlot.plotting import plt, pretty_labels + +from bird.utilities.ofio import * + + +def compute_gas_holdup(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + alpha_liq = field_dict["alpha_liq"] + volume = field_dict["volume"] + holdup = np.sum((1 - alpha_liq) * volume) / np.sum(volume) + return holdup, field_dict + + +def co2liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("co2_liq" in field_dict) or field_dict["co2_liq"] is None: + co2_liq_file = os.path.join(caseFolder, timeFolder, "CO2.liquid") + co2_liq = readOFScal(co2_liq_file, nCells) + # print("computing co2 liq") + field_dict["co2_liq"] = co2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + co2_liq = field_dict["co2_liq"] + met = np.sum( + alpha_liq[indliq] * co2_liq[indliq] * volume[indliq] + ) / np.sum(volume[indliq]) + return met, field_dict + + +def cliq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("rho_liq" in field_dict) or field_dict["rho_liq"] is None: + rho_liq_file = os.path.join(caseFolder, timeFolder, "rhom") + rho_liq = readOFScal(rho_liq_file, nCells) + field_dict["rho_liq"] = rho_liq + if not ("co2_liq" in field_dict) or field_dict["co2_liq"] is None: + co2_liq_file = os.path.join(caseFolder, timeFolder, "CO2.liquid") + co2_liq = readOFScal(co2_liq_file, nCells) + # print("computing co2 liq") + field_dict["co2_liq"] = co2_liq + if not ("h2_liq" in field_dict) or field_dict["h2_liq"] is None: + h2_liq_file = os.path.join(caseFolder, timeFolder, "H2.liquid") + h2_liq = readOFScal(h2_liq_file, nCells) + # print("computing h2 liq") + field_dict["h2_liq"] = h2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + co2_liq = field_dict["co2_liq"] + h2_liq = field_dict["h2_liq"] + rho_liq = field_dict["rho_liq"] + + # c_h2 = rho_liq[indliq] * alpha_liq[indliq] * h2_liq[indliq] / 0.002016 + # c_co2 = rho_liq[indliq] * alpha_liq[indliq] * co2_liq[indliq] / 0.04401 + + c_h2 = 1000 * alpha_liq[indliq] * h2_liq[indliq] / 0.002016 + c_co2 = 1000 * alpha_liq[indliq] * co2_liq[indliq] / 0.04401 + + c_h2 = np.sum(c_h2 * volume[indliq]) / np.sum(volume[indliq]) + c_co2 = np.sum(c_co2 * volume[indliq]) / np.sum(volume[indliq]) + + return c_co2, c_h2, field_dict + + +def h2liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("h2_liq" in field_dict) or field_dict["h2_liq"] is None: + h2_liq_file = os.path.join(caseFolder, timeFolder, "H2.liquid") + h2_liq = readOFScal(h2_liq_file, nCells) + # print("computing h2 liq") + field_dict["h2_liq"] = h2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + h2_liq = field_dict["h2_liq"] + met = np.sum(alpha_liq[indliq] * h2_liq[indliq] * volume[indliq]) / np.sum( + volume[indliq] + ) + return met, field_dict + + +def vol_liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + volume = field_dict["volume"] + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.0) + liqvol = np.sum(alpha_liq[indliq] * volume[indliq]) / np.sum( + volume[indliq] + ) + return liqvol, field_dict + + +parser = argparse.ArgumentParser(description="Convergence of GH") +parser.add_argument( + "-cn", + "--case_name", + type=str, + metavar="", + required=True, + help="Case name", +) +parser.add_argument( + "-df", + "--data_folder", + type=str, + metavar="", + required=False, + help="data folder name", + default="data", +) + +args, unknown = parser.parse_known_args() + + +case_root = "." # "../" +case_name = args.case_name # "12_hole_sparger_snappyRefine_700rpm_opt_coeff" +case_path = "." +dataFolder = args.data_folder + +if os.path.isfile(os.path.join(dataFolder, case_name, "conv.npz")): + sys.exit("WARNING: History already created, Skipping") + +time_float_sorted, time_str_sorted = getCaseTimes(case_path, remove_zero=True) +cellCentres = readMesh(os.path.join(case_path, f"meshCellCentres_0.obj")) +nCells = len(cellCentres) + + +co2_history = np.zeros(len(time_str_sorted)) +c_co2_history = np.zeros(len(time_str_sorted)) +h2_history = np.zeros(len(time_str_sorted)) +c_h2_history = np.zeros(len(time_str_sorted)) +gh_history = np.zeros(len(time_str_sorted)) +liqvol_history = np.zeros(len(time_str_sorted)) +print(f"case_path = {case_path}") +field_dict = {} +for itime, time in enumerate(time_float_sorted): + time_folder = time_str_sorted[itime] + print(f"\tTime : {time_folder}") + if not field_dict == {}: + new_field_dict = {} + if "volume" in field_dict: + new_field_dict["volume"] = field_dict["volume"] + field_dict = new_field_dict + gh_history[itime], field_dict = compute_gas_holdup( + case_path, time_str_sorted[itime], nCells, field_dict + ) + co2_history[itime], field_dict = co2liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + h2_history[itime], field_dict = h2liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + liqvol_history[itime], field_dict = vol_liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + c_co2_history[itime], c_h2_history[itime], field_dict = cliq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + + +os.makedirs(dataFolder, exist_ok=True) +os.makedirs(os.path.join(dataFolder, case_name), exist_ok=True) +np.savez( + os.path.join(dataFolder, case_name, "conv.npz"), + time=np.array(time_float_sorted), + gh=gh_history, + co2=co2_history, + h2=h2_history, + vol_liq=liqvol_history, + c_h2=c_h2_history, + c_co2=c_co2_history, +) diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/run.sh b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/run.sh new file mode 100644 index 00000000..6b7eb516 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/run.sh @@ -0,0 +1,5 @@ +multiphaseEulerFoam + + + + diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/script b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/script new file mode 100755 index 00000000..090e5c05 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/script @@ -0,0 +1,14 @@ +#!/bin/bash +#SBATCH --qos=high +#SBATCH --job-name=val2 +##SBATCH --partition=debug +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=16 +#SBATCH --time=07:59:00 +#SBATCH --account=co2snow + +bash presteps.sh +source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc +decomposePar -fileHandler collated +srun -n 16 multiphaseEulerFoam -parallel -fileHandler collated +reconstructPar -newTimes diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/script_post b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/script_post new file mode 100755 index 00000000..aabbc33e --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/script_post @@ -0,0 +1,10 @@ +#!/bin/bash +#SBATCH --qos=high +#SBATCH --job-name=val2 +##SBATCH --partition=debug +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=16 +#SBATCH --time=00:59:00 +#SBATCH --account=co2snow + +bash computeQOI.sh diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/blockMeshDict b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/blockMeshDict similarity index 62% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/blockMeshDict rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/blockMeshDict index 0bb60950..1183d262 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/blockMeshDict +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/blockMeshDict @@ -100,50 +100,6 @@ vertices ( 8.0 7.0 0.0) ( 9.0 7.0 0.0) ( 10.0 7.0 0.0) -( 0.0 8.0 0.0) -( 1.0 8.0 0.0) -( 2.0 8.0 0.0) -( 3.0 8.0 0.0) -( 4.0 8.0 0.0) -( 5.0 8.0 0.0) -( 6.0 8.0 0.0) -( 7.0 8.0 0.0) -( 8.0 8.0 0.0) -( 9.0 8.0 0.0) -( 10.0 8.0 0.0) -( 0.0 9.0 0.0) -( 1.0 9.0 0.0) -( 2.0 9.0 0.0) -( 3.0 9.0 0.0) -( 4.0 9.0 0.0) -( 5.0 9.0 0.0) -( 6.0 9.0 0.0) -( 7.0 9.0 0.0) -( 8.0 9.0 0.0) -( 9.0 9.0 0.0) -( 10.0 9.0 0.0) -( 0.0 10.0 0.0) -( 1.0 10.0 0.0) -( 2.0 10.0 0.0) -( 3.0 10.0 0.0) -( 4.0 10.0 0.0) -( 5.0 10.0 0.0) -( 6.0 10.0 0.0) -( 7.0 10.0 0.0) -( 8.0 10.0 0.0) -( 9.0 10.0 0.0) -( 10.0 10.0 0.0) -( 0.0 11.0 0.0) -( 1.0 11.0 0.0) -( 2.0 11.0 0.0) -( 3.0 11.0 0.0) -( 4.0 11.0 0.0) -( 5.0 11.0 0.0) -( 6.0 11.0 0.0) -( 7.0 11.0 0.0) -( 8.0 11.0 0.0) -( 9.0 11.0 0.0) -( 10.0 11.0 0.0) ( 0.0 0.0 1.0) ( 1.0 0.0 1.0) ( 2.0 0.0 1.0) @@ -232,50 +188,6 @@ vertices ( 8.0 7.0 1.0) ( 9.0 7.0 1.0) ( 10.0 7.0 1.0) -( 0.0 8.0 1.0) -( 1.0 8.0 1.0) -( 2.0 8.0 1.0) -( 3.0 8.0 1.0) -( 4.0 8.0 1.0) -( 5.0 8.0 1.0) -( 6.0 8.0 1.0) -( 7.0 8.0 1.0) -( 8.0 8.0 1.0) -( 9.0 8.0 1.0) -( 10.0 8.0 1.0) -( 0.0 9.0 1.0) -( 1.0 9.0 1.0) -( 2.0 9.0 1.0) -( 3.0 9.0 1.0) -( 4.0 9.0 1.0) -( 5.0 9.0 1.0) -( 6.0 9.0 1.0) -( 7.0 9.0 1.0) -( 8.0 9.0 1.0) -( 9.0 9.0 1.0) -( 10.0 9.0 1.0) -( 0.0 10.0 1.0) -( 1.0 10.0 1.0) -( 2.0 10.0 1.0) -( 3.0 10.0 1.0) -( 4.0 10.0 1.0) -( 5.0 10.0 1.0) -( 6.0 10.0 1.0) -( 7.0 10.0 1.0) -( 8.0 10.0 1.0) -( 9.0 10.0 1.0) -( 10.0 10.0 1.0) -( 0.0 11.0 1.0) -( 1.0 11.0 1.0) -( 2.0 11.0 1.0) -( 3.0 11.0 1.0) -( 4.0 11.0 1.0) -( 5.0 11.0 1.0) -( 6.0 11.0 1.0) -( 7.0 11.0 1.0) -( 8.0 11.0 1.0) -( 9.0 11.0 1.0) -( 10.0 11.0 1.0) ( 0.0 0.0 2.0) ( 1.0 0.0 2.0) ( 2.0 0.0 2.0) @@ -364,50 +276,6 @@ vertices ( 8.0 7.0 2.0) ( 9.0 7.0 2.0) ( 10.0 7.0 2.0) -( 0.0 8.0 2.0) -( 1.0 8.0 2.0) -( 2.0 8.0 2.0) -( 3.0 8.0 2.0) -( 4.0 8.0 2.0) -( 5.0 8.0 2.0) -( 6.0 8.0 2.0) -( 7.0 8.0 2.0) -( 8.0 8.0 2.0) -( 9.0 8.0 2.0) -( 10.0 8.0 2.0) -( 0.0 9.0 2.0) -( 1.0 9.0 2.0) -( 2.0 9.0 2.0) -( 3.0 9.0 2.0) -( 4.0 9.0 2.0) -( 5.0 9.0 2.0) -( 6.0 9.0 2.0) -( 7.0 9.0 2.0) -( 8.0 9.0 2.0) -( 9.0 9.0 2.0) -( 10.0 9.0 2.0) -( 0.0 10.0 2.0) -( 1.0 10.0 2.0) -( 2.0 10.0 2.0) -( 3.0 10.0 2.0) -( 4.0 10.0 2.0) -( 5.0 10.0 2.0) -( 6.0 10.0 2.0) -( 7.0 10.0 2.0) -( 8.0 10.0 2.0) -( 9.0 10.0 2.0) -( 10.0 10.0 2.0) -( 0.0 11.0 2.0) -( 1.0 11.0 2.0) -( 2.0 11.0 2.0) -( 3.0 11.0 2.0) -( 4.0 11.0 2.0) -( 5.0 11.0 2.0) -( 6.0 11.0 2.0) -( 7.0 11.0 2.0) -( 8.0 11.0 2.0) -( 9.0 11.0 2.0) -( 10.0 11.0 2.0) ( 0.0 0.0 3.0) ( 1.0 0.0 3.0) ( 2.0 0.0 3.0) @@ -496,50 +364,6 @@ vertices ( 8.0 7.0 3.0) ( 9.0 7.0 3.0) ( 10.0 7.0 3.0) -( 0.0 8.0 3.0) -( 1.0 8.0 3.0) -( 2.0 8.0 3.0) -( 3.0 8.0 3.0) -( 4.0 8.0 3.0) -( 5.0 8.0 3.0) -( 6.0 8.0 3.0) -( 7.0 8.0 3.0) -( 8.0 8.0 3.0) -( 9.0 8.0 3.0) -( 10.0 8.0 3.0) -( 0.0 9.0 3.0) -( 1.0 9.0 3.0) -( 2.0 9.0 3.0) -( 3.0 9.0 3.0) -( 4.0 9.0 3.0) -( 5.0 9.0 3.0) -( 6.0 9.0 3.0) -( 7.0 9.0 3.0) -( 8.0 9.0 3.0) -( 9.0 9.0 3.0) -( 10.0 9.0 3.0) -( 0.0 10.0 3.0) -( 1.0 10.0 3.0) -( 2.0 10.0 3.0) -( 3.0 10.0 3.0) -( 4.0 10.0 3.0) -( 5.0 10.0 3.0) -( 6.0 10.0 3.0) -( 7.0 10.0 3.0) -( 8.0 10.0 3.0) -( 9.0 10.0 3.0) -( 10.0 10.0 3.0) -( 0.0 11.0 3.0) -( 1.0 11.0 3.0) -( 2.0 11.0 3.0) -( 3.0 11.0 3.0) -( 4.0 11.0 3.0) -( 5.0 11.0 3.0) -( 6.0 11.0 3.0) -( 7.0 11.0 3.0) -( 8.0 11.0 3.0) -( 9.0 11.0 3.0) -( 10.0 11.0 3.0) ( 0.0 0.0 4.0) ( 1.0 0.0 4.0) ( 2.0 0.0 4.0) @@ -628,50 +452,6 @@ vertices ( 8.0 7.0 4.0) ( 9.0 7.0 4.0) ( 10.0 7.0 4.0) -( 0.0 8.0 4.0) -( 1.0 8.0 4.0) -( 2.0 8.0 4.0) -( 3.0 8.0 4.0) -( 4.0 8.0 4.0) -( 5.0 8.0 4.0) -( 6.0 8.0 4.0) -( 7.0 8.0 4.0) -( 8.0 8.0 4.0) -( 9.0 8.0 4.0) -( 10.0 8.0 4.0) -( 0.0 9.0 4.0) -( 1.0 9.0 4.0) -( 2.0 9.0 4.0) -( 3.0 9.0 4.0) -( 4.0 9.0 4.0) -( 5.0 9.0 4.0) -( 6.0 9.0 4.0) -( 7.0 9.0 4.0) -( 8.0 9.0 4.0) -( 9.0 9.0 4.0) -( 10.0 9.0 4.0) -( 0.0 10.0 4.0) -( 1.0 10.0 4.0) -( 2.0 10.0 4.0) -( 3.0 10.0 4.0) -( 4.0 10.0 4.0) -( 5.0 10.0 4.0) -( 6.0 10.0 4.0) -( 7.0 10.0 4.0) -( 8.0 10.0 4.0) -( 9.0 10.0 4.0) -( 10.0 10.0 4.0) -( 0.0 11.0 4.0) -( 1.0 11.0 4.0) -( 2.0 11.0 4.0) -( 3.0 11.0 4.0) -( 4.0 11.0 4.0) -( 5.0 11.0 4.0) -( 6.0 11.0 4.0) -( 7.0 11.0 4.0) -( 8.0 11.0 4.0) -( 9.0 11.0 4.0) -( 10.0 11.0 4.0) ( 0.0 0.0 5.0) ( 1.0 0.0 5.0) ( 2.0 0.0 5.0) @@ -760,50 +540,6 @@ vertices ( 8.0 7.0 5.0) ( 9.0 7.0 5.0) ( 10.0 7.0 5.0) -( 0.0 8.0 5.0) -( 1.0 8.0 5.0) -( 2.0 8.0 5.0) -( 3.0 8.0 5.0) -( 4.0 8.0 5.0) -( 5.0 8.0 5.0) -( 6.0 8.0 5.0) -( 7.0 8.0 5.0) -( 8.0 8.0 5.0) -( 9.0 8.0 5.0) -( 10.0 8.0 5.0) -( 0.0 9.0 5.0) -( 1.0 9.0 5.0) -( 2.0 9.0 5.0) -( 3.0 9.0 5.0) -( 4.0 9.0 5.0) -( 5.0 9.0 5.0) -( 6.0 9.0 5.0) -( 7.0 9.0 5.0) -( 8.0 9.0 5.0) -( 9.0 9.0 5.0) -( 10.0 9.0 5.0) -( 0.0 10.0 5.0) -( 1.0 10.0 5.0) -( 2.0 10.0 5.0) -( 3.0 10.0 5.0) -( 4.0 10.0 5.0) -( 5.0 10.0 5.0) -( 6.0 10.0 5.0) -( 7.0 10.0 5.0) -( 8.0 10.0 5.0) -( 9.0 10.0 5.0) -( 10.0 10.0 5.0) -( 0.0 11.0 5.0) -( 1.0 11.0 5.0) -( 2.0 11.0 5.0) -( 3.0 11.0 5.0) -( 4.0 11.0 5.0) -( 5.0 11.0 5.0) -( 6.0 11.0 5.0) -( 7.0 11.0 5.0) -( 8.0 11.0 5.0) -( 9.0 11.0 5.0) -( 10.0 11.0 5.0) ); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -811,232 +547,192 @@ blocks ( //block 0 -hex (0 1 12 11 132 133 144 143 ) +hex (0 1 12 11 88 89 100 99 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 1 -hex (1 2 13 12 133 134 145 144 ) +hex (1 2 13 12 89 90 101 100 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 2 -hex (2 3 14 13 134 135 146 145 ) +hex (2 3 14 13 90 91 102 101 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 3 -hex (3 4 15 14 135 136 147 146 ) +hex (3 4 15 14 91 92 103 102 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 4 -hex (4 5 16 15 136 137 148 147 ) +hex (4 5 16 15 92 93 104 103 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 5 -hex (5 6 17 16 137 138 149 148 ) +hex (5 6 17 16 93 94 105 104 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 6 -hex (6 7 18 17 138 139 150 149 ) +hex (6 7 18 17 94 95 106 105 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 7 -hex (7 8 19 18 139 140 151 150 ) +hex (7 8 19 18 95 96 107 106 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 8 -hex (8 9 20 19 140 141 152 151 ) +hex (8 9 20 19 96 97 108 107 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 9 -hex (9 10 21 20 141 142 153 152 ) +hex (9 10 21 20 97 98 109 108 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 10 -hex (141 142 153 152 273 274 285 284 ) +hex (97 98 109 108 185 186 197 196 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 11 -hex (273 274 285 284 405 406 417 416 ) +hex (185 186 197 196 273 274 285 284 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 12 -hex (405 406 417 416 537 538 549 548 ) +hex (273 274 285 284 361 362 373 372 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 13 -hex (537 538 549 548 669 670 681 680 ) +hex (361 362 373 372 449 450 461 460 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 14 -hex (536 537 548 547 668 669 680 679 ) +hex (360 361 372 371 448 449 460 459 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 15 -hex (535 536 547 546 667 668 679 678 ) +hex (359 360 371 370 447 448 459 458 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 16 -hex (534 535 546 545 666 667 678 677 ) +hex (358 359 370 369 446 447 458 457 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 17 -hex (533 534 545 544 665 666 677 676 ) +hex (357 358 369 368 445 446 457 456 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 18 -hex (532 533 544 543 664 665 676 675 ) +hex (356 357 368 367 444 445 456 455 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 19 -hex (531 532 543 542 663 664 675 674 ) +hex (355 356 367 366 443 444 455 454 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 20 -hex (530 531 542 541 662 663 674 673 ) +hex (354 355 366 365 442 443 454 453 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 21 -hex (529 530 541 540 661 662 673 672 ) +hex (353 354 365 364 441 442 453 452 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 22 -hex (528 529 540 539 660 661 672 671 ) +hex (352 353 364 363 440 441 452 451 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 23 -hex (539 540 551 550 671 672 683 682 ) +hex (363 364 375 374 451 452 463 462 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 24 -hex (550 551 562 561 682 683 694 693 ) +hex (374 375 386 385 462 463 474 473 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 25 -hex (561 562 573 572 693 694 705 704 ) +hex (385 386 397 396 473 474 485 484 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 26 -hex (572 573 584 583 704 705 716 715 ) +hex (396 397 408 407 484 485 496 495 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 27 -hex (583 584 595 594 715 716 727 726 ) +hex (407 408 419 418 495 496 507 506 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 28 -hex (594 595 606 605 726 727 738 737 ) +hex (418 419 430 429 506 507 518 517 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 29 -hex (605 606 617 616 737 738 749 748 ) +hex (308 309 320 319 396 397 408 407 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 30 -hex (616 617 628 627 748 749 760 759 ) +hex (220 221 232 231 308 309 320 319 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 31 -hex (627 628 639 638 759 760 771 770 ) +hex (132 133 144 143 220 221 232 231 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 32 -hex (638 639 650 649 770 771 782 781 ) +hex (44 45 56 55 132 133 144 143 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 33 -hex (440 441 452 451 572 573 584 583 ) +hex (55 56 67 66 143 144 155 154 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 34 -hex (308 309 320 319 440 441 452 451 ) +hex (66 67 78 77 154 155 166 165 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 35 -hex (176 177 188 187 308 309 320 319 ) +hex (33 34 45 44 121 122 133 132 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 36 -hex (44 45 56 55 176 177 188 187 ) +hex (22 23 34 33 110 111 122 121 ) ( 10 10 10 ) SimpleGrading (1 1 1) //block 37 -hex (55 56 67 66 187 188 199 198 ) -( 10 10 10 ) -SimpleGrading (1 1 1) - - //block 38 -hex (66 67 78 77 198 199 210 209 ) -( 10 10 10 ) -SimpleGrading (1 1 1) - - //block 39 -hex (77 78 89 88 209 210 221 220 ) -( 10 10 10 ) -SimpleGrading (1 1 1) - - //block 40 -hex (88 89 100 99 220 221 232 231 ) -( 10 10 10 ) -SimpleGrading (1 1 1) - - //block 41 -hex (99 100 111 110 231 232 243 242 ) -( 10 10 10 ) -SimpleGrading (1 1 1) - - //block 42 -hex (110 111 122 121 242 243 254 253 ) -( 10 10 10 ) -SimpleGrading (1 1 1) - - //block 43 -hex (33 34 45 44 165 166 177 176 ) -( 10 10 10 ) -SimpleGrading (1 1 1) - - //block 44 -hex (22 23 34 33 154 155 166 165 ) -( 10 10 10 ) -SimpleGrading (1 1 1) - - //block 45 -hex (11 12 23 22 143 144 155 154 ) +hex (11 12 23 22 99 100 111 110 ) ( 10 10 10 ) SimpleGrading (1 1 1) ); diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/controlDict b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/controlDict new file mode 100644 index 00000000..7374023a --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/controlDict @@ -0,0 +1,67 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application multiphaseEulerFoam; + +startFrom latestTime;//startTime; + +startTime 0; + +stopAt endTime; + +endTime 100; + +deltaT 0.0001; + +writeControl adjustableRunTime; + +writeInterval 2; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.5; + +maxDeltaT 0.0005; + + +functions +{ + + #includeFunc writeObjects(d.gas) + #includeFunc writeObjects(thermo:rho.gas) + #includeFunc writeObjects(thermo:rho.liquid) +} +//functions +//{ +// #includeFunc fieldAverage(U.air, U.water, alpha.air, p) +//} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/decomposeParDict b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/decomposeParDict similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/decomposeParDict rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/decomposeParDict diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvConstraints b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvConstraints new file mode 100644 index 00000000..334f1c8f --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvConstraints @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvConstraints; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +limitp +{ + type limitPressure; + + min 1e4; +} +limitUliq +{ + type limitVelocity; + active yes; + U U.liquid; + selectionMode all; + max 1e1; +} +limitUgas +{ + type limitVelocity; + active yes; + U U.gas; + selectionMode all; + max 2e1; +} +limitTgas +{ + type limitTemperature; + selectionMode all; + min 290; + max 310; + phase gas; +} +limitTliq +{ + type limitTemperature; + selectionMode all; + min 290; + max 310; + phase liquid; +} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvSchemes b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvSchemes similarity index 99% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvSchemes rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvSchemes index 7c2385a9..52e6e13a 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvSchemes +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvSchemes @@ -40,7 +40,6 @@ divSchemes "div\(alphaRhoPhi.*,(K|k|epsilon|omega).*\)" Gauss limitedLinear 1; "div\(alphaPhi.*,f.*\)" Gauss limitedLinear 1; "div\(alphaRhoPhi.*,\(p\|thermo:rho.*\)\)" Gauss limitedLinear 1; - "div\(phim,(k|epsilon)m\)" Gauss upwind; "div\(\(\(\(alpha.*\*thermo:rho.*\)*nuEff.*\)*dev2\(T\(grad\(U.*\)\)\)\)\)" Gauss linear; diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvSolution b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvSolution similarity index 94% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvSolution rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvSolution index 12592abf..2e69fdfa 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvSolution +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/fvSolution @@ -18,8 +18,8 @@ solvers { "alpha.*" { - nAlphaCorr 1; - nAlphaSubCycles 4; + nAlphaCorr 2; + nAlphaSubCycles 5; } bubbles @@ -35,7 +35,7 @@ solvers { solver GAMG; smoother DIC; - tolerance 1e-8; + tolerance 1e-7; relTol 0; } @@ -60,7 +60,8 @@ solvers smoother symGaussSeidel; tolerance 1e-8; relTol 0; - minIter 1; + minIter 0; + maxIter 3; } "f.*" diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/inlets_outlets.json b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/inlets_outlets.json similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/inlets_outlets.json rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/inlets_outlets.json diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/mesh.json b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/mesh.json similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/mesh.json rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/mesh.json diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/mixers.json b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/mixers.json new file mode 100644 index 00000000..0106f58d --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/mixers.json @@ -0,0 +1,29 @@ +{ + "Meshing": { + "Blockwise": { + "x" : 10, + "y" : 10, + "z" : 10 + } + }, + "Geometry": { + "OverallDomain": { + "x" : {"nblocks": 10, "size_per_block": 1.0, "rescale": 0.05}, + "y" : {"nblocks": 11, "size_per_block": 1.0, "rescale": 0.05}, + "z" : {"nblocks": 5, "size_per_block": 1.0, "rescale": 0.05} + }, + "Fluids": [ + [ [0,0,0], [9,0,0] ], + [ [9,0,0], [9,0,4] ], + [ [9,0,4], [0,0,4] ], + [ [0,1,4], [0,4,4] ], + [ [0,4,4], [0,10,4] ], + [ [0,4,4], [0,4,0] ], + [ [0,4,0], [0,10,0] ], + [ [0,4,0], [0,1,0] ] + ] + }, + "mixers": [ + {"branch_id": 2, "frac_space": 0.5, "start_time": 1, "power": 2.5, "sign": "+"} + ] +} diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/setFieldsDict b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/setFieldsDict new file mode 100644 index 00000000..7faaeb15 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/system/setFieldsDict @@ -0,0 +1,37 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha.gas 0.99 + volScalarFieldValue alpha.liquid 0.01 +); + +regions +( + boxToCell + { + box (-1.0 -1.0 -1.0) (10 0.2 10.0); + fieldValues + ( + volScalarFieldValue alpha.gas 0.01 + volScalarFieldValue alpha.liquid 0.99 + ); + } +); + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/writeGlobalVars.py b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/writeGlobalVars.py similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/writeGlobalVars.py rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch/writeGlobalVars.py diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/.vim/.netrwhist b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/.vim/.netrwhist new file mode 100644 index 00000000..b9691c3b --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/.vim/.netrwhist @@ -0,0 +1,3 @@ +let g:netrw_dirhistmax =10 +let g:netrw_dirhistcnt =1 +let g:netrw_dirhist_1='/home/openfoam/postProcessing/patchIntegrate(patch=inlet,field=alpha.gas)/0' diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CH4.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/CO2.gas similarity index 94% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CH4.gas rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/CO2.gas index 70655866..e4165b1a 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CH4.gas +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/CO2.gas @@ -9,7 +9,7 @@ FoamFile { format ascii; class volScalarField; - object CH4.gas; + object CO2.gas; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; @@ -26,7 +26,7 @@ boundaryField inlet { type fixedValue; - value uniform $f_CH4; + value uniform $f_CO2; } outlet diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CH4.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/CO2.liquid similarity index 97% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CH4.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/CO2.liquid index 9d867e84..4b8ea6a0 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/CH4.liquid +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/CO2.liquid @@ -9,7 +9,7 @@ FoamFile { format ascii; class volScalarField; - object CH4.liquid; + object CO2.liquid; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/H2.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/H2.gas new file mode 100644 index 00000000..9f66b2d2 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/H2.gas @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object H2.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +dimensions [0 0 0 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform 0; + + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform $f_H2; + } + + outlet + { + //type inletOutlet; + //phi phi.gas; + //inletValue $f_H2; + //value $f_H2; + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/water.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/H2.liquid similarity index 94% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/water.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/H2.liquid index 60f35905..65ae8d34 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/water.liquid +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/H2.liquid @@ -9,13 +9,13 @@ FoamFile { format ascii; class volScalarField; - object water.liquid; + object H2.liquid; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; -internalField uniform 1.0; +internalField uniform 0.0; boundaryField { diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/N2.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/N2.gas new file mode 100644 index 00000000..c1d7225f --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/N2.gas @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object N2.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +dimensions [0 0 0 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform 1; + + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform $f_N2; + } + + outlet + { + //type inletOutlet; + //phi phi.gas; + //inletValue $f_N2; + //value $f_N2; + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/T.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/T.gas new file mode 100644 index 00000000..bf0199a0 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/T.gas @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object T.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 300; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value $internalField; + } + + outlet + { + type inletOutlet; + phi phi.gas; + inletValue $internalField; + value $internalField; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/T.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/T.liquid new file mode 100644 index 00000000..7101ea31 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/T.liquid @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object T.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 300; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + outlet + { + type inletOutlet; + phi phi.liquid; + inletValue $internalField; + value $internalField; + } + inlet + { + type fixedValue; + value $internalField; + } + defaultFaces + { + type zeroGradient; + } + +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/U.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/U.gas new file mode 100644 index 00000000..e696566f --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/U.gas @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volVectorField; + object U.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0.0 0); + +#include "${FOAM_CASE}/constant/globalVars" + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + //type flowRateInletVelocity; + //massFlowRate $mflowRateGas; + //rho thermo:rho.gas; + //value $internalField; + type fixedValue; + value uniform (0 $uGasPhase 0); + } + outlet + { + type pressureInletOutletVelocity; + phi phi.gas; + value $internalField; + } + defaultFaces + { + type slip; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/U.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/U.liquid new file mode 100644 index 00000000..1879e020 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/U.liquid @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volVectorField; + object U.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform (0 0 0); + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + //type flowRateInletVelocity; + //massFlowRate $mflowRateLiq; + //rho thermo:rho.liquid; + //value $internalField; + type fixedValue; + value uniform (0 0 0); + } + outlet + { + type noSlip; + } + defaultFaces + { + type noSlip; + } + +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/Ydefault.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/Ydefault.gas new file mode 100644 index 00000000..fba2945d --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/Ydefault.gas @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object Ydefault.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform 0.0; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/Ydefault.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/Ydefault.liquid new file mode 100644 index 00000000..a5108564 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/Ydefault.liquid @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object Ydefault.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 1.0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform 1.0; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alpha.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alpha.gas new file mode 100644 index 00000000..1e303fbe --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alpha.gas @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object alpha.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $alphaGas; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $alphaGas; + } + outlet + { + type inletOutlet; + phi phi.gas; + inletValue uniform 1; + value uniform 1; + } + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alpha.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alpha.liquid new file mode 100644 index 00000000..5c92070b --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alpha.liquid @@ -0,0 +1,40 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object alpha.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform 1; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $alphaLiq; + } + outlet + { + type fixedValue; + value uniform 0; + } + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alphat.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alphat.gas new file mode 100644 index 00000000..b867958f --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alphat.gas @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object alphat.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + defaultFaces + { + type calculated; + value $internalField; + //type compressible::alphatWallFunction; + //Prt 0.85; + //value $internalField; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alphat.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alphat.liquid new file mode 100644 index 00000000..2569c3ee --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/alphat.liquid @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object alphat.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + defaultFaces + { + type compressible::alphatWallFunction; + Prt 0.85; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/epsilon.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/epsilon.gas new file mode 100644 index 00000000..707a1cda --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/epsilon.gas @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object epsilon.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $eps_inlet_gas; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $eps_inlet_gas; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + //type epsilonWallFunction; + //value $internalField; + } + + // defaultFaces + // { + // type empty; + // } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/epsilon.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/epsilon.liquid new file mode 100644 index 00000000..0a4236fd --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/epsilon.liquid @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object epsilon.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $eps_inlet_liq; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $eps_inlet_liq; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type epsilonWallFunction; + value $internalField; + } + +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/f.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/f.gas new file mode 100644 index 00000000..76ee77a9 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/f.gas @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object f.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 1.0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform 1.0; //$internalField; // + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/k.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/k.gas new file mode 100644 index 00000000..4a3d44ca --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/k.gas @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object k.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $k_inlet_gas; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform $k_inlet_gas; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/k.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/k.liquid new file mode 100644 index 00000000..cde8f6c1 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/k.liquid @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object k.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $k_inlet_liq; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform $k_inlet_liq; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type kqRWallFunction; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/nut.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/nut.gas new file mode 100644 index 00000000..ba16dd4c --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/nut.gas @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object nut.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 1e-8; + +boundaryField +{ + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + defaultFaces + { + //type nutkWallFunction; + //value $internalField; + type calculated; + value $internalField; + } + + // defaultFaces + // { + // type empty; + // } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/nut.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/nut.liquid new file mode 100644 index 00000000..1442e07f --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/nut.liquid @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object nut.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 1e-4; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + defaultFaces + { + type nutkWallFunction; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/p b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/p new file mode 100644 index 00000000..b3a295fb --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/p @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 101325; + +boundaryField +{ + inlet + { + type calculated; + value $internalField; + } + outlet + { + type calculated; + value $internalField; + } + defaultFaces + { + type calculated; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/p_rgh b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/p_rgh new file mode 100644 index 00000000..88ee7d80 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/0.orig/p_rgh @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 101325; + +boundaryField +{ + inlet + { + type fixedFluxPressure; + value $internalField; + } + outlet + { + type prghTotalPressure; + p0 $internalField; + U U.gas; + phi phi.gas; + rho thermo:rho.gas; + value $internalField; + } + defaultFaces + { + type fixedFluxPressure; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/Allclean b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/Allclean new file mode 100755 index 00000000..f55e0ec9 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/Allclean @@ -0,0 +1,18 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +# Remove surface, features and solution +#rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1 +#rm -f constant/triSurface/*.eMesh > /dev/null 2>&1 +#rm -rf constant/polyMesh > /dev/null 2>&1 +#rm -rf processor* > /dev/null 2>&1 +rm -rf 0 +cleanCase + +#rm *.obj +#rm *.stl + +#------------------------------------------------------------------------------ diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/computeQOI.sh b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/computeQOI.sh new file mode 100644 index 00000000..3756ed7f --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/computeQOI.sh @@ -0,0 +1,13 @@ +if [ ! -f qoi.txt ]; then + # Reconstruct if needed + source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc + reconstructPar -newTimes + module load anaconda3/2023 + conda activate /projects/gas2fuels/conda_env/bird + python read_history.py -cr .. -cn local -df data + python get_qoi.py + conda deactivate +else + echo "WARNING: QOI already computed" +fi + diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/dynamicMix_util.H b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/dynamicMix_util.H new file mode 100644 index 00000000..8fa7daf7 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/dynamicMix_util.H @@ -0,0 +1,37 @@ +#include + +double gradfunMix(double V1, double V2){ + return 3.0*V2*V2 + 2.0*V1*V2 - V1*V1; +} + +double funMix(double V1, double V2, double P, double rhoL, double A){ + return V2*V2*V2 + V1*V2*V2 - V2*V1*V1 - V1*V1*V1 - 4.0*P/(rhoL * A); +} + +double findV2(double P, double rhoL, double A, double V1) { + int newton_iter = 100; + double V2 = 2*V1; + double V2_old; + double V2_new; + if (std::abs(V1) < 1e-12) { + V2=std::pow((4.0*P/rhoL/A),0.333333); + V2_new = V2; + V2_old = V2; + } else { + for (int i=0; i("thermo:rho.liquid"); + const volScalarField& alphaL = + mesh().lookupObject("alpha.liquid"); + const volVectorField& UL = + mesh().lookupObject("U.liquid"); + double pi=3.141592654; + double source_pt_x=13.807637692813548; + double source_pt_y=1.3807637692813548; + double source_pt_z=12.426873923532193; + double disk_rad=0.9665346384969483; + double disk_area=pi*disk_rad*disk_rad; + double power=7626.034346240216; + double smear_factor=3.0; + const scalar startTime = 1; + if (time.value() > startTime) + { + // Get V1 + double source_sign_factor = 1.0; + double V1 = 0; + double V2 = 0; + double rhoV; + double dist_tol = disk_rad*5; + + double dist_n; + double upV = 0; + double uprhoV = 0; + double upVvol = 0; + double downV = 0; + double downrhoV = 0; + double downVvol = 0; + double dist2; + forAll(C,i) + { + dist2 = (C[i].x()-source_pt_x)*(C[i].x()-source_pt_x); + dist2 += (C[i].y()-source_pt_y)*(C[i].y()-source_pt_y); + dist2 += (C[i].z()-source_pt_z)*(C[i].z()-source_pt_z); + + dist_n = (C[i].x()-source_pt_x); + + if (dist2 < dist_tol*dist_tol && dist_n < -dist_tol/2) { + upVvol += V[i] * alphaL[i]; + upV += V[i] * alphaL[i] * UL[i][0]; + uprhoV += V[i] * alphaL[i] * rhoL[i]; + } + if (dist2 < dist_tol*dist_tol && dist_n > dist_tol/2) { + downVvol += V[i] * alphaL[i]; + downV += V[i] * alphaL[i] * UL[i][0]; + downrhoV += V[i] * alphaL[i] * rhoL[i]; + } + } + + reduce(uprhoV, sumOp()); + reduce(downrhoV, sumOp()); + reduce(upV, sumOp()); + reduce(downV, sumOp()); + reduce(downVvol, sumOp()); + reduce(upVvol, sumOp()); + + downV /= downVvol; + upV /= upVvol; + downrhoV /= downVvol; + uprhoV /= upVvol; + + if (upV <= 0 && downV <= 0) { + source_sign_factor = -1.0; + V1 = std::abs(upV); + rhoV = uprhoV; + } else if (upV >= 0 && downV >= 0) { + source_sign_factor = 1.0; + V1 = std::abs(downV); + rhoV = downrhoV; + } else { + V1 = 0.0; + source_sign_factor = -1.0; + rhoV = uprhoV; + Foam::Info << "[BIRD:DYNMIX WARN] " << "upV = " << upV << " downV = " << downV << " for source at " << source_pt_x << ", " << source_pt_y << ", " << source_pt_z << endl; + } + Foam::Info << "[BIRD:DYNMIX INFO] V1 = " << V1 << endl; + + // Get V2 + V2 = findV2(power, rhoV, disk_area, V1); + + forAll(C,i) + { + double Thrust=0.5*rhoL[i]*(V2*V2 - V1*V1)*disk_area; + double dist2=(C[i].x()-source_pt_x)*(C[i].x()-source_pt_x); + dist2 += (C[i].y()-source_pt_y)*(C[i].y()-source_pt_y); + dist2 += (C[i].z()-source_pt_z)*(C[i].z()-source_pt_z); + double epsilon=pow(V[i],0.33333)*smear_factor; + double sourceterm=alphaL[i]*(Thrust/pow(pi,1.5)/pow(epsilon,3.0))* + exp(-dist2/(epsilon*epsilon)); + Usource[i][0] -= source_sign_factor*sourceterm*V[i]; + } + } + #}; +}; diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/combustionProperties.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/g similarity index 82% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/combustionProperties.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/g index 93b7615d..770a5619 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/combustionProperties.liquid +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/g @@ -7,15 +7,15 @@ \*---------------------------------------------------------------------------*/ FoamFile { - version 2.0; format ascii; - class dictionary; + class uniformDimensionedVectorField; location "constant"; - object combustionProperties.liquid; + object g; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -combustionModel laminar; +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); // ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/globalVars b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/globalVars similarity index 99% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/globalVars rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/globalVars index f48bc569..1a0ce724 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/globalVars +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/globalVars @@ -1,5 +1,5 @@ T0 300; //initial T(K) which stays constant -VVM 0.4; +VVM 1.6; //****water Liquid properties************** CpMixLiq 4181; muMixLiq #calc "2.414e-5 * pow(10,247.8/($T0 - 140.0))"; //viscosity (Pa.s) of water as a function of T(K) @@ -42,11 +42,10 @@ He_N2 #calc "$H_N2_298 * exp($DH_N2 *(1. / $T0 - 1./298.15))"; //*******inlet gas frac************* f_H2 0.1; f_CO2 0.9; -f_CH4 0.0; f_N2 0.0; //*******inlet gas frac************* inletA 11.8966; -liqVol 608.198; +liqVol 606.514; alphaGas 1; alphaLiq 0; uGasPhase #calc "$liqVol * $VVM / (60 * $inletA * $alphaGas)"; diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/globalVars_temp b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/globalVars_temp new file mode 100644 index 00000000..fcb076a7 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/globalVars_temp @@ -0,0 +1,83 @@ +T0 300; //initial T(K) which stays constant +VVM 0.2; +//****water Liquid properties************** +CpMixLiq 4181; +muMixLiq #calc "2.414e-5 * pow(10,247.8/($T0 - 140.0))"; //viscosity (Pa.s) of water as a function of T(K) +kThermLiq 0.62; // W/m-K +rho0MixLiq 1000; // kg/m^3 +sigmaLiq 0.07; //surface tension N/m +//Wilke-Chang params for diffusion coefficient of a given solute in water (solvent) +WC_psi 2.6; +WC_M 18; // kg/kmol +WC_V_O2 25.6e-3; // m3/kmol molar volume at normal boiling temperature (Treybal 1968) +WC_V_H2 14.3e-3; +WC_V_CO2 34e-3; +WC_V_CO 30.7e-3; +WC_V_N2 31.2e-3; +WC_V_CH4 35e-3; // V_b[cm3/mol]=0.285*V_critical^1.048 (Tyn and Calus; ESTIMATING LIQUID MOLAL VOLUME; Processing, Volume 21, Issue 4, Pages 16 - 17) +//****** diffusion coeff *********** +D_H2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_H2,0.6)"; +D_CO2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CO2,0.6)"; +D_CO #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CO,0.6)"; +D_CH4 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CH4,0.6)"; +D_N2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_N2,0.6)"; +//****** Henry coeff *************** +H_O2_298 0.032; +DH_O2 1700; +H_CO2_298 0.83; +DH_CO2 2400; +H_CO_298 0.023; +DH_CO 1300; +H_H2_298 0.019; +DH_H2 500; +H_CH4_298 0.032; +DH_CH4 1900; +H_N2_298 0.015; +DH_N2 1300; +He_H2 #calc "$H_H2_298 * exp($DH_H2 *(1. / $T0 - 1./298.15))"; +He_CO #calc "$H_CO_298 * exp($DH_CO *(1. / $T0 - 1./298.15))"; +He_CO2 #calc "$H_CO2_298 * exp($DH_CO2 *(1. / $T0 - 1./298.15))"; +He_CH4 #calc "$H_CH4_298 * exp($DH_CH4 *(1. / $T0 - 1./298.15))"; +He_N2 #calc "$H_N2_298 * exp($DH_N2 *(1. / $T0 - 1./298.15))"; +//*******inlet gas frac************* +f_H2 0.1; +f_CO2 0.9; +f_N2 0.0; +//*******inlet gas frac************* +inletA ; +liqVol ; +alphaGas 1; +alphaLiq 0; +uGasPhase #calc "$liqVol * $VVM / (60 * $inletA * $alphaGas)"; +//********************************* +LeLiqH2 #calc "$kThermLiq / $rho0MixLiq / $D_H2 / $CpMixLiq"; +LeLiqCO #calc "$kThermLiq / $rho0MixLiq / $D_CO / $CpMixLiq"; +LeLiqCO2 #calc "$kThermLiq / $rho0MixLiq / $D_CO2 / $CpMixLiq"; // = 74 +LeLiqCH4 #calc "$kThermLiq / $rho0MixLiq / $D_CH4 / $CpMixLiq"; +LeLiqN2 #calc "$kThermLiq / $rho0MixLiq / $D_N2 / $CpMixLiq"; +LeLiqMix #calc "$f_CO2*$LeLiqCO2+$f_H2*$LeLiqH2"; +PrMixLiq #calc "$CpMixLiq * $muMixLiq / $kThermLiq"; +//********************************* +kH2 #calc "$D_H2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrH2 #calc "$muMixLiq*$CpMixLiq / $kH2"; + +kCO #calc "$D_CO*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCO #calc "$muMixLiq*$CpMixLiq / $kCO"; + +kCO2 #calc "$D_CO2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCO2 #calc "$muMixLiq*$CpMixLiq / $kCO2"; + +kCH4 #calc "$D_CH4*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCH4 #calc "$muMixLiq*$CpMixLiq / $kCH4"; + +kN2 #calc "$D_N2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrN2 #calc "$muMixLiq*$CpMixLiq / $kN2"; +//********************************* +l_scale 0.5; +intensity 0.05; +k_inlet_gas #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)"; +k_inlet_liq #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)"; +eps_inlet_gas #calc "pow(0.09,0.75) * Foam::pow($k_inlet_gas, 1.5) / ($l_scale * 0.07)"; +eps_inlet_liq #calc "pow(0.09,0.75) * Foam::pow($k_inlet_liq, 1.5) / ($l_scale * 0.07)"; +omega_inlet_gas #calc "pow(0.09,-0.25) * pow($k_inlet_gas,0.5) / ($l_scale * 0.07)"; +omega_inlet_liq #calc "pow(0.09,-0.25) * pow($k_inlet_liq,0.5) / ($l_scale * 0.07)"; diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/reactions.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/momentumTransport.gas similarity index 65% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/reactions.liquid rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/momentumTransport.gas index e686faed..ca916714 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/reactions.liquid +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/momentumTransport.gas @@ -4,28 +4,23 @@ \\ / O peration | Website: https://openfoam.org \\ / A nd | Version: dev \\/ M anipulation | -------------------------------------------------------------------------------- - \*---------------------------------------------------------------------------*/ FoamFile { - version 2.0; format ascii; class dictionary; location "constant"; - object reactions.liquid; + object momentumTransport.gas; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -reactions + +//simulationType laminar; +simulationType RAS; +RAS { - methanation - { - type irreversibleArrhenius; - reaction "CO2 + 4H2 = CH4 + 2water"; - - A 2.5e7; - beta 0.0; - Ta 0.0; - } + model mixtureKEpsilon; + turbulence on; + printCoeff on; } + // ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvConstraints b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/momentumTransport.liquid similarity index 74% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvConstraints rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/momentumTransport.liquid index 33a2d6db..2063de0d 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/fvConstraints +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/momentumTransport.liquid @@ -9,23 +9,19 @@ FoamFile { format ascii; class dictionary; - object fvConstraints; + location "constant"; + object momentumTransport.liquid; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -limitp -{ - type limitPressure; +//simulationType laminar; +simulationType RAS; - min 1e4; -} -limitU +RAS { - type limitVelocity; - active yes; - U U.liquid; - selectionMode all; - max 2e1; + model mixtureKEpsilon; + turbulence on; + printCoeffs on; } // ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties_constantd b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties similarity index 76% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties_constantd rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties index 1f6d4671..a3c90f5a 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/phaseProperties_constantd +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties @@ -15,34 +15,62 @@ FoamFile #include "$FOAM_CASE/constant/globalVars" -type interfaceCompositionPhaseChangeMultiphaseSystem; +type interfaceCompositionPhaseChangePopulationBalanceMultiphaseSystem; phases (gas liquid); +populationBalances (bubbles); gas { type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel velocityGroup; - diameterModel constant; - - constantCoeffs + velocityGroupCoeffs { - d 3e-3; + populationBalance bubbles; + + shapeModel spherical; + + sizeGroups + ( + f1 {dSph 1.4e-3; value 0.0;} + f2 {dSph 1.8e-3; value 0.0;} + f3 {dSph 2.2e-3; value 0.0;} + f4 {dSph 2.6e-3; value 0.0;} + f5 {dSph 3e-3; value 1.0;} + f6 {dSph 3.4e-3; value 0.0;} + f7 {dSph 3.8e-3; value 0.0;} + f8 {dSph 4.2e-3; value 0.0;} + f9 {dSph 4.6e-3; value 0.0;} + f10 {dSph 5.0e-3; value 0.0;} + ); } + residualAlpha 1e-6; + Sc 0.7; } - liquid { - type reactingPhaseModel; + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + diameterModel constant; + constantCoeffs { d 1e-4; } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + residualAlpha 1e-6; } @@ -79,16 +107,7 @@ populationBalanceCoeffs ); nucleationModels - ( - reactionDriven - { - nucleationDiameter 3.0e-3; - velocityGroup gas; - reactingPhase liquid; - dmdtf phaseTransfer:dmidtf; - specie CH4; - } - ); + (); } } @@ -141,8 +160,8 @@ drag ( (gas in liquid) { - //type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign - type IshiiZuber; + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; residualRe 1e-3; swarmCorrection { @@ -201,8 +220,8 @@ interfaceComposition.liquid (liquid and gas) { type Henry; - species ( CO2 H2 CH4 ); - k ( $He_CO2 $He_H2 $He_CH4 ); + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); Le $LeLiqMix; } ); @@ -214,8 +233,8 @@ diffusiveMassTransfer.liquid ( (gas in liquid) { - //type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign - type Frossling; + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; Le $LeLiqMix; } @@ -227,15 +246,7 @@ diffusiveMassTransfer.liquid ); phaseTransfer -( - (gas in liquid) - { - type reactionDriven; - reactingPhase liquid; - targetPhase gas; - species (CH4); - } -); +(); lift ( diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties_constantd b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties_constantd new file mode 100644 index 00000000..e029df99 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties_constantd @@ -0,0 +1,261 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object phaseProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "$FOAM_CASE/constant/globalVars" + +type interfaceCompositionPhaseChangeMultiphaseSystem; + +phases (gas liquid); + +gas +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 3e-3; + } + residualAlpha 1e-6; + Sc 0.7; +} + +liquid +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 1e-4; + } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + + residualAlpha 1e-6; +} + +populationBalanceCoeffs +{ + bubbles + { + continuousPhase liquid; + + coalescenceModels + (); + + binaryBreakupModels + (); + + breakupModels + (); + + driftModels + (); + + nucleationModels + (); + } +} + +blending +{ + default + { + type linear; + minFullyContinuousAlpha.gas 0.7; + minPartlyContinuousAlpha.gas 0.3; + minFullyContinuousAlpha.liquid 0.7; + minPartlyContinuousAlpha.liquid 0.3; + } + heatTransfer + { + type linear; + minFullyContinuousAlpha.gas 1; + minPartlyContinuousAlpha.gas 0; + minFullyContinuousAlpha.liquid 1; + minPartlyContinuousAlpha.liquid 0; + } + massTransfer + { + $heatTransfer; + } +} + +surfaceTension +( + (gas and liquid) + { + type constant; + sigma $sigmaLiq; + } +); + +interfaceCompression +(); + +aspectRatio +( + (gas in liquid) + { + type Wellek; + } +); + + +drag +( + (gas in liquid) + { + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; + residualRe 1e-3; + swarmCorrection + { + type none; + } + } +); + +virtualMass +( + (gas in liquid) + { + type constantCoefficient; + Cvm 0.5; + } +); + +// heatTransfer +// (); + +heatTransfer.gas +( + (gas in liquid) + { + type spherical; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type RanzMarshall; + residualAlpha 1e-4; + } +); + +heatTransfer.liquid +( + (gas in liquid) + { + type RanzMarshall; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type spherical; + residualAlpha 1e-4; + } +); + +interfaceComposition.gas +(); + +interfaceComposition.liquid +( + (liquid and gas) + { + type Henry; + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); + Le $LeLiqMix; + } +); + +diffusiveMassTransfer.gas +(); + +diffusiveMassTransfer.liquid +( + (gas in liquid) + { + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; + Le $LeLiqMix; + } + + (liquid in gas) + { + type spherical; + Le 1.0; //not used for spherical + } +); + +phaseTransfer +(); + +lift +( + (gas in liquid) + { + type wallDamped; + + wallDamping + { + type cosine; + Cd 3.0; + } + + lift + { + type Tomiyama; + + swarmCorrection + { + type none; + } + } + } + +); + +wallLubrication +( + (gas in liquid) + { + type Antal; + Cw1 -0.01; + Cw2 0.05; + } +); + +turbulentDispersion +( + (gas in liquid) + { + type Burns; + sigma 0.9; + } +); + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties_pbe b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties_pbe new file mode 100644 index 00000000..a3c90f5a --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/phaseProperties_pbe @@ -0,0 +1,295 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object phaseProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "$FOAM_CASE/constant/globalVars" + +type interfaceCompositionPhaseChangePopulationBalanceMultiphaseSystem; + +phases (gas liquid); + +populationBalances (bubbles); + +gas +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel velocityGroup; + + velocityGroupCoeffs + { + populationBalance bubbles; + + shapeModel spherical; + + sizeGroups + ( + f1 {dSph 1.4e-3; value 0.0;} + f2 {dSph 1.8e-3; value 0.0;} + f3 {dSph 2.2e-3; value 0.0;} + f4 {dSph 2.6e-3; value 0.0;} + f5 {dSph 3e-3; value 1.0;} + f6 {dSph 3.4e-3; value 0.0;} + f7 {dSph 3.8e-3; value 0.0;} + f8 {dSph 4.2e-3; value 0.0;} + f9 {dSph 4.6e-3; value 0.0;} + f10 {dSph 5.0e-3; value 0.0;} + ); + } + + residualAlpha 1e-6; + + Sc 0.7; +} + +liquid +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 1e-4; + } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + + residualAlpha 1e-6; +} + +populationBalanceCoeffs +{ + bubbles + { + continuousPhase liquid; + + coalescenceModels + ( + LehrMilliesMewes{ + efficiency 4.695; + uCrit 0.08; + alphaMax 0.6; + } + ); + + binaryBreakupModels + (); + + breakupModels + ( + Laakkonen { + efficiency 13.83; + daughterSizeDistributionModel Laakkonen; + } + + ); + + driftModels + ( + densityChange{} + ); + + nucleationModels + (); + } +} + +blending +{ + default + { + type linear; + minFullyContinuousAlpha.gas 0.7; + minPartlyContinuousAlpha.gas 0.3; + minFullyContinuousAlpha.liquid 0.7; + minPartlyContinuousAlpha.liquid 0.3; + } + heatTransfer + { + type linear; + minFullyContinuousAlpha.gas 1; + minPartlyContinuousAlpha.gas 0; + minFullyContinuousAlpha.liquid 1; + minPartlyContinuousAlpha.liquid 0; + } + massTransfer + { + $heatTransfer; + } +} + +surfaceTension +( + (gas and liquid) + { + type constant; + sigma $sigmaLiq; + } +); + +interfaceCompression +(); + +aspectRatio +( + (gas in liquid) + { + type Wellek; + } +); + + +drag +( + (gas in liquid) + { + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; + residualRe 1e-3; + swarmCorrection + { + type none; + } + } +); + +virtualMass +( + (gas in liquid) + { + type constantCoefficient; + Cvm 0.5; + } +); + +// heatTransfer +// (); + +heatTransfer.gas +( + (gas in liquid) + { + type spherical; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type RanzMarshall; + residualAlpha 1e-4; + } +); + +heatTransfer.liquid +( + (gas in liquid) + { + type RanzMarshall; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type spherical; + residualAlpha 1e-4; + } +); + +interfaceComposition.gas +(); + +interfaceComposition.liquid +( + (liquid and gas) + { + type Henry; + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); + Le $LeLiqMix; + } +); + +diffusiveMassTransfer.gas +(); + +diffusiveMassTransfer.liquid +( + (gas in liquid) + { + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; + Le $LeLiqMix; + } + + (liquid in gas) + { + type spherical; + Le 1.0; //not used for spherical + } +); + +phaseTransfer +(); + +lift +( + (gas in liquid) + { + type wallDamped; + + wallDamping + { + type cosine; + Cd 3.0; + } + + lift + { + type Tomiyama; + + swarmCorrection + { + type none; + } + } + } + +); + +wallLubrication +( + (gas in liquid) + { + type Antal; + Cw1 -0.01; + Cw2 0.05; + } +); + +turbulentDispersion +( + (gas in liquid) + { + type Burns; + sigma 0.9; + } +); + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/thermophysicalProperties.gas b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/thermophysicalProperties.gas new file mode 100644 index 00000000..11b1c4b9 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/thermophysicalProperties.gas @@ -0,0 +1,142 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture multiComponentMixture; + transport sutherland; + thermo janaf; + equationOfState perfectGas; + specie specie; + energy sensibleInternalEnergy; + //energy sensibleEnthalpy; +} + + +species +( + H2 + CO2 + N2 +); + +defaultSpecie N2; + +CO2 +{ + specie + { + molWeight 44.00995; + } + thermodynamics + { + Tlow 200; + Thigh 3500; + Tcommon 1000; + highCpCoeffs ( 3.85746029 0.00441437026 -2.21481404e-06 5.23490188e-10 -4.72084164e-14 -48759.166 2.27163806 ); + lowCpCoeffs ( 2.35677352 0.00898459677 -7.12356269e-06 2.45919022e-09 -1.43699548e-13 -48371.9697 9.90105222 ); + } + transport + { + As 1.572e-06; + Ts 240; + } + elements + { + C 1; + O 2; + } +} + +water +{ + specie + { + molWeight 18.01534; + } + thermodynamics + { + Tlow 200; + Thigh 3500; + Tcommon 1000; + highCpCoeffs ( 3.03399249 0.00217691804 -1.64072518e-07 -9.7041987e-11 1.68200992e-14 -30004.2971 4.9667701 ); + lowCpCoeffs ( 4.19864056 -0.0020364341 6.52040211e-06 -5.48797062e-09 1.77197817e-12 -30293.7267 -0.849032208 ); + } + transport + { + As 1.512e-06; + Ts 120; + } + elements + { + H 2; + O 1; + } +} + +N2 +{ + specie + { + molWeight 28.0134; + } + thermodynamics + { + Tlow 250; + Thigh 5000; + Tcommon 1000; + highCpCoeffs ( 2.92664 0.0014879768 -5.68476e-07 1.0097038e-10 -6.753351e-15 -922.7977 5.980528 ); + lowCpCoeffs ( 3.298677 0.0014082404 -3.963222e-06 5.641515e-09 -2.444854e-12 -1020.8999 3.950372 ); + } + transport + { + As 1.512e-06; + Ts 120; + } + elements + { + N 2; + } +} + +H2 +{ + specie + { + molWeight 2.01594; + } + thermodynamics + { + Tlow 200; + Thigh 3500; + Tcommon 1000; + highCpCoeffs ( 3.3372792 -4.94024731e-05 4.99456778e-07 -1.79566394e-10 2.00255376e-14 -950.158922 -3.20502331 ); + lowCpCoeffs ( 2.34433112 0.00798052075 -1.9478151e-05 2.01572094e-08 -7.37611761e-12 -917.935173 0.683010238 ); + } + transport + { + As 6.362e-07; + Ts 72; + } + elements + { + H 2; + } +} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/thermophysicalProperties.liquid b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/thermophysicalProperties.liquid new file mode 100644 index 00000000..d324ec51 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/constant/thermophysicalProperties.liquid @@ -0,0 +1,108 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "$FOAM_CASE/constant/globalVars" + +thermoType +{ + type heRhoThermo; + mixture multiComponentMixture; + transport const; + thermo hConst; + equationOfState rhoConst;//rPolynomial; + specie specie; + energy sensibleInternalEnergy; + //energy sensibleEnthalpy; +} + +species +( + CO2 + water + H2 +); + +inertSpecie water; + +water +{ + specie + { + molWeight 18.0153; + } + equationOfState + { + rho $rho0MixLiq; + } + thermodynamics + { + Cp $CpMixLiq; + Hf -1.5879e+07; + } + transport + { + mu $muMixLiq; + Pr $PrMixLiq; + } +} + +CO2 +{ + specie + { + molWeight 44.00995; + } + equationOfState + { + rho $rho0MixLiq; + } + thermodynamics + { + Cp $CpMixLiq; + Hf -1.5879e+07; + } + transport + { + mu $muMixLiq; + Pr $PrCO2; + } +} + +H2 +{ + specie + { + molWeight 2.01594; + } + equationOfState + { + rho $rho0MixLiq; + } + thermodynamics + { + Cp $CpMixLiq; + Hf -1.5879e+07;//-9402451; + } + transport + { + mu $muMixLiq; + Pr $PrH2; + } +} + + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/get_qoi.py b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/get_qoi.py new file mode 100644 index 00000000..9562cc65 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/get_qoi.py @@ -0,0 +1,183 @@ +import json +import os +import pickle as pkl + +import matplotlib as mpl +import numpy as np +from prettyPlot.plotting import * +from scipy.optimize import curve_fit + + +def get_sim_folds(path): + folds = os.listdir(path) + sim_folds = [] + for fold in folds: + if fold.startswith("loop"): + sim_folds.append(fold) + return sim_folds + + +def func(t, cstar, kla): + t = t + t0 = 0 + c0 = 0 + return (cstar - c0) * (1 - np.exp(-kla * (t - t0))) + c0 + + +def get_vl(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("liqVol"): + vol = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read liqVol = {vol}m3") + return vol + + +def get_vvm(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("VVM"): + vvm = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read VVM = {vvm} [-]") + return vvm + + +def get_As(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("inletA"): + As = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read As = {As}m2") + return As + + +def get_pmix(verb=False): + with open("system/mixers.json", "r+") as f: + data = json.load(f) + mixer_list = data["mixers"] + pmix = 0 + for mix in mixer_list: + pmix += mix["power"] / 1000 + if verb: + print(f"Read Mixing power = {pmix}kW") + return pmix + + +def get_lh(verb=False): + filename = os.path.join("system", "setFieldsDict") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if "box (-1.0 -1.0 -1.0)" in line: + height = float(line.split("(")[2].split()[1]) + break + if verb: + print(f"Read Height = {height}m") + return height + + +def get_pinj(vvm, Vl, As, lh): + rhog = 1.25 # kg /m3 + Vg = Vl * vvm / (60 * As * 1) # m/s + Ptank = 101325 # Pa + # Ptank = 0 # Pa + rhoL = 1000 # kg / m3 + Pl = 101325 + rhoL * 9.8 * lh # Pa + # W + P1 = rhog * As * Vg**3 + # W + P2 = (Pl - Ptank) * As * Vg + # kg /s + MF = rhog * Vg * As + # kwh / kg + e_m = (P1 + P2) / (3600 * 1000 * MF) + + # returns kW + return (P1 + P2) * 1e-3 + + +def get_qoi(kla_co2, cs_co2, kla_h2, cs_h2, verb=False): + vvm = get_vvm(verb) + As = get_As(verb) + V_l = get_vl(verb) + liqh = get_lh(verb) + P_inj = get_pinj(vvm, V_l, As, liqh) + P_mix = get_pmix(verb) + + qoi_co2 = kla_co2 * cs_co2 * V_l * 0.04401 / (P_mix / 3600 + P_inj / 3600) + qoi_h2 = kla_h2 * cs_h2 * V_l * 0.002016 / (P_mix / 3600 + P_inj / 3600) + return qoi_co2 * qoi_h2 + + +def get_qoi_uq(kla_co2, cs_co2, kla_h2, cs_h2): + qoi = [] + for i in range(len(kla_co2)): + if i == 0: + verb = True + else: + verb = False + qoi.append(get_qoi(kla_co2[i], cs_co2[i], kla_h2[i], cs_h2[i], verb)) + qoi = np.array(qoi) + return np.mean(qoi), np.std(qoi) + + +os.makedirs("Figures", exist_ok=True) + +dataFolder = "data" +fold = "local" + +nuq = 100 +mean_cstar_co2 = np.random.uniform(12.6, 13.3, nuq) +mean_cstar_h2 = np.random.uniform(0.902, 0.96, nuq) + + +tmp_cs_h2 = [] +tmp_cs_co2 = [] +tmp_kla_h2 = [] +tmp_kla_co2 = [] +cs_co2 = mean_cstar_co2 +cs_h2 = mean_cstar_h2 + +a = np.load(os.path.join(dataFolder, fold, "conv.npz")) +endindex = -1 +if ( + "c_h2" in a + and "c_co2" in a + and len(a["time"][:endindex] > 0) + and (a["time"][:endindex][-1] > 95) +): + for i in range(nuq): + fitparamsH2, _ = curve_fit( + func, + np.array(a["time"][:endindex]), + np.array(a["c_h2"][:endindex]), + bounds=[(cs_h2[i] - 1e-6, 0), (cs_h2[i] + 1e-6, 1)], + ) + fitparamsCO2, _ = curve_fit( + func, + np.array(a["time"][:endindex]), + np.array(a["c_co2"][:endindex]), + bounds=[(cs_co2[i] - 1e-6, 0), (cs_co2[i] + 1e-6, 1)], + ) + tmp_kla_co2.append(fitparamsCO2[1]) + tmp_kla_h2.append(fitparamsH2[1]) + tmp_cs_h2.append(cs_h2[i]) + tmp_cs_co2.append(cs_co2[i]) + +qoi_m, qoi_s = get_qoi_uq(tmp_kla_co2, tmp_cs_co2, tmp_kla_h2, tmp_cs_h2) + + +with open("qoi.txt", "w+") as f: + f.write(f"{qoi_m},{qoi_s}\n") diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/presteps.sh b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/presteps.sh new file mode 100644 index 00000000..6d419bf9 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/presteps.sh @@ -0,0 +1,71 @@ +# Clean case +module load anaconda3/2023 +conda activate /projects/gas2fuels/conda_env/bird +source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc +./Allclean + +echo PRESTEP 1 +# Generate blockmeshDict +python /projects/gas2fuels/BioReactorDesign/applications/write_block_rect_mesh.py -i system/mesh.json -o system +#python ../../../applications/write_block_rect_mesh.py -i system/mesh.json -o system + +# Generate boundary stl +python /projects/gas2fuels/BioReactorDesign/applications/write_stl_patch.py -i system/inlets_outlets.json +#python ../../../applications/write_stl_patch.py -i system/inlets_outlets.json + +# Generate mixers +python /projects/gas2fuels/BioReactorDesign/applications/write_dynMix_fvModels_force_sign.py -i system/mixers.json -o constant +#python ../../../applications/write_dynMix_fvModels_force_sign.py -i system/mixers.json -o constant + +echo PRESTEP 2 +# Mesh gen +blockMesh -dict system/blockMeshDict + +# Inlet BC +surfaceToPatch -tol 1e-3 inlets.stl +export newmeshdir=$(foamListTimes -latestTime) +rm -rf constant/polyMesh/ +cp -r $newmeshdir/polyMesh ./constant +rm -rf $newmeshdir +cp constant/polyMesh/boundary /tmp +sed -i -e 's/inlets\.stl/inlet/g' /tmp/boundary +cat /tmp/boundary > constant/polyMesh/boundary + +# Outlet BC +surfaceToPatch -tol 1e-3 outlets.stl +export newmeshdir=$(foamListTimes -latestTime) +rm -rf constant/polyMesh/ +cp -r $newmeshdir/polyMesh ./constant +rm -rf $newmeshdir +cp constant/polyMesh/boundary /tmp +sed -i -e 's/outlets\.stl/outlet/g' /tmp/boundary +cat /tmp/boundary > constant/polyMesh/boundary + + +# Scale +transformPoints "scale=(2.7615275385627096 2.7615275385627096 2.7615275385627096)" + + +# setup IC +cp -r 0.orig 0 +setFields + +# Setup mass flow rate +# Get inlet area +postProcess -func 'patchIntegrate(patch="inlet", field="alpha.gas")' +postProcess -func writeCellVolumes +writeMeshObj + +echo PRESTEP 3 +python writeGlobalVars.py +cp constant/phaseProperties_constantd constant/phaseProperties + +conda deactivate + +if [ -f qoi.txt ]; then + rm qoi.txt +fi +if [ -f data/local/conv.npz ]; then + rm data/local/conv.npz +fi + diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/read_history.py b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/read_history.py new file mode 100644 index 00000000..264711f8 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/read_history.py @@ -0,0 +1,239 @@ +import argparse +import os +import sys + +import numpy as np +from prettyPlot.plotting import plt, pretty_labels + +from bird.utilities.ofio import * + + +def compute_gas_holdup(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + alpha_liq = field_dict["alpha_liq"] + volume = field_dict["volume"] + holdup = np.sum((1 - alpha_liq) * volume) / np.sum(volume) + return holdup, field_dict + + +def co2liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("co2_liq" in field_dict) or field_dict["co2_liq"] is None: + co2_liq_file = os.path.join(caseFolder, timeFolder, "CO2.liquid") + co2_liq = readOFScal(co2_liq_file, nCells) + # print("computing co2 liq") + field_dict["co2_liq"] = co2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + co2_liq = field_dict["co2_liq"] + met = np.sum( + alpha_liq[indliq] * co2_liq[indliq] * volume[indliq] + ) / np.sum(volume[indliq]) + return met, field_dict + + +def cliq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("rho_liq" in field_dict) or field_dict["rho_liq"] is None: + rho_liq_file = os.path.join(caseFolder, timeFolder, "rhom") + rho_liq = readOFScal(rho_liq_file, nCells) + field_dict["rho_liq"] = rho_liq + if not ("co2_liq" in field_dict) or field_dict["co2_liq"] is None: + co2_liq_file = os.path.join(caseFolder, timeFolder, "CO2.liquid") + co2_liq = readOFScal(co2_liq_file, nCells) + # print("computing co2 liq") + field_dict["co2_liq"] = co2_liq + if not ("h2_liq" in field_dict) or field_dict["h2_liq"] is None: + h2_liq_file = os.path.join(caseFolder, timeFolder, "H2.liquid") + h2_liq = readOFScal(h2_liq_file, nCells) + # print("computing h2 liq") + field_dict["h2_liq"] = h2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + co2_liq = field_dict["co2_liq"] + h2_liq = field_dict["h2_liq"] + rho_liq = field_dict["rho_liq"] + + # c_h2 = rho_liq[indliq] * alpha_liq[indliq] * h2_liq[indliq] / 0.002016 + # c_co2 = rho_liq[indliq] * alpha_liq[indliq] * co2_liq[indliq] / 0.04401 + + c_h2 = 1000 * alpha_liq[indliq] * h2_liq[indliq] / 0.002016 + c_co2 = 1000 * alpha_liq[indliq] * co2_liq[indliq] / 0.04401 + + c_h2 = np.sum(c_h2 * volume[indliq]) / np.sum(volume[indliq]) + c_co2 = np.sum(c_co2 * volume[indliq]) / np.sum(volume[indliq]) + + return c_co2, c_h2, field_dict + + +def h2liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("h2_liq" in field_dict) or field_dict["h2_liq"] is None: + h2_liq_file = os.path.join(caseFolder, timeFolder, "H2.liquid") + h2_liq = readOFScal(h2_liq_file, nCells) + # print("computing h2 liq") + field_dict["h2_liq"] = h2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + h2_liq = field_dict["h2_liq"] + met = np.sum(alpha_liq[indliq] * h2_liq[indliq] * volume[indliq]) / np.sum( + volume[indliq] + ) + return met, field_dict + + +def vol_liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + volume = field_dict["volume"] + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.0) + liqvol = np.sum(alpha_liq[indliq] * volume[indliq]) / np.sum( + volume[indliq] + ) + return liqvol, field_dict + + +parser = argparse.ArgumentParser(description="Convergence of GH") +parser.add_argument( + "-cn", + "--case_name", + type=str, + metavar="", + required=True, + help="Case name", +) +parser.add_argument( + "-df", + "--data_folder", + type=str, + metavar="", + required=False, + help="data folder name", + default="data", +) + +args, unknown = parser.parse_known_args() + + +case_root = "." # "../" +case_name = args.case_name # "12_hole_sparger_snappyRefine_700rpm_opt_coeff" +case_path = "." +dataFolder = args.data_folder + +if os.path.isfile(os.path.join(dataFolder, case_name, "conv.npz")): + sys.exit("WARNING: History already created, Skipping") + +time_float_sorted, time_str_sorted = getCaseTimes(case_path, remove_zero=True) +cellCentres = readMesh(os.path.join(case_path, f"meshCellCentres_0.obj")) +nCells = len(cellCentres) + + +co2_history = np.zeros(len(time_str_sorted)) +c_co2_history = np.zeros(len(time_str_sorted)) +h2_history = np.zeros(len(time_str_sorted)) +c_h2_history = np.zeros(len(time_str_sorted)) +gh_history = np.zeros(len(time_str_sorted)) +liqvol_history = np.zeros(len(time_str_sorted)) +print(f"case_path = {case_path}") +field_dict = {} +for itime, time in enumerate(time_float_sorted): + time_folder = time_str_sorted[itime] + print(f"\tTime : {time_folder}") + if not field_dict == {}: + new_field_dict = {} + if "volume" in field_dict: + new_field_dict["volume"] = field_dict["volume"] + field_dict = new_field_dict + gh_history[itime], field_dict = compute_gas_holdup( + case_path, time_str_sorted[itime], nCells, field_dict + ) + co2_history[itime], field_dict = co2liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + h2_history[itime], field_dict = h2liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + liqvol_history[itime], field_dict = vol_liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + c_co2_history[itime], c_h2_history[itime], field_dict = cliq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + + +os.makedirs(dataFolder, exist_ok=True) +os.makedirs(os.path.join(dataFolder, case_name), exist_ok=True) +np.savez( + os.path.join(dataFolder, case_name, "conv.npz"), + time=np.array(time_float_sorted), + gh=gh_history, + co2=co2_history, + h2=h2_history, + vol_liq=liqvol_history, + c_h2=c_h2_history, + c_co2=c_co2_history, +) diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/run.sh b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/run.sh new file mode 100644 index 00000000..6b7eb516 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/run.sh @@ -0,0 +1,5 @@ +multiphaseEulerFoam + + + + diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/script b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/script new file mode 100755 index 00000000..090e5c05 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/script @@ -0,0 +1,14 @@ +#!/bin/bash +#SBATCH --qos=high +#SBATCH --job-name=val2 +##SBATCH --partition=debug +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=16 +#SBATCH --time=07:59:00 +#SBATCH --account=co2snow + +bash presteps.sh +source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc +decomposePar -fileHandler collated +srun -n 16 multiphaseEulerFoam -parallel -fileHandler collated +reconstructPar -newTimes diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/script_post b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/script_post new file mode 100755 index 00000000..aabbc33e --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/script_post @@ -0,0 +1,10 @@ +#!/bin/bash +#SBATCH --qos=high +#SBATCH --job-name=val2 +##SBATCH --partition=debug +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=16 +#SBATCH --time=00:59:00 +#SBATCH --account=co2snow + +bash computeQOI.sh diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/blockMeshDict b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/blockMeshDict new file mode 100644 index 00000000..1183d262 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/blockMeshDict @@ -0,0 +1,746 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +convertToMeters 1.0; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +vertices +( +( 0.0 0.0 0.0) +( 1.0 0.0 0.0) +( 2.0 0.0 0.0) +( 3.0 0.0 0.0) +( 4.0 0.0 0.0) +( 5.0 0.0 0.0) +( 6.0 0.0 0.0) +( 7.0 0.0 0.0) +( 8.0 0.0 0.0) +( 9.0 0.0 0.0) +( 10.0 0.0 0.0) +( 0.0 1.0 0.0) +( 1.0 1.0 0.0) +( 2.0 1.0 0.0) +( 3.0 1.0 0.0) +( 4.0 1.0 0.0) +( 5.0 1.0 0.0) +( 6.0 1.0 0.0) +( 7.0 1.0 0.0) +( 8.0 1.0 0.0) +( 9.0 1.0 0.0) +( 10.0 1.0 0.0) +( 0.0 2.0 0.0) +( 1.0 2.0 0.0) +( 2.0 2.0 0.0) +( 3.0 2.0 0.0) +( 4.0 2.0 0.0) +( 5.0 2.0 0.0) +( 6.0 2.0 0.0) +( 7.0 2.0 0.0) +( 8.0 2.0 0.0) +( 9.0 2.0 0.0) +( 10.0 2.0 0.0) +( 0.0 3.0 0.0) +( 1.0 3.0 0.0) +( 2.0 3.0 0.0) +( 3.0 3.0 0.0) +( 4.0 3.0 0.0) +( 5.0 3.0 0.0) +( 6.0 3.0 0.0) +( 7.0 3.0 0.0) +( 8.0 3.0 0.0) +( 9.0 3.0 0.0) +( 10.0 3.0 0.0) +( 0.0 4.0 0.0) +( 1.0 4.0 0.0) +( 2.0 4.0 0.0) +( 3.0 4.0 0.0) +( 4.0 4.0 0.0) +( 5.0 4.0 0.0) +( 6.0 4.0 0.0) +( 7.0 4.0 0.0) +( 8.0 4.0 0.0) +( 9.0 4.0 0.0) +( 10.0 4.0 0.0) +( 0.0 5.0 0.0) +( 1.0 5.0 0.0) +( 2.0 5.0 0.0) +( 3.0 5.0 0.0) +( 4.0 5.0 0.0) +( 5.0 5.0 0.0) +( 6.0 5.0 0.0) +( 7.0 5.0 0.0) +( 8.0 5.0 0.0) +( 9.0 5.0 0.0) +( 10.0 5.0 0.0) +( 0.0 6.0 0.0) +( 1.0 6.0 0.0) +( 2.0 6.0 0.0) +( 3.0 6.0 0.0) +( 4.0 6.0 0.0) +( 5.0 6.0 0.0) +( 6.0 6.0 0.0) +( 7.0 6.0 0.0) +( 8.0 6.0 0.0) +( 9.0 6.0 0.0) +( 10.0 6.0 0.0) +( 0.0 7.0 0.0) +( 1.0 7.0 0.0) +( 2.0 7.0 0.0) +( 3.0 7.0 0.0) +( 4.0 7.0 0.0) +( 5.0 7.0 0.0) +( 6.0 7.0 0.0) +( 7.0 7.0 0.0) +( 8.0 7.0 0.0) +( 9.0 7.0 0.0) +( 10.0 7.0 0.0) +( 0.0 0.0 1.0) +( 1.0 0.0 1.0) +( 2.0 0.0 1.0) +( 3.0 0.0 1.0) +( 4.0 0.0 1.0) +( 5.0 0.0 1.0) +( 6.0 0.0 1.0) +( 7.0 0.0 1.0) +( 8.0 0.0 1.0) +( 9.0 0.0 1.0) +( 10.0 0.0 1.0) +( 0.0 1.0 1.0) +( 1.0 1.0 1.0) +( 2.0 1.0 1.0) +( 3.0 1.0 1.0) +( 4.0 1.0 1.0) +( 5.0 1.0 1.0) +( 6.0 1.0 1.0) +( 7.0 1.0 1.0) +( 8.0 1.0 1.0) +( 9.0 1.0 1.0) +( 10.0 1.0 1.0) +( 0.0 2.0 1.0) +( 1.0 2.0 1.0) +( 2.0 2.0 1.0) +( 3.0 2.0 1.0) +( 4.0 2.0 1.0) +( 5.0 2.0 1.0) +( 6.0 2.0 1.0) +( 7.0 2.0 1.0) +( 8.0 2.0 1.0) +( 9.0 2.0 1.0) +( 10.0 2.0 1.0) +( 0.0 3.0 1.0) +( 1.0 3.0 1.0) +( 2.0 3.0 1.0) +( 3.0 3.0 1.0) +( 4.0 3.0 1.0) +( 5.0 3.0 1.0) +( 6.0 3.0 1.0) +( 7.0 3.0 1.0) +( 8.0 3.0 1.0) +( 9.0 3.0 1.0) +( 10.0 3.0 1.0) +( 0.0 4.0 1.0) +( 1.0 4.0 1.0) +( 2.0 4.0 1.0) +( 3.0 4.0 1.0) +( 4.0 4.0 1.0) +( 5.0 4.0 1.0) +( 6.0 4.0 1.0) +( 7.0 4.0 1.0) +( 8.0 4.0 1.0) +( 9.0 4.0 1.0) +( 10.0 4.0 1.0) +( 0.0 5.0 1.0) +( 1.0 5.0 1.0) +( 2.0 5.0 1.0) +( 3.0 5.0 1.0) +( 4.0 5.0 1.0) +( 5.0 5.0 1.0) +( 6.0 5.0 1.0) +( 7.0 5.0 1.0) +( 8.0 5.0 1.0) +( 9.0 5.0 1.0) +( 10.0 5.0 1.0) +( 0.0 6.0 1.0) +( 1.0 6.0 1.0) +( 2.0 6.0 1.0) +( 3.0 6.0 1.0) +( 4.0 6.0 1.0) +( 5.0 6.0 1.0) +( 6.0 6.0 1.0) +( 7.0 6.0 1.0) +( 8.0 6.0 1.0) +( 9.0 6.0 1.0) +( 10.0 6.0 1.0) +( 0.0 7.0 1.0) +( 1.0 7.0 1.0) +( 2.0 7.0 1.0) +( 3.0 7.0 1.0) +( 4.0 7.0 1.0) +( 5.0 7.0 1.0) +( 6.0 7.0 1.0) +( 7.0 7.0 1.0) +( 8.0 7.0 1.0) +( 9.0 7.0 1.0) +( 10.0 7.0 1.0) +( 0.0 0.0 2.0) +( 1.0 0.0 2.0) +( 2.0 0.0 2.0) +( 3.0 0.0 2.0) +( 4.0 0.0 2.0) +( 5.0 0.0 2.0) +( 6.0 0.0 2.0) +( 7.0 0.0 2.0) +( 8.0 0.0 2.0) +( 9.0 0.0 2.0) +( 10.0 0.0 2.0) +( 0.0 1.0 2.0) +( 1.0 1.0 2.0) +( 2.0 1.0 2.0) +( 3.0 1.0 2.0) +( 4.0 1.0 2.0) +( 5.0 1.0 2.0) +( 6.0 1.0 2.0) +( 7.0 1.0 2.0) +( 8.0 1.0 2.0) +( 9.0 1.0 2.0) +( 10.0 1.0 2.0) +( 0.0 2.0 2.0) +( 1.0 2.0 2.0) +( 2.0 2.0 2.0) +( 3.0 2.0 2.0) +( 4.0 2.0 2.0) +( 5.0 2.0 2.0) +( 6.0 2.0 2.0) +( 7.0 2.0 2.0) +( 8.0 2.0 2.0) +( 9.0 2.0 2.0) +( 10.0 2.0 2.0) +( 0.0 3.0 2.0) +( 1.0 3.0 2.0) +( 2.0 3.0 2.0) +( 3.0 3.0 2.0) +( 4.0 3.0 2.0) +( 5.0 3.0 2.0) +( 6.0 3.0 2.0) +( 7.0 3.0 2.0) +( 8.0 3.0 2.0) +( 9.0 3.0 2.0) +( 10.0 3.0 2.0) +( 0.0 4.0 2.0) +( 1.0 4.0 2.0) +( 2.0 4.0 2.0) +( 3.0 4.0 2.0) +( 4.0 4.0 2.0) +( 5.0 4.0 2.0) +( 6.0 4.0 2.0) +( 7.0 4.0 2.0) +( 8.0 4.0 2.0) +( 9.0 4.0 2.0) +( 10.0 4.0 2.0) +( 0.0 5.0 2.0) +( 1.0 5.0 2.0) +( 2.0 5.0 2.0) +( 3.0 5.0 2.0) +( 4.0 5.0 2.0) +( 5.0 5.0 2.0) +( 6.0 5.0 2.0) +( 7.0 5.0 2.0) +( 8.0 5.0 2.0) +( 9.0 5.0 2.0) +( 10.0 5.0 2.0) +( 0.0 6.0 2.0) +( 1.0 6.0 2.0) +( 2.0 6.0 2.0) +( 3.0 6.0 2.0) +( 4.0 6.0 2.0) +( 5.0 6.0 2.0) +( 6.0 6.0 2.0) +( 7.0 6.0 2.0) +( 8.0 6.0 2.0) +( 9.0 6.0 2.0) +( 10.0 6.0 2.0) +( 0.0 7.0 2.0) +( 1.0 7.0 2.0) +( 2.0 7.0 2.0) +( 3.0 7.0 2.0) +( 4.0 7.0 2.0) +( 5.0 7.0 2.0) +( 6.0 7.0 2.0) +( 7.0 7.0 2.0) +( 8.0 7.0 2.0) +( 9.0 7.0 2.0) +( 10.0 7.0 2.0) +( 0.0 0.0 3.0) +( 1.0 0.0 3.0) +( 2.0 0.0 3.0) +( 3.0 0.0 3.0) +( 4.0 0.0 3.0) +( 5.0 0.0 3.0) +( 6.0 0.0 3.0) +( 7.0 0.0 3.0) +( 8.0 0.0 3.0) +( 9.0 0.0 3.0) +( 10.0 0.0 3.0) +( 0.0 1.0 3.0) +( 1.0 1.0 3.0) +( 2.0 1.0 3.0) +( 3.0 1.0 3.0) +( 4.0 1.0 3.0) +( 5.0 1.0 3.0) +( 6.0 1.0 3.0) +( 7.0 1.0 3.0) +( 8.0 1.0 3.0) +( 9.0 1.0 3.0) +( 10.0 1.0 3.0) +( 0.0 2.0 3.0) +( 1.0 2.0 3.0) +( 2.0 2.0 3.0) +( 3.0 2.0 3.0) +( 4.0 2.0 3.0) +( 5.0 2.0 3.0) +( 6.0 2.0 3.0) +( 7.0 2.0 3.0) +( 8.0 2.0 3.0) +( 9.0 2.0 3.0) +( 10.0 2.0 3.0) +( 0.0 3.0 3.0) +( 1.0 3.0 3.0) +( 2.0 3.0 3.0) +( 3.0 3.0 3.0) +( 4.0 3.0 3.0) +( 5.0 3.0 3.0) +( 6.0 3.0 3.0) +( 7.0 3.0 3.0) +( 8.0 3.0 3.0) +( 9.0 3.0 3.0) +( 10.0 3.0 3.0) +( 0.0 4.0 3.0) +( 1.0 4.0 3.0) +( 2.0 4.0 3.0) +( 3.0 4.0 3.0) +( 4.0 4.0 3.0) +( 5.0 4.0 3.0) +( 6.0 4.0 3.0) +( 7.0 4.0 3.0) +( 8.0 4.0 3.0) +( 9.0 4.0 3.0) +( 10.0 4.0 3.0) +( 0.0 5.0 3.0) +( 1.0 5.0 3.0) +( 2.0 5.0 3.0) +( 3.0 5.0 3.0) +( 4.0 5.0 3.0) +( 5.0 5.0 3.0) +( 6.0 5.0 3.0) +( 7.0 5.0 3.0) +( 8.0 5.0 3.0) +( 9.0 5.0 3.0) +( 10.0 5.0 3.0) +( 0.0 6.0 3.0) +( 1.0 6.0 3.0) +( 2.0 6.0 3.0) +( 3.0 6.0 3.0) +( 4.0 6.0 3.0) +( 5.0 6.0 3.0) +( 6.0 6.0 3.0) +( 7.0 6.0 3.0) +( 8.0 6.0 3.0) +( 9.0 6.0 3.0) +( 10.0 6.0 3.0) +( 0.0 7.0 3.0) +( 1.0 7.0 3.0) +( 2.0 7.0 3.0) +( 3.0 7.0 3.0) +( 4.0 7.0 3.0) +( 5.0 7.0 3.0) +( 6.0 7.0 3.0) +( 7.0 7.0 3.0) +( 8.0 7.0 3.0) +( 9.0 7.0 3.0) +( 10.0 7.0 3.0) +( 0.0 0.0 4.0) +( 1.0 0.0 4.0) +( 2.0 0.0 4.0) +( 3.0 0.0 4.0) +( 4.0 0.0 4.0) +( 5.0 0.0 4.0) +( 6.0 0.0 4.0) +( 7.0 0.0 4.0) +( 8.0 0.0 4.0) +( 9.0 0.0 4.0) +( 10.0 0.0 4.0) +( 0.0 1.0 4.0) +( 1.0 1.0 4.0) +( 2.0 1.0 4.0) +( 3.0 1.0 4.0) +( 4.0 1.0 4.0) +( 5.0 1.0 4.0) +( 6.0 1.0 4.0) +( 7.0 1.0 4.0) +( 8.0 1.0 4.0) +( 9.0 1.0 4.0) +( 10.0 1.0 4.0) +( 0.0 2.0 4.0) +( 1.0 2.0 4.0) +( 2.0 2.0 4.0) +( 3.0 2.0 4.0) +( 4.0 2.0 4.0) +( 5.0 2.0 4.0) +( 6.0 2.0 4.0) +( 7.0 2.0 4.0) +( 8.0 2.0 4.0) +( 9.0 2.0 4.0) +( 10.0 2.0 4.0) +( 0.0 3.0 4.0) +( 1.0 3.0 4.0) +( 2.0 3.0 4.0) +( 3.0 3.0 4.0) +( 4.0 3.0 4.0) +( 5.0 3.0 4.0) +( 6.0 3.0 4.0) +( 7.0 3.0 4.0) +( 8.0 3.0 4.0) +( 9.0 3.0 4.0) +( 10.0 3.0 4.0) +( 0.0 4.0 4.0) +( 1.0 4.0 4.0) +( 2.0 4.0 4.0) +( 3.0 4.0 4.0) +( 4.0 4.0 4.0) +( 5.0 4.0 4.0) +( 6.0 4.0 4.0) +( 7.0 4.0 4.0) +( 8.0 4.0 4.0) +( 9.0 4.0 4.0) +( 10.0 4.0 4.0) +( 0.0 5.0 4.0) +( 1.0 5.0 4.0) +( 2.0 5.0 4.0) +( 3.0 5.0 4.0) +( 4.0 5.0 4.0) +( 5.0 5.0 4.0) +( 6.0 5.0 4.0) +( 7.0 5.0 4.0) +( 8.0 5.0 4.0) +( 9.0 5.0 4.0) +( 10.0 5.0 4.0) +( 0.0 6.0 4.0) +( 1.0 6.0 4.0) +( 2.0 6.0 4.0) +( 3.0 6.0 4.0) +( 4.0 6.0 4.0) +( 5.0 6.0 4.0) +( 6.0 6.0 4.0) +( 7.0 6.0 4.0) +( 8.0 6.0 4.0) +( 9.0 6.0 4.0) +( 10.0 6.0 4.0) +( 0.0 7.0 4.0) +( 1.0 7.0 4.0) +( 2.0 7.0 4.0) +( 3.0 7.0 4.0) +( 4.0 7.0 4.0) +( 5.0 7.0 4.0) +( 6.0 7.0 4.0) +( 7.0 7.0 4.0) +( 8.0 7.0 4.0) +( 9.0 7.0 4.0) +( 10.0 7.0 4.0) +( 0.0 0.0 5.0) +( 1.0 0.0 5.0) +( 2.0 0.0 5.0) +( 3.0 0.0 5.0) +( 4.0 0.0 5.0) +( 5.0 0.0 5.0) +( 6.0 0.0 5.0) +( 7.0 0.0 5.0) +( 8.0 0.0 5.0) +( 9.0 0.0 5.0) +( 10.0 0.0 5.0) +( 0.0 1.0 5.0) +( 1.0 1.0 5.0) +( 2.0 1.0 5.0) +( 3.0 1.0 5.0) +( 4.0 1.0 5.0) +( 5.0 1.0 5.0) +( 6.0 1.0 5.0) +( 7.0 1.0 5.0) +( 8.0 1.0 5.0) +( 9.0 1.0 5.0) +( 10.0 1.0 5.0) +( 0.0 2.0 5.0) +( 1.0 2.0 5.0) +( 2.0 2.0 5.0) +( 3.0 2.0 5.0) +( 4.0 2.0 5.0) +( 5.0 2.0 5.0) +( 6.0 2.0 5.0) +( 7.0 2.0 5.0) +( 8.0 2.0 5.0) +( 9.0 2.0 5.0) +( 10.0 2.0 5.0) +( 0.0 3.0 5.0) +( 1.0 3.0 5.0) +( 2.0 3.0 5.0) +( 3.0 3.0 5.0) +( 4.0 3.0 5.0) +( 5.0 3.0 5.0) +( 6.0 3.0 5.0) +( 7.0 3.0 5.0) +( 8.0 3.0 5.0) +( 9.0 3.0 5.0) +( 10.0 3.0 5.0) +( 0.0 4.0 5.0) +( 1.0 4.0 5.0) +( 2.0 4.0 5.0) +( 3.0 4.0 5.0) +( 4.0 4.0 5.0) +( 5.0 4.0 5.0) +( 6.0 4.0 5.0) +( 7.0 4.0 5.0) +( 8.0 4.0 5.0) +( 9.0 4.0 5.0) +( 10.0 4.0 5.0) +( 0.0 5.0 5.0) +( 1.0 5.0 5.0) +( 2.0 5.0 5.0) +( 3.0 5.0 5.0) +( 4.0 5.0 5.0) +( 5.0 5.0 5.0) +( 6.0 5.0 5.0) +( 7.0 5.0 5.0) +( 8.0 5.0 5.0) +( 9.0 5.0 5.0) +( 10.0 5.0 5.0) +( 0.0 6.0 5.0) +( 1.0 6.0 5.0) +( 2.0 6.0 5.0) +( 3.0 6.0 5.0) +( 4.0 6.0 5.0) +( 5.0 6.0 5.0) +( 6.0 6.0 5.0) +( 7.0 6.0 5.0) +( 8.0 6.0 5.0) +( 9.0 6.0 5.0) +( 10.0 6.0 5.0) +( 0.0 7.0 5.0) +( 1.0 7.0 5.0) +( 2.0 7.0 5.0) +( 3.0 7.0 5.0) +( 4.0 7.0 5.0) +( 5.0 7.0 5.0) +( 6.0 7.0 5.0) +( 7.0 7.0 5.0) +( 8.0 7.0 5.0) +( 9.0 7.0 5.0) +( 10.0 7.0 5.0) +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +blocks +( + + //block 0 +hex (0 1 12 11 88 89 100 99 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 1 +hex (1 2 13 12 89 90 101 100 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 2 +hex (2 3 14 13 90 91 102 101 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 3 +hex (3 4 15 14 91 92 103 102 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 4 +hex (4 5 16 15 92 93 104 103 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 5 +hex (5 6 17 16 93 94 105 104 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 6 +hex (6 7 18 17 94 95 106 105 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 7 +hex (7 8 19 18 95 96 107 106 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 8 +hex (8 9 20 19 96 97 108 107 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 9 +hex (9 10 21 20 97 98 109 108 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 10 +hex (97 98 109 108 185 186 197 196 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 11 +hex (185 186 197 196 273 274 285 284 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 12 +hex (273 274 285 284 361 362 373 372 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 13 +hex (361 362 373 372 449 450 461 460 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 14 +hex (360 361 372 371 448 449 460 459 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 15 +hex (359 360 371 370 447 448 459 458 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 16 +hex (358 359 370 369 446 447 458 457 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 17 +hex (357 358 369 368 445 446 457 456 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 18 +hex (356 357 368 367 444 445 456 455 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 19 +hex (355 356 367 366 443 444 455 454 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 20 +hex (354 355 366 365 442 443 454 453 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 21 +hex (353 354 365 364 441 442 453 452 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 22 +hex (352 353 364 363 440 441 452 451 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 23 +hex (363 364 375 374 451 452 463 462 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 24 +hex (374 375 386 385 462 463 474 473 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 25 +hex (385 386 397 396 473 474 485 484 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 26 +hex (396 397 408 407 484 485 496 495 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 27 +hex (407 408 419 418 495 496 507 506 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 28 +hex (418 419 430 429 506 507 518 517 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 29 +hex (308 309 320 319 396 397 408 407 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 30 +hex (220 221 232 231 308 309 320 319 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 31 +hex (132 133 144 143 220 221 232 231 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 32 +hex (44 45 56 55 132 133 144 143 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 33 +hex (55 56 67 66 143 144 155 154 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 34 +hex (66 67 78 77 154 155 166 165 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 35 +hex (33 34 45 44 121 122 133 132 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 36 +hex (22 23 34 33 110 111 122 121 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 37 +hex (11 12 23 22 99 100 111 110 ) +( 10 10 10 ) +SimpleGrading (1 1 1) +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +defaultPatch +{ type wall;} + +patches +( +); diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/controlDict b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/controlDict similarity index 95% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/controlDict rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/controlDict index bda655db..7f457c4b 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/controlDict +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/controlDict @@ -22,11 +22,11 @@ startTime 0; stopAt endTime; -endTime 600; +endTime 200; deltaT 0.0001; -writeControl runTime; +writeControl adjustableRunTime; writeInterval 2; @@ -50,9 +50,10 @@ maxCo 0.5; maxDeltaT 0.01; + functions { - + #includeFunc writeObjects(d.gas) #includeFunc writeObjects(thermo:rho.gas) #includeFunc writeObjects(thermo:rho.liquid) diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/decomposeParDict b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/decomposeParDict new file mode 100755 index 00000000..f8397e73 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/decomposeParDict @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 3.0.x | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 16; + +method scotch; + +hierarchicalCoeffs +{ + n (4 4 1); + delta 0.001; + order xyz; +} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvConstraints b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvConstraints new file mode 100644 index 00000000..334f1c8f --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvConstraints @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvConstraints; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +limitp +{ + type limitPressure; + + min 1e4; +} +limitUliq +{ + type limitVelocity; + active yes; + U U.liquid; + selectionMode all; + max 1e1; +} +limitUgas +{ + type limitVelocity; + active yes; + U U.gas; + selectionMode all; + max 2e1; +} +limitTgas +{ + type limitTemperature; + selectionMode all; + min 290; + max 310; + phase gas; +} +limitTliq +{ + type limitTemperature; + selectionMode all; + min 290; + max 310; + phase liquid; +} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvSchemes b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvSchemes new file mode 100644 index 00000000..52e6e13a --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvSchemes @@ -0,0 +1,70 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; + limited cellLimited Gauss linear 1; +} + +divSchemes +{ + default none; + + "div\(phi,alpha.*\)" Gauss vanLeer; + + "div\(phir,alpha.*,alpha.*\)" Gauss vanLeer; + + "div\(alphaRhoPhi.*,U.*\)" Gauss limitedLinearV 1; + "div\(phi.*,U.*\)" Gauss limitedLinearV 1; + "div\(alphaRhoPhi.*,Yi\)" Gauss limitedLinear 1; + "div\(alphaRhoPhi.*,(h|e).*\)" Gauss limitedLinear 1; + "div\(alphaRhoPhi.*,(K|k|epsilon|omega).*\)" Gauss limitedLinear 1; + "div\(alphaPhi.*,f.*\)" Gauss limitedLinear 1; + "div\(alphaRhoPhi.*,\(p\|thermo:rho.*\)\)" Gauss limitedLinear 1; + + "div\(phim,(k|epsilon)m\)" Gauss upwind; + "div\(\(\(\(alpha.*\*thermo:rho.*\)*nuEff.*\)*dev2\(T\(grad\(U.*\)\)\)\)\)" Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +wallDist +{ + method Poisson; + nRequired true; +} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvSolution b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvSolution new file mode 100644 index 00000000..2e69fdfa --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/fvSolution @@ -0,0 +1,120 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha.*" + { + nAlphaCorr 2; + nAlphaSubCycles 5; + } + + bubbles + { + nCorr 1; + tolerance 1e-4; + scale true; + solveOnFinalIterOnly true; + sourceUpdateInterval 1; + } + + p_rgh + { + solver GAMG; + smoother DIC; + tolerance 1e-7; + relTol 0; + } + + p_rghFinal + { + $p_rgh; + relTol 0; + } + + "(k|omega).*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-7; + relTol 0; + minIter 1; + } + + "(e|h).*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + minIter 0; + maxIter 3; + } + + "f.*" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-6; + relTol 0; + } + + "Yi.*" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-12; + relTol 0; + residualAlpha 1e-8; + } + + "U.*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-5; + relTol 0; + minIter 1; + } + + yPsi + { + solver PCG; + preconditioner DIC; + tolerance 1e-10; + relTol 0; + } + +} + +PIMPLE +{ + nOuterCorrectors 3; + nCorrectors 1; + nNonOrthogonalCorrectors 0; + +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} + + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/inlets_outlets.json b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/inlets_outlets.json new file mode 100644 index 00000000..2b53da73 --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/inlets_outlets.json @@ -0,0 +1,28 @@ +{ + "Geometry": { + "OverallDomain": { + "x" : {"nblocks": 10, "size_per_block": 1.0}, + "y" : {"nblocks": 11, "size_per_block": 1.0}, + "z" : {"nblocks": 5, "size_per_block": 1.0} + }, + "Fluids": [ + [ [0,0,0], [9,0,0] ], + [ [9,0,0], [9,0,4] ], + [ [9,0,4], [0,0,4] ], + [ [0,1,4], [0,4,4] ], + [ [0,4,4], [0,10,4] ], + [ [0,4,4], [0,4,0] ], + [ [0,4,0], [0,10,0] ], + [ [0,4,0], [0,1,0] ] + ] + }, + "inlets": [ + {"branch_id": 0, "type": "circle", "frac_space": 0.2222222222222222, "normal_dir": 1, "radius": 0.4, "nelements": 50, "block_pos": "bottom"}, + {"branch_id": 0, "type": "circle", "frac_space": 0.5, "radius": 0.4, "normal_dir": 1,"nelements": 50, "block_pos": "bottom"}, + {"branch_id": 0, "type": "circle", "frac_space": 0.7777777777777778, "radius": 0.4, "normal_dir": 1,"nelements": 50, "block_pos": "bottom"} + ], + "outlets": [ + {"branch_id": 6, "type": "circle", "frac_space": 1, "normal_dir": 1, "radius": 0.4, "nelements": 50, "block_pos": "top"}, + {"branch_id": 4, "type": "circle", "frac_space": 1, "normal_dir": 1, "radius": 0.4, "nelements": 50, "block_pos": "top"} + ] +} diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/mesh.json b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/mesh.json new file mode 100644 index 00000000..29841d7e --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/mesh.json @@ -0,0 +1,26 @@ +{ + "Meshing": { + "Blockwise": { + "x" : 10, + "y" : 10, + "z" : 10 + } + }, + "Geometry": { + "OverallDomain": { + "x" : {"nblocks": 10, "size_per_block": 1.0}, + "y" : {"nblocks": 11, "size_per_block": 1.0}, + "z" : {"nblocks": 5, "size_per_block": 1.0} + }, + "Fluids": [ + [ [0,0,0], [9,0,0] ], + [ [9,0,0], [9,0,4] ], + [ [9,0,4], [0,0,4] ], + [ [0,1,4], [0,4,4] ], + [ [0,4,4], [0,10,4] ], + [ [0,4,4], [0,4,0] ], + [ [0,4,0], [0,10,0] ], + [ [0,4,0], [0,1,0] ] + ] + } +} diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/mixers.json b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/mixers.json similarity index 91% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/mixers.json rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/mixers.json index e49c9a7c..b6224fb7 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/mixers.json +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/mixers.json @@ -24,6 +24,6 @@ ] }, "mixers": [ - {"branch_id": 2, "frac_space": 0.5, "start_time": 1, "power": 0, "sign": "+"} + {"branch_id": 2, "frac_space": 0.5, "start_time": 4, "power": 1500, "sign": "+"} ] } diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/system/setFieldsDict b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/setFieldsDict similarity index 100% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/system/setFieldsDict rename to OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/system/setFieldsDict diff --git a/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/writeGlobalVars.py b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/writeGlobalVars.py new file mode 100644 index 00000000..0594eccc --- /dev/null +++ b/OFsolvers/tutorial_cases/loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup/writeGlobalVars.py @@ -0,0 +1,47 @@ +import os + +import numpy as np + +from bird.utilities.ofio import * + + +def writeGvars(inletA, liqVol): + filename_tmp = os.path.join("constant", "globalVars_temp") + with open(filename_tmp, "r+") as f: + lines = f.readlines() + filename = os.path.join("constant", "globalVars") + with open(filename, "w+") as f: + for line in lines: + if line.startswith("inletA"): + f.write(f"inletA\t{inletA:g};\n") + elif line.startswith("liqVol"): + f.write(f"liqVol\t{liqVol:g};\n") + else: + f.write(line) + + +def readInletArea(): + filename = os.path.join( + "postProcessing", + "patchIntegrate(patch=inlet,field=alpha.gas)", + "0", + "surfaceFieldValue.dat", + ) + with open(filename, "r+") as f: + lines = f.readlines() + return float(lines[4].split()[-1]) + + +def getLiqVol(): + cellCentres = readMesh(os.path.join(".", f"meshCellCentres_0.obj")) + volume_field = readOFScal(os.path.join("0", "V"), len(cellCentres)) + alpha_field = readOFScal( + os.path.join("0", "alpha.liquid"), len(cellCentres) + ) + return np.sum(volume_field * alpha_field) + + +if __name__ == "__main__": + A = readInletArea() + V = getLiqVol() + writeGvars(A, V) diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/README.md b/OFsolvers/tutorial_cases/loop_reactor_reacting/README.md deleted file mode 100644 index dc65411c..00000000 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/README.md +++ /dev/null @@ -1,15 +0,0 @@ -* Scaled up loop reactor with 608m3 of liq -* Reaction kinetics transforming CO2 to CH4 -* No mixers enabled (power = 0 in the fvModels) -* Setup with constant diameter but can use PBE by changing the line -`cp constant/phaseProperties_constantd constant/phaseProperties` -into -`cp constant/phaseProperties_pbe constant/phaseProperties` -* writeGlobalVars.py writes `constant/globalVars` from `constant/globalVars_tmp` - - -## Running the case - -bash run.sh - - diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/run.sh b/OFsolvers/tutorial_cases/loop_reactor_reacting/run.sh deleted file mode 100644 index af2b90bd..00000000 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/run.sh +++ /dev/null @@ -1,70 +0,0 @@ -if ! type "python" &> /dev/null; then - echo " could not be found" - echo "Skipping Mesh generation" -else - # Generate blockmeshDict - python ../../../applications/write_block_rect_mesh.py -i system/mesh.json -o system - - # Generate boundary stl - python ../../../applications/write_stl_patch.py -i system/inlets_outlets.json - - # Generate mixers - #python ../../../applications/write_dynMix_fvModels.py -i system/mixers.json -o constant - -fi - - -if ! type "blockMesh" &> /dev/null; then - echo " could not be found" - echo "OpenFoam is likely not installed, skipping run" -else - # Clean case - ./Allclean - - # Mesh gen - blockMesh -dict system/blockMeshDict - - # Inlet BC - surfaceToPatch -tol 1e-3 inlets.stl - export newmeshdir=$(foamListTimes -latestTime) - rm -rf constant/polyMesh/ - cp -r $newmeshdir/polyMesh ./constant - rm -rf $newmeshdir - cp constant/polyMesh/boundary /tmp - sed -i -e 's/inlets\.stl/inlet/g' /tmp/boundary - cat /tmp/boundary > constant/polyMesh/boundary - - # Outlet BC - surfaceToPatch -tol 1e-3 outlets.stl - export newmeshdir=$(foamListTimes -latestTime) - rm -rf constant/polyMesh/ - cp -r $newmeshdir/polyMesh ./constant - rm -rf $newmeshdir - cp constant/polyMesh/boundary /tmp - sed -i -e 's/outlets\.stl/outlet/g' /tmp/boundary - cat /tmp/boundary > constant/polyMesh/boundary - - # Scale - transformPoints "scale=(2.7615275385627096 2.7615275385627096 2.7615275385627096)" - - # setup IC - cp -r 0.orig 0 - setFields - - # Setup mass flow rate - # Get inlet area - postProcess -func 'patchIntegrate(patch="inlet", field="alpha.gas")' - postProcess -func writeCellVolumes - writeMeshObj - - echo PRESTEP 3 - python writeGlobalVars.py - cp constant/phaseProperties_constantd constant/phaseProperties - - # Run - multiphaseEulerFoam -fi - - - - diff --git a/README.md b/README.md index effc2fb7..2f114366 100644 --- a/README.md +++ b/README.md @@ -341,7 +341,7 @@ To cite BioReactorDesign use these articles on [CO2 interphase mass transfer (op and on [butanediol synthesis](https://www.sciencedirect.com/science/article/pii/S0263876223004689) ``` @article{hassanaly2024inverse, - title={Bayesian calibration of bubble size dynamics applied to \ce{CO2} gas fermenters}, + title={Inverse modeling of bubble size dynamics for interphase mass transfer and gas holdup in CO2 bubble column reactors}, author={Hassanaly, Malik and Parra-Alvarez, John M. and Rahimi, Mohammad J. and Sitaraman, Hariswaran}, journal={Under Review}, year={2024}, diff --git a/applications/GA_opt/ga2sim.py b/applications/GA_opt/ga2sim.py new file mode 100644 index 00000000..a5526bff --- /dev/null +++ b/applications/GA_opt/ga2sim.py @@ -0,0 +1,124 @@ +import os +import pickle +import shutil + +import numpy as np + +from bird import BIRD_CASE_DIR +from bird.preprocess.json_gen.design_io import * +from bird.preprocess.json_gen.generate_designs import * + + +def optimization_setup(): + # spots on the branches where we can place sparger or mixers + branchcom_spots = {} + branchcom_spots[0] = np.linspace(0.2, 0.8, 4) + branchcom_spots[1] = np.linspace(0.2, 0.8, 3) + branchcom_spots[2] = np.linspace(0.2, 0.8, 4) + # branches where the sparger and mixers are placed + branches_com = [0, 1, 2] + return branchcom_spots, branches_com + + +def check_ga_samples(ga_samples): + # we expect ga_samples of dimension (N, 11), where N is the number of samples in the batch + assert len(ga_samples.shape) == 2 + assert ga_samples.shape[1] == 11 + assert np.amax(ga_samples) <= 2 + assert np.amin(ga_samples) >= 0 + + +def ga2sim(ga_samples): + branchcom_spots, branches_com = optimization_setup() + check_ga_samples(ga_samples) + config_dict = {} + # Split ga_samples across the 3 branches + split_ga_samples = np.split(ga_samples, [4, 7], axis=1) + n_batch = ga_samples.shape[0] + for i_batch in range(n_batch): + config = {} + for branch in branches_com: + config[branch] = split_ga_samples[branch][i_batch, :] + config_dict[i_batch] = config + + return config_dict + + +def setup_sim_batch( + ga_samples, vvm_v=0.4, pow_v=6000, study_folder="GA_batch" +): + # GA_batch + check_ga_samples(ga_samples) + n_batch = ga_samples.shape[0] + branchcom_spots, branches_com = optimization_setup() + + # Generate cases + config_dict = ga2sim(ga_samples) + generate_scaledup_reactor_cases( + config_dict, + branchcom_spots=branchcom_spots, + vvm=vvm_v, + power=pow_v, + constantD=True, + study_folder=study_folder, + ) + write_script_start(f"{study_folder}/many_scripts_start", n_batch) + write_script_post(f"{study_folder}/many_scripts_post", n_batch) + write_prep(f"{study_folder}/prep.sh", n_batch) + save_config_dict(f"{study_folder}/configs.pkl", config_dict) + save_config_dict(f"{study_folder}/branchcom_spots.pkl", branchcom_spots) + + +if __name__ == "__main__": + import argparse + + parser = argparse.ArgumentParser(description="GA setup") + parser.add_argument( + "-bf", + "--batch_folder", + type=str, + metavar="", + required=False, + help="Folder that contains the batch of sims", + default="GAbatch_0.4vvm_6kW", + ) + parser.add_argument( + "-vvm", + "--vvm", + type=float, + metavar="", + required=False, + help="Volume flow rate", + default=0.4, + ) + parser.add_argument( + "-pow", + "--power", + type=float, + metavar="", + required=False, + help="mixer power", + default=6000, + ) + parser.add_argument( + "-gas", + "--ga_sample_file", + type=str, + metavar="", + required=False, + help="file containing the ga samples to execute", + default=None, + ) + args, unknown = parser.parse_known_args() + + if args.ga_sample_file is None: + n_batch = 3 + ga_samples = np.random.choice([0, 1, 2], size=(n_batch, 11)) + else: + ga_samples = np.load(args.ga_sample_file) + vvm_v = args.vvm + pow_v = args.power + study_folder = args.batch_folder + setup_sim_batch( + ga_samples, vvm_v=vvm_v, pow_v=pow_v, study_folder=study_folder + ) diff --git a/applications/GA_opt/read_qoi.py b/applications/GA_opt/read_qoi.py new file mode 100644 index 00000000..e1924121 --- /dev/null +++ b/applications/GA_opt/read_qoi.py @@ -0,0 +1,51 @@ +import argparse +import os + +import numpy as np + + +def count_sim(dirlist): + count = 0 + for entry in dirlist: + if entry.startswith("Sim"): + count += 1 + return count + + +def read_qoi(case_folder): + filen = os.path.join(case_folder, "qoi.txt") + if os.path.isfile(filen): + with open(filen, "r+") as f: + try: + line = f.readline() + qois = line.split(",") + except: + qois = [np.nan, np.nan] + return float(qois[0]), float(qois[1]) + else: + return np.nan, np.nan + + +parser = argparse.ArgumentParser(description="QOI reader") +parser.add_argument( + "-bf", + "--batch_folder", + type=str, + metavar="", + required=True, + help="Folder that contains the batch of sims", +) +args, unknown = parser.parse_known_args() + + +dir_list = os.listdir(args.batch_folder) +n_sim = count_sim(dir_list) +qoi = np.zeros(n_sim) +qoi_err = np.zeros(n_sim) +for isim in range(n_sim): + case_folder = os.path.join(args.batch_folder, f"Sim_{isim}") + qoi[isim], qoi_err[isim] = read_qoi(case_folder) + +np.savez( + os.path.join(args.batch_folder, "results.npz"), qoi=qoi, qoi_err=qoi_err +) diff --git a/applications/GA_opt/runGA.sh b/applications/GA_opt/runGA.sh new file mode 100644 index 00000000..210010fc --- /dev/null +++ b/applications/GA_opt/runGA.sh @@ -0,0 +1,14 @@ +for ga_iter in NiterGA: + 1) decide next batch of GA samples + 2) save samples as 'samples_batch${ga_iter}.npy' + 3) setup the next batch of CFD runs + python ga2sim.py -bf GAbatch${ga_iter}_0.4vvm_6kW -vvm 0.4 -pow 6000 --ga_sample_file samples_batch${ga_iter}.npy + 4) run the CFD sim + cd GAbatch${ga_iter}_0.4vvm_6kW + bash many_scripts_start + 5) waituntil done + 6) compute QOI + cd GAbatch${ga_iter}_0.4vvm_6kW + bash many_scripts_post + 7) Store qoi of batch in numpy array + python read_qoi.py -bf GAbatch${ga_iter}_0.4vvm_6kW diff --git a/applications/Random_opt/randsim.py b/applications/Random_opt/randsim.py new file mode 100644 index 00000000..a3b49d53 --- /dev/null +++ b/applications/Random_opt/randsim.py @@ -0,0 +1,100 @@ +import os +import pickle +import shutil + +import numpy as np + +from bird import BIRD_CASE_DIR +from bird.preprocess.json_gen.design_io import * +from bird.preprocess.json_gen.generate_designs import * + + +def optimization_setup(): + # spots on the branches where we can place sparger or mixers + branchcom_spots = {} + branchcom_spots[0] = np.linspace(0.2, 0.8, 4) + branchcom_spots[1] = np.linspace(0.2, 0.8, 3) + branchcom_spots[2] = np.linspace(0.2, 0.8, 4) + # branches where the sparger and mixers are placed + branches_com = [0, 1, 2] + return branchcom_spots, branches_com + + +def random_sample(branches_com, branchcom_spots, config_dict={}): + config = {} + # choices = ["mix", "sparger", "none"] + choices_com = [0, 1, 2] + for branch in branches_com: + config[branch] = np.random.choice( + choices_com, size=len(branchcom_spots[branch]) + ) + + existing = False + new_config_key = 0 + for old_key_conf in config_dict: + if compare_config(config_dict[old_key_conf], config): + existing = True + print("FOUND SAME CONFIG") + return config_dict + new_config_key = old_key_conf + 1 + + if check_config(config): + config_dict[new_config_key] = config + + return config_dict + + +if __name__ == "__main__": + branchcom_spots, branches_com = optimization_setup() + n_sim = 4 + config_dict = {} + for i in range(n_sim): + config_dict = random_sample( + branches_com, branchcom_spots, config_dict=config_dict + ) + + vvm_l = [0.4] + pow_l = [2] + + for vvm_v in vvm_l: + vvm_str = str(vvm_v).replace(".", "_") + for pow_v in pow_l: + study_folder = f"study_{vvm_str}vvm_{pow_v}W" + generate_small_reactor_cases( + config_dict, + branchcom_spots, + vvm=vvm_v, + power=pow_v, + constantD=True, + study_folder=study_folder, + ) + write_script_start(f"{study_folder}/many_scripts_start", n_sim) + write_script_post(f"{study_folder}/many_scripts_post", n_sim) + write_prep(f"{study_folder}/prep.sh", n_sim) + save_config_dict(f"{study_folder}/configs.pkl", config_dict) + save_config_dict( + f"{study_folder}/branchcom_spots.pkl", branchcom_spots + ) + + vvm_l = [0.1, 0.4] + pow_l = [6000] + + for vvm_v in vvm_l: + vvm_str = str(vvm_v).replace(".", "_") + for pow_v in pow_l: + study_folder = f"study_scaleup_{vvm_str}vvm_{pow_v}W" + generate_scaledup_reactor_cases( + config_dict, + branchcom_spots, + vvm=vvm_v, + power=pow_v, + constantD=True, + study_folder=study_folder, + ) + write_script_start(f"{study_folder}/many_scripts_start", n_sim) + write_script_post(f"{study_folder}/many_scripts_post", n_sim) + write_prep(f"{study_folder}/prep.sh", n_sim) + save_config_dict(f"{study_folder}/configs.pkl", config_dict) + save_config_dict( + f"{study_folder}/branchcom_spots.pkl", branchcom_spots + ) diff --git a/applications/Random_opt/read_qoi.py b/applications/Random_opt/read_qoi.py new file mode 100644 index 00000000..e1924121 --- /dev/null +++ b/applications/Random_opt/read_qoi.py @@ -0,0 +1,51 @@ +import argparse +import os + +import numpy as np + + +def count_sim(dirlist): + count = 0 + for entry in dirlist: + if entry.startswith("Sim"): + count += 1 + return count + + +def read_qoi(case_folder): + filen = os.path.join(case_folder, "qoi.txt") + if os.path.isfile(filen): + with open(filen, "r+") as f: + try: + line = f.readline() + qois = line.split(",") + except: + qois = [np.nan, np.nan] + return float(qois[0]), float(qois[1]) + else: + return np.nan, np.nan + + +parser = argparse.ArgumentParser(description="QOI reader") +parser.add_argument( + "-bf", + "--batch_folder", + type=str, + metavar="", + required=True, + help="Folder that contains the batch of sims", +) +args, unknown = parser.parse_known_args() + + +dir_list = os.listdir(args.batch_folder) +n_sim = count_sim(dir_list) +qoi = np.zeros(n_sim) +qoi_err = np.zeros(n_sim) +for isim in range(n_sim): + case_folder = os.path.join(args.batch_folder, f"Sim_{isim}") + qoi[isim], qoi_err[isim] = read_qoi(case_folder) + +np.savez( + os.path.join(args.batch_folder, "results.npz"), qoi=qoi, qoi_err=qoi_err +) diff --git a/applications/Random_opt/runGA.sh b/applications/Random_opt/runGA.sh new file mode 100644 index 00000000..210010fc --- /dev/null +++ b/applications/Random_opt/runGA.sh @@ -0,0 +1,14 @@ +for ga_iter in NiterGA: + 1) decide next batch of GA samples + 2) save samples as 'samples_batch${ga_iter}.npy' + 3) setup the next batch of CFD runs + python ga2sim.py -bf GAbatch${ga_iter}_0.4vvm_6kW -vvm 0.4 -pow 6000 --ga_sample_file samples_batch${ga_iter}.npy + 4) run the CFD sim + cd GAbatch${ga_iter}_0.4vvm_6kW + bash many_scripts_start + 5) waituntil done + 6) compute QOI + cd GAbatch${ga_iter}_0.4vvm_6kW + bash many_scripts_post + 7) Store qoi of batch in numpy array + python read_qoi.py -bf GAbatch${ga_iter}_0.4vvm_6kW diff --git a/applications/convert_dim.py b/applications/convert_dim.py new file mode 100644 index 00000000..c739e1dc --- /dev/null +++ b/applications/convert_dim.py @@ -0,0 +1,43 @@ +import argparse +import os +import shutil +import sys + +from bird.preprocess.json_gen.generate_designs import ( + convert_case_dim, + replace_str_in_file, +) + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Modify case dim") + parser.add_argument( + "-i", + "--input_folder", + type=str, + metavar="", + required=False, + help="case folder input", + default=None, + ) + parser.add_argument( + "-o", + "--output_folder", + type=str, + metavar="", + required=False, + help="case folder output", + default=None, + ) + parser.add_argument( + "-f", + "--dim_factor", + type=float, + metavar="", + required=False, + help="scaling factor", + default=None, + ) + + args, unknown = parser.parse_known_args() + + convert_case_dim(args.input_folder, args.output_folder, args.dim_factor) diff --git a/applications/read_history.py b/applications/read_history.py new file mode 100644 index 00000000..d287f020 --- /dev/null +++ b/applications/read_history.py @@ -0,0 +1,243 @@ +import argparse +import os +import sys + +import numpy as np +from prettyPlot.plotting import plt, pretty_labels + +from bird.utilities.ofio import * + + +def compute_gas_holdup(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + alpha_liq = field_dict["alpha_liq"] + volume = field_dict["volume"] + holdup = np.sum((1 - alpha_liq) * volume) / np.sum(volume) + return holdup, field_dict + + +def co2liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("co2_liq" in field_dict) or field_dict["co2_liq"] is None: + co2_liq_file = os.path.join(caseFolder, timeFolder, "CO2.liquid") + co2_liq = readOFScal(co2_liq_file, nCells) + # print("computing co2 liq") + field_dict["co2_liq"] = co2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + co2_liq = field_dict["co2_liq"] + met = np.sum( + alpha_liq[indliq] * co2_liq[indliq] * volume[indliq] + ) / np.sum(volume[indliq]) + return met, field_dict + + +def cliq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("rho_liq" in field_dict) or field_dict["rho_liq"] is None: + rho_liq_file = os.path.join(caseFolder, timeFolder, "rhom") + rho_liq = readOFScal(rho_liq_file, nCells) + field_dict["rho_liq"] = rho_liq + if not ("co2_liq" in field_dict) or field_dict["co2_liq"] is None: + co2_liq_file = os.path.join(caseFolder, timeFolder, "CO2.liquid") + co2_liq = readOFScal(co2_liq_file, nCells) + # print("computing co2 liq") + field_dict["co2_liq"] = co2_liq + if not ("h2_liq" in field_dict) or field_dict["h2_liq"] is None: + h2_liq_file = os.path.join(caseFolder, timeFolder, "H2.liquid") + h2_liq = readOFScal(h2_liq_file, nCells) + # print("computing h2 liq") + field_dict["h2_liq"] = h2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + co2_liq = field_dict["co2_liq"] + h2_liq = field_dict["h2_liq"] + rho_liq = field_dict["rho_liq"] + + # c_h2 = rho_liq[indliq] * alpha_liq[indliq] * h2_liq[indliq] / 0.002016 + # c_co2 = rho_liq[indliq] * alpha_liq[indliq] * co2_liq[indliq] / 0.04401 + + c_h2 = 1000 * alpha_liq[indliq] * h2_liq[indliq] / 0.002016 + c_co2 = 1000 * alpha_liq[indliq] * co2_liq[indliq] / 0.04401 + + c_h2 = np.sum(c_h2 * volume[indliq]) / np.sum(volume[indliq]) + c_co2 = np.sum(c_co2 * volume[indliq]) / np.sum(volume[indliq]) + + return c_co2, c_h2, field_dict + + +def h2liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("h2_liq" in field_dict) or field_dict["h2_liq"] is None: + h2_liq_file = os.path.join(caseFolder, timeFolder, "H2.liquid") + h2_liq = readOFScal(h2_liq_file, nCells) + # print("computing h2 liq") + field_dict["h2_liq"] = h2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + h2_liq = field_dict["h2_liq"] + met = np.sum(alpha_liq[indliq] * h2_liq[indliq] * volume[indliq]) / np.sum( + volume[indliq] + ) + return met, field_dict + + +def vol_liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + volume = field_dict["volume"] + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.0) + liqvol = np.sum(alpha_liq[indliq] * volume[indliq]) / np.sum( + volume[indliq] + ) + return liqvol, field_dict + + +parser = argparse.ArgumentParser(description="Convergence of GH") +parser.add_argument( + "-cr", + "--case_root", + type=str, + metavar="", + required=True, + help="Case root", +) +parser.add_argument( + "-cn", + "--case_name", + type=str, + metavar="", + required=True, + help="Case name", +) +parser.add_argument( + "-df", + "--data_folder", + type=str, + metavar="", + required=False, + help="data folder name", + default="data", +) + +args, unknown = parser.parse_known_args() + + +case_root = args.case_root # "../" +case_name = args.case_name # "12_hole_sparger_snappyRefine_700rpm_opt_coeff" +case_path = os.path.join(case_root, case_name) +time_float_sorted, time_str_sorted = getCaseTimes(case_path, remove_zero=True) +cellCentres = readMesh(os.path.join(case_path, f"meshCellCentres_0.obj")) +nCells = len(cellCentres) + + +co2_history = np.zeros(len(time_str_sorted)) +c_co2_history = np.zeros(len(time_str_sorted)) +h2_history = np.zeros(len(time_str_sorted)) +c_h2_history = np.zeros(len(time_str_sorted)) +gh_history = np.zeros(len(time_str_sorted)) +liqvol_history = np.zeros(len(time_str_sorted)) +print(f"case_path = {case_path}") +field_dict = {} +for itime, time in enumerate(time_float_sorted): + time_folder = time_str_sorted[itime] + print(f"\tTime : {time_folder}") + if not field_dict == {}: + new_field_dict = {} + if "volume" in field_dict: + new_field_dict["volume"] = field_dict["volume"] + field_dict = new_field_dict + gh_history[itime], field_dict = compute_gas_holdup( + case_path, time_str_sorted[itime], nCells, field_dict + ) + co2_history[itime], field_dict = co2liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + h2_history[itime], field_dict = h2liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + liqvol_history[itime], field_dict = vol_liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + c_co2_history[itime], c_h2_history[itime], field_dict = cliq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + + +dataFolder = args.data_folder +os.makedirs(dataFolder, exist_ok=True) +os.makedirs(os.path.join(dataFolder, case_name), exist_ok=True) +np.savez( + os.path.join(dataFolder, case_name, "conv.npz"), + time=np.array(time_float_sorted), + gh=gh_history, + co2=co2_history, + h2=h2_history, + vol_liq=liqvol_history, + c_h2=c_h2_history, + c_co2=c_co2_history, +) diff --git a/applications/write_dynMix_fvModels.py b/applications/write_dynMix_fvModels.py index e2a5278b..bf1665ca 100644 --- a/applications/write_dynMix_fvModels.py +++ b/applications/write_dynMix_fvModels.py @@ -35,4 +35,6 @@ ) args = parser.parse_args() dynMix_dict = parseJsonFile(args.input) - write_fvModel(dynMix_dict, output_folder=args.output_folder) + write_fvModel( + dynMix_dict, output_folder=args.output_folder, force_sign=True + ) diff --git a/applications/write_dynMix_fvModels_force_sign.py b/applications/write_dynMix_fvModels_force_sign.py new file mode 100644 index 00000000..bf1665ca --- /dev/null +++ b/applications/write_dynMix_fvModels_force_sign.py @@ -0,0 +1,40 @@ +import os + +import numpy as np +import stl + +from bird import BIRD_PRE_DYNMIX_TEMP_DIR +from bird.meshing._mesh_tools import parseJsonFile +from bird.preprocess.dynamic_mixer.mixing_fvModels import * + +if __name__ == "__main__": + import argparse + + parser = argparse.ArgumentParser( + description="Generate dynamic mixer fvModels" + ) + parser.add_argument( + "-i", + "--input", + type=str, + metavar="", + required=False, + help="Mixers Json input", + default=os.path.join( + BIRD_PRE_DYNMIX_TEMP_DIR, "expl_list", "mixers.json" + ), + ) + parser.add_argument( + "-o", + "--output_folder", + type=str, + metavar="", + required=False, + help="fvModels folder output", + default=".", + ) + args = parser.parse_args() + dynMix_dict = parseJsonFile(args.input) + write_fvModel( + dynMix_dict, output_folder=args.output_folder, force_sign=True + ) diff --git a/bird/__init__.py b/bird/__init__.py index 3365eb11..b8aa816c 100644 --- a/bird/__init__.py +++ b/bird/__init__.py @@ -5,6 +5,7 @@ from bird.version import __version__ BIRD_DIR = os.path.dirname(os.path.realpath(__file__)) +BIRD_CASE_DIR = os.path.join(BIRD_DIR, "../OFsolvers/tutorial_cases") BIRD_MESH_DIR = os.path.join(BIRD_DIR, "meshing") BIRD_POST_DIR = os.path.join(BIRD_DIR, "postprocess") BIRD_PRE_DIR = os.path.join(BIRD_DIR, "preprocess") @@ -32,5 +33,6 @@ BIRD_PRE_DYNMIX_TEMP_DIR = os.path.join( BIRD_PRE_DIR, "dynamic_mixer", "mixing_template" ) +BIRD_PRE_DATA_DIR = os.path.join(BIRD_PRE_DIR, "data_preprocess") BIRD_EARLY_PRED_DATA_DIR = os.path.join(BIRD_POST_DIR, "data_early") BIRD_INV_DIR = os.path.join(BIRD_DIR, "inverse_modeling") diff --git a/bird/calibration/param_nn.py b/bird/calibration/param_nn.py deleted file mode 100644 index 11436ab8..00000000 --- a/bird/calibration/param_nn.py +++ /dev/null @@ -1,409 +0,0 @@ -import argparse -import os -import sys -import time - -import joblib -import numpy as np -import tensorflow as tf -import tensorflow.keras as keras -from prettyPlot.progressBar import print_progress_bar -from sklearn.model_selection import train_test_split -from sklearn.pipeline import make_pipeline -from sklearn.preprocessing import MinMaxScaler, StandardScaler -from tensorflow.keras import initializers, layers, optimizers, regularizers - - -def flexible_activation(x, activation): - if activation is None: - out = x - elif activation.lower() == "swish": - out = layers.Activation(swish_activation)(x) - elif activation.lower() == "sigmoid": - out = layers.Activation(activation="sigmoid")(x) - elif activation.lower() == "softplus": - out = layers.Activation(activation="softplus")(x) - elif activation.lower() == "tanh": - out = layers.Activation(activation="tanh")(x) - elif activation.lower() == "elu": - out = layers.Activation(activation="elu")(x) - elif activation.lower() == "selu": - out = layers.Activation(activation="selu")(x) - elif activation.lower() == "gelu": - out = layers.Activation(activation="gelu")(x) - elif activation.lower() == "relu": - out = layers.Activation(activation="relu")(x) - elif activation.lower() == "leakyrelu": - out = layers.LeakyReLU()(x) - else: - sys.exit(f"ERROR: unknown activation {activation}") - return out - - -def singleLayer(x, n_units, activation): - out = layers.Dense(n_units)(x) - out = flexible_activation(out, activation) - return out - - -def makeModel(input_dim_par, output_dim, units, activation, final_activation): - # inputs - input_z = layers.Input(shape=(1,), name="input_z") - input_par = layers.Input(shape=(input_dim_par,), name="input_par") - input_z_par = layers.concatenate([input_z, input_par], name="input_z_par") - x = input_z_par - for unit in units: - x = singleLayer(x, unit, activation) - output = layers.Dense(output_dim)(x) - output = flexible_activation(output, final_activation) - model = keras.Model([input_z, input_par], output) - return model - - -class Param_NN(keras.Model): - def __init__( - self, - input_dim=None, - output_dim=None, - units=None, - activation=None, - final_activation=None, - batch_size=None, - nEpochs=None, - weight_file=None, - model_folder="Model", - log_loss_folder="Log", - np_data_file=None, - **kwargs, - ): - super().__init__(**kwargs) - - self.np_data_file = np_data_file - if input_dim is None or output_dim is None: - input_dim, output_dim = self.get_dim_from_data(np_data_file) - self.input_dim = input_dim - self.output_dim = output_dim - self.input_dim_par = self.input_dim - 1 - - self.model = makeModel( - self.input_dim_par, - self.output_dim, - units, - activation, - final_activation, - ) - if weight_file is not None: - self.load(weight_file) - - self.batch_size = batch_size - self.nEpochs = nEpochs - - self.model_folder = model_folder - self.log_loss_folder = log_loss_folder - - def get_dim_from_data(self, data_file): - tmp_dat = np.load(data_file) - if len(tmp_dat["x"].shape) == 1: - input_dim = 1 - else: - input_dim = tmp_dat["x"].shape[1] - if len(tmp_dat["y"].shape) == 1: - output_dim = 1 - else: - output_dim = tmp_dat["y"].shape[1] - return input_dim, output_dim - - def make_data(self, np_file=None, scaler_folder="."): - # Raw data - if np_file is None: - np_file = self.np_data_file - - tmp = np.load(np_file) - z_dat = np.float32(np.reshape(tmp["x"][:, 0], (-1, 1))) - par_dat = np.float32(tmp["x"][:, 1:]) - y_dat = np.float32(np.reshape(tmp["y"], (-1, 1))) - - # Scaler - scaler_z = MinMaxScaler() - scaler_par = MinMaxScaler() - scaler_y = StandardScaler() - scaler_z.fit(z_dat) - scaler_par.fit(par_dat) - scaler_y.fit(y_dat) - joblib.dump(scaler_z, os.path.join(scaler_folder, "scaler_z.mod")) - joblib.dump(scaler_par, os.path.join(scaler_folder, "scaler_par.mod")) - joblib.dump(scaler_y, os.path.join(scaler_folder, "scaler_y.mod")) - - # Split and shuffle - ( - z_train, - z_test, - par_train, - par_test, - y_train, - y_test, - ) = train_test_split( - scaler_z.transform(z_dat), - scaler_par.transform(par_dat), - scaler_y.transform(y_dat), - test_size=0.1, - random_state=42, - ) - - return { - "z_train": z_train, - "par_train": par_train, - "y_train": y_train, - "z_test": z_test, - "par_test": par_test, - "y_test": y_test, - } - - @tf.function - def train_step(self, input_z=None, input_par=None, output_true=None): - with tf.GradientTape() as tape: - loss = self.calc_loss(input_z, input_par, output_true) - grads = tape.gradient(loss, self.trainable_weights) - self.optimizer.apply_gradients(zip(grads, self.trainable_weights)) - return { - "loss": loss, - } - - def calc_loss(self, input_z=None, input_par=None, output_true=None): - output_predicted = self.model([input_z, input_par]) - loss = tf.math.reduce_sum( - tf.math.square(output_predicted - output_true) - ) - return loss - - def train( - self, - learningRateModel, - batch_size=None, - nEpochs=None, - data_file=None, - gradient_threshold=None, - ): - if gradient_threshold is not None: - print(f"INFO: clipping gradients at {gradient_threshold:.2g}") - # Make sure the control file for learning rate is consistent with main.py, at least at first - self.prepareLog() - bestLoss = None - - if batch_size is None: - batch_size = self.batch_size - if nEpochs is None: - nEpochs = self.nEpochs - - # Make dataset - if data_file is None: - data_file = self.np_data_file - - input_dim_data, output_dim_data = self.get_dim_from_data(data_file) - assert input_dim_data == self.input_dim - assert output_dim_data == self.output_dim - - dataset = self.make_data( - scaler_folder=self.model_folder, np_file=data_file - ) - self.n_batch = dataset["z_train"].shape[0] // batch_size - self.freq = self.n_batch * 10 - # self.freq = 1 - - train_dataset = tf.data.Dataset.from_tensor_slices( - ( - dataset["z_train"], - dataset["par_train"], - dataset["y_train"], - ) - ).batch(batch_size) - test_dataset = tf.data.Dataset.from_tensor_slices( - ( - dataset["z_test"], - dataset["par_test"], - dataset["y_test"], - ) - ).batch(100000) - - # Prepare LR - lr_m = learningRateModel - self.optimizer = optimizers.Adam(learning_rate=lr_m) - - # Train - print_progress_bar( - 0, - nEpochs, - prefix="Loss=%s Epoch= %d / %d " % ("?", 0, nEpochs), - suffix="Complete", - length=20, - ) - - for epoch in range(nEpochs): - train_loss = 0 - time_per_step = 0 - for step, batch in enumerate(train_dataset): - self.total_step = step + epoch * self.n_batch - time_s = time.time() - loss_info = self.train_step( - input_z=batch[0], input_par=batch[1], output_true=batch[2] - ) - loss_val = loss_info["loss"] - time_e = time.time() - train_loss = ( - (step) * train_loss + tf.reduce_sum(loss_val) - ) / (step + 1) - time_per_step = ( - (step) * (time_per_step) + (time_e - time_s) - ) / (step + 1) - test_loss = 0 - for val_step, val_batch in enumerate(test_dataset): - val_loss = self.calc_loss( - val_batch[0], val_batch[1], val_batch[2] - ) - test_loss = ( - (val_step) * test_loss + tf.reduce_sum(val_loss) - ) / (val_step + 1) - - print_progress_bar( - epoch + 1, - nEpochs, - prefix=f"train_l={train_loss:.2f}, test_l={test_loss:.2f}, t/step={1e3*time_per_step:.2f} ms, Epoch= {epoch + 1} / {nEpochs} ", - suffix="Complete", - length=20, - ) - bestLoss = self.logTraining( - epoch, - loss=train_loss, - val_loss=test_loss, - bestLoss=bestLoss, - ) - self.model.save_weights( - os.path.join(self.model_folder, "last.weights.h5"), - overwrite=True, - ) - - def pred(self, z, par, rescaled=False): - if len(z.shape) == 1: - z = np.reshape(z, (-1, 1)) - if len(par.shape) == 1: - par = np.reshape(par, (-1, 1)) - scaler_z = joblib.load(os.path.join(self.model_folder, "scaler_z.mod")) - scaler_par = joblib.load( - os.path.join(self.model_folder, "scaler_par.mod") - ) - scaler_y = joblib.load(os.path.join(self.model_folder, "scaler_y.mod")) - z = np.float32(z) - par = np.float32(par) - if not rescaled: - z_in = scaler_z.transform(z) - par_in = scaler_par.transform(par) - y_out = self.model([z_in, par_in]) - y = scaler_y.inverse_transform(y_out) - return y - - def load(self, weight_file): - self.model.load_weights(weight_file) - - def prepareLog(self): - os.makedirs(self.model_folder, exist_ok=True) - os.makedirs(self.log_loss_folder, exist_ok=True) - try: - os.remove(os.path.join(self.log_loss_folder, "log.csv")) - except: - pass - # Make log headers - f = open(os.path.join(self.log_loss_folder, "log.csv"), "a+") - f.write("epoch;step;loss;recons_w_loss;recons_chi_loss\n") - f.close() - - def logTraining(self, epoch, loss, val_loss, bestLoss): - f = open(os.path.join(self.log_loss_folder, "log.csv"), "a+") - f.write( - str(int(epoch)) - + ";" - + str(int(epoch * self.n_batch)) - + ";" - + str(loss.numpy()) - + ";" - + str(val_loss.numpy()) - + ";" - + "\n" - ) - f.close() - if bestLoss is None or loss < bestLoss: - bestLoss = loss - self.model.save_weights( - os.path.join(self.model_folder, "best.weights.h5"), - overwrite=True, - ) - return bestLoss - - def get_loss_dat(self): - lossData = np.genfromtxt( - os.path.join(self.log_loss_folder, "log.csv"), - delimiter=";", - skip_header=1, - ) - return { - "epoch": lossData[:, 0], - "step": lossData[:, 1], - "train_loss": lossData[:, 2], - "val_loss": lossData[:, 3], - } - - -if __name__ == "__main__": - myNN = BCR_NN( - input_dim=4, - output_dim=1, - units=[10, 20, 10, 5], - activation="tanh", - model_folder="Modeltmp", - # weight_file='Modeltmp.save/last.weights.h5', - log_loss_folder="Logtmp", - ) - - myNN.train( - learningRateModel=1e-3, - batch_size=32, - nEpochs=1000, - data_file="train_data_gh_17_raw.npz", - ) - - from plotsUtil import * - - nz = 32 - nz_true = 32 - A = np.load("train_data_gh_17_raw.npz") - dat_par = np.repeat(np.reshape(A["x"][0, 1:], (1, -1)), nz, axis=0) - dat_z = np.reshape(np.linspace(0, 4, nz), (-1, 1)) - pred = myNN.pred(dat_z, dat_par) - - fig = plt.figure() - plt.plot(pred[:, 0], dat_z[:, 0], "o", label="pred") - plt.plot(A["y"][:nz_true], A["x"][:nz_true, 0], "x", label="true") - prettyLabels("gh", "z", 14) - plotLegend() - - loss_dat = myNN.get_loss_dat() - fig = plt.figure() - plt.plot( - loss_dat["epoch"], - loss_dat["train_loss"], - color="k", - linewidth=3, - label="train", - ) - plt.plot( - loss_dat["epoch"], - loss_dat["val_loss"], - color="b", - linewidth=3, - label="test", - ) - prettyLabels("epoch", "loss", 14) - ax = plt.gca() - ax.set_yscale("log") - plotLegend() - - plt.show() diff --git a/bird/calibration/scaling.py b/bird/calibration/scaling.py deleted file mode 100644 index 0d04060c..00000000 --- a/bird/calibration/scaling.py +++ /dev/null @@ -1,22 +0,0 @@ -def scale_x(inp, min_, max_): - return (inp - min_) / (max_ - min_) - - -def scale_par(inp, min_, max_): - return scale_x(inp, min_, max_) - - -def scale_y(inp, mean_, scale_): - return (inp - mean_) / (max_ - min_) - - -def unscale_x(inp, min_, max_): - return inp * (max_ - min_) + min_ - - -def unscale_par(inp, min_, max_): - return unscale_x(inp, min_, max_) - - -def unscale_y(inp, mean_, scale_): - return inp * scale_ + mean_ diff --git a/bird/meshing/block_rect_mesh.py b/bird/meshing/block_rect_mesh.py index 22a31f16..2b9d335e 100644 --- a/bird/meshing/block_rect_mesh.py +++ b/bird/meshing/block_rect_mesh.py @@ -240,9 +240,9 @@ def from_block_rect_to_seg(input_geom_dict, rescale=True): segments[iseg]["normal_dir"] = int(np.nonzero(vec_conn)[0][0]) if segments[iseg]["normal_dir"] == 0: segments[iseg]["max_rad"] = (blocksize_y + blocksize_z) / 4 - if segments[iseg]["normal_dir"] == 1: + elif segments[iseg]["normal_dir"] == 1: segments[iseg]["max_rad"] = (blocksize_x + blocksize_z) / 4 - if segments[iseg]["normal_dir"] == 2: + elif segments[iseg]["normal_dir"] == 2: segments[iseg]["max_rad"] = (blocksize_x + blocksize_y) / 4 return { diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/.vim/.netrwhist b/bird/preprocess/data_preprocess/loop_reactor_3_6L/.vim/.netrwhist new file mode 100644 index 00000000..b9691c3b --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/.vim/.netrwhist @@ -0,0 +1,3 @@ +let g:netrw_dirhistmax =10 +let g:netrw_dirhistcnt =1 +let g:netrw_dirhist_1='/home/openfoam/postProcessing/patchIntegrate(patch=inlet,field=alpha.gas)/0' diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/water.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/CO2.gas similarity index 94% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/water.gas rename to bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/CO2.gas index 9193636d..e4165b1a 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/0.orig/water.gas +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/CO2.gas @@ -9,7 +9,7 @@ FoamFile { format ascii; class volScalarField; - object water.gas; + object CO2.gas; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // dimensions [0 0 0 0 0 0 0]; @@ -26,7 +26,7 @@ boundaryField inlet { type fixedValue; - value uniform 0; + value uniform $f_CO2; } outlet diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/CO2.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/CO2.liquid new file mode 100644 index 00000000..4b8ea6a0 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/CO2.liquid @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object CO2.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type zeroGradient; + //type fixedValue; + //value uniform 0.0; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/H2.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/H2.gas new file mode 100644 index 00000000..9f66b2d2 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/H2.gas @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object H2.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +dimensions [0 0 0 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform 0; + + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform $f_H2; + } + + outlet + { + //type inletOutlet; + //phi phi.gas; + //inletValue $f_H2; + //value $f_H2; + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/H2.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/H2.liquid new file mode 100644 index 00000000..65ae8d34 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/H2.liquid @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object H2.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type zeroGradient; + //type fixedValue; + //value uniform 0.0; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/N2.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/N2.gas new file mode 100644 index 00000000..c1d7225f --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/N2.gas @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object N2.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +dimensions [0 0 0 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform 1; + + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform $f_N2; + } + + outlet + { + //type inletOutlet; + //phi phi.gas; + //inletValue $f_N2; + //value $f_N2; + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/T.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/T.gas new file mode 100644 index 00000000..bf0199a0 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/T.gas @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object T.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 300; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value $internalField; + } + + outlet + { + type inletOutlet; + phi phi.gas; + inletValue $internalField; + value $internalField; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/T.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/T.liquid new file mode 100644 index 00000000..7101ea31 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/T.liquid @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object T.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 300; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + outlet + { + type inletOutlet; + phi phi.liquid; + inletValue $internalField; + value $internalField; + } + inlet + { + type fixedValue; + value $internalField; + } + defaultFaces + { + type zeroGradient; + } + +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/U.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/U.gas new file mode 100644 index 00000000..e696566f --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/U.gas @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volVectorField; + object U.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0.0 0); + +#include "${FOAM_CASE}/constant/globalVars" + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + //type flowRateInletVelocity; + //massFlowRate $mflowRateGas; + //rho thermo:rho.gas; + //value $internalField; + type fixedValue; + value uniform (0 $uGasPhase 0); + } + outlet + { + type pressureInletOutletVelocity; + phi phi.gas; + value $internalField; + } + defaultFaces + { + type slip; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/U.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/U.liquid new file mode 100644 index 00000000..1879e020 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/U.liquid @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volVectorField; + object U.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform (0 0 0); + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + //type flowRateInletVelocity; + //massFlowRate $mflowRateLiq; + //rho thermo:rho.liquid; + //value $internalField; + type fixedValue; + value uniform (0 0 0); + } + outlet + { + type noSlip; + } + defaultFaces + { + type noSlip; + } + +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/Ydefault.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/Ydefault.gas new file mode 100644 index 00000000..fba2945d --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/Ydefault.gas @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object Ydefault.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform 0.0; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/Ydefault.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/Ydefault.liquid new file mode 100644 index 00000000..a5108564 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/Ydefault.liquid @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object Ydefault.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 1.0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform 1.0; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alpha.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alpha.gas new file mode 100644 index 00000000..1e303fbe --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alpha.gas @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + location "0"; + object alpha.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $alphaGas; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $alphaGas; + } + outlet + { + type inletOutlet; + phi phi.gas; + inletValue uniform 1; + value uniform 1; + } + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alpha.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alpha.liquid new file mode 100644 index 00000000..5c92070b --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alpha.liquid @@ -0,0 +1,40 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object alpha.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform 1; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $alphaLiq; + } + outlet + { + type fixedValue; + value uniform 0; + } + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alphat.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alphat.gas new file mode 100644 index 00000000..b867958f --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alphat.gas @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object alphat.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + defaultFaces + { + type calculated; + value $internalField; + //type compressible::alphatWallFunction; + //Prt 0.85; + //value $internalField; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alphat.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alphat.liquid new file mode 100644 index 00000000..2569c3ee --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/alphat.liquid @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object alphat.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + defaultFaces + { + type compressible::alphatWallFunction; + Prt 0.85; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/epsilon.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/epsilon.gas new file mode 100644 index 00000000..707a1cda --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/epsilon.gas @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object epsilon.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $eps_inlet_gas; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $eps_inlet_gas; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + //type epsilonWallFunction; + //value $internalField; + } + + // defaultFaces + // { + // type empty; + // } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/epsilon.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/epsilon.liquid new file mode 100644 index 00000000..0a4236fd --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/epsilon.liquid @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object epsilon.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $eps_inlet_liq; + +boundaryField +{ + inlet + { + type fixedValue; + value uniform $eps_inlet_liq; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type epsilonWallFunction; + value $internalField; + } + +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/f.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/f.gas new file mode 100644 index 00000000..76ee77a9 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/f.gas @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object f.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 1.0; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform 1.0; //$internalField; // + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/k.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/k.gas new file mode 100644 index 00000000..4a3d44ca --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/k.gas @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object k.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $k_inlet_gas; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform $k_inlet_gas; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/k.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/k.liquid new file mode 100644 index 00000000..cde8f6c1 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/k.liquid @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object k.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +#include "${FOAM_CASE}/constant/globalVars" + +internalField uniform $k_inlet_liq; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type fixedValue; + value uniform $k_inlet_liq; + } + + outlet + { + type zeroGradient; + } + + defaultFaces + { + type kqRWallFunction; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/nut.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/nut.gas new file mode 100644 index 00000000..ba16dd4c --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/nut.gas @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object nut.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 1e-8; + +boundaryField +{ + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + defaultFaces + { + //type nutkWallFunction; + //value $internalField; + type calculated; + value $internalField; + } + + // defaultFaces + // { + // type empty; + // } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/nut.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/nut.liquid new file mode 100644 index 00000000..1442e07f --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/nut.liquid @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object nut.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 1e-4; + +boundaryField +{ + #includeEtc "caseDicts/setConstraintTypes" + + inlet + { + type calculated; + value $internalField; + } + + outlet + { + type calculated; + value $internalField; + } + + defaultFaces + { + type nutkWallFunction; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/p b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/p new file mode 100644 index 00000000..b3a295fb --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/p @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 101325; + +boundaryField +{ + inlet + { + type calculated; + value $internalField; + } + outlet + { + type calculated; + value $internalField; + } + defaultFaces + { + type calculated; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/p_rgh b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/p_rgh new file mode 100644 index 00000000..88ee7d80 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/0.orig/p_rgh @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 101325; + +boundaryField +{ + inlet + { + type fixedFluxPressure; + value $internalField; + } + outlet + { + type prghTotalPressure; + p0 $internalField; + U U.gas; + phi phi.gas; + rho thermo:rho.gas; + value $internalField; + } + defaultFaces + { + type fixedFluxPressure; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/Allclean b/bird/preprocess/data_preprocess/loop_reactor_3_6L/Allclean new file mode 100755 index 00000000..f55e0ec9 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/Allclean @@ -0,0 +1,18 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +# Remove surface, features and solution +#rm -rf constant/extendedFeatureEdgeMesh > /dev/null 2>&1 +#rm -f constant/triSurface/*.eMesh > /dev/null 2>&1 +#rm -rf constant/polyMesh > /dev/null 2>&1 +#rm -rf processor* > /dev/null 2>&1 +rm -rf 0 +cleanCase + +#rm *.obj +#rm *.stl + +#------------------------------------------------------------------------------ diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/computeQOI.sh b/bird/preprocess/data_preprocess/loop_reactor_3_6L/computeQOI.sh new file mode 100644 index 00000000..3756ed7f --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/computeQOI.sh @@ -0,0 +1,13 @@ +if [ ! -f qoi.txt ]; then + # Reconstruct if needed + source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc + reconstructPar -newTimes + module load anaconda3/2023 + conda activate /projects/gas2fuels/conda_env/bird + python read_history.py -cr .. -cn local -df data + python get_qoi.py + conda deactivate +else + echo "WARNING: QOI already computed" +fi + diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/dynamicMix_util.H b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/dynamicMix_util.H new file mode 100644 index 00000000..8fa7daf7 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/dynamicMix_util.H @@ -0,0 +1,37 @@ +#include + +double gradfunMix(double V1, double V2){ + return 3.0*V2*V2 + 2.0*V1*V2 - V1*V1; +} + +double funMix(double V1, double V2, double P, double rhoL, double A){ + return V2*V2*V2 + V1*V2*V2 - V2*V1*V1 - V1*V1*V1 - 4.0*P/(rhoL * A); +} + +double findV2(double P, double rhoL, double A, double V1) { + int newton_iter = 100; + double V2 = 2*V1; + double V2_old; + double V2_new; + if (std::abs(V1) < 1e-12) { + V2=std::pow((4.0*P/rhoL/A),0.333333); + V2_new = V2; + V2_old = V2; + } else { + for (int i=0; i("thermo:rho.liquid"); + const volScalarField& alphaL = + mesh().lookupObject("alpha.liquid"); + const volVectorField& UL = + mesh().lookupObject("U.liquid"); + double pi=3.141592654; + double source_pt_x=0.25; + double source_pt_y=0.025; + double source_pt_z=0.225; + double disk_rad=0.017499999999999998; + double disk_area=pi*disk_rad*disk_rad; + double power=2.5; + double smear_factor=3.0; + const scalar startTime = 1; + if (time.value() > startTime) + { + // Get V1 + double source_sign_factor = 1.0; + double V1 = 0; + double V2 = 0; + double rhoV; + double dist_tol = disk_rad*5; + + double dist_n; + double upV = 0; + double uprhoV = 0; + double upVvol = 0; + double downV = 0; + double downrhoV = 0; + double downVvol = 0; + double dist2; + forAll(C,i) + { + dist2 = (C[i].x()-source_pt_x)*(C[i].x()-source_pt_x); + dist2 += (C[i].y()-source_pt_y)*(C[i].y()-source_pt_y); + dist2 += (C[i].z()-source_pt_z)*(C[i].z()-source_pt_z); + + dist_n = (C[i].x()-source_pt_x); + + if (dist2 < dist_tol*dist_tol && dist_n < -dist_tol/2) { + upVvol += V[i] * alphaL[i]; + upV += V[i] * alphaL[i] * UL[i][0]; + uprhoV += V[i] * alphaL[i] * rhoL[i]; + } + if (dist2 < dist_tol*dist_tol && dist_n > dist_tol/2) { + downVvol += V[i] * alphaL[i]; + downV += V[i] * alphaL[i] * UL[i][0]; + downrhoV += V[i] * alphaL[i] * rhoL[i]; + } + } + + reduce(uprhoV, sumOp()); + reduce(downrhoV, sumOp()); + reduce(upV, sumOp()); + reduce(downV, sumOp()); + reduce(downVvol, sumOp()); + reduce(upVvol, sumOp()); + + downV /= downVvol; + upV /= upVvol; + downrhoV /= downVvol; + uprhoV /= upVvol; + + if (upV <= 0 && downV <= 0) { + source_sign_factor = -1.0; + V1 = std::abs(upV); + rhoV = uprhoV; + } else if (upV >= 0 && downV >= 0) { + source_sign_factor = 1.0; + V1 = std::abs(downV); + rhoV = downrhoV; + } else { + V1 = 0.0; + source_sign_factor = -1.0; + rhoV = uprhoV; + Foam::Info << "[BIRD:DYNMIX WARN] " << "upV = " << upV << " downV = " << downV << " for source at " << source_pt_x << ", " << source_pt_y << ", " << source_pt_z << endl; + } + Foam::Info << "[BIRD:DYNMIX INFO] V1 = " << V1 << endl; + + // Get V2 + V2 = findV2(power, rhoV, disk_area, V1); + + forAll(C,i) + { + double Thrust=0.5*rhoL[i]*(V2*V2 - V1*V1)*disk_area; + double dist2=(C[i].x()-source_pt_x)*(C[i].x()-source_pt_x); + dist2 += (C[i].y()-source_pt_y)*(C[i].y()-source_pt_y); + dist2 += (C[i].z()-source_pt_z)*(C[i].z()-source_pt_z); + double epsilon=pow(V[i],0.33333)*smear_factor; + double sourceterm=alphaL[i]*(Thrust/pow(pi,1.5)/pow(epsilon,3.0))* + exp(-dist2/(epsilon*epsilon)); + Usource[i][0] -= source_sign_factor*sourceterm*V[i]; + } + } + #}; +}; diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/g b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/g new file mode 100644 index 00000000..770a5619 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/globalVars b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/globalVars new file mode 100644 index 00000000..21436f69 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/globalVars @@ -0,0 +1,83 @@ +T0 300; //initial T(K) which stays constant +VVM 1.6; +//****water Liquid properties************** +CpMixLiq 4181; +muMixLiq #calc "2.414e-5 * pow(10,247.8/($T0 - 140.0))"; //viscosity (Pa.s) of water as a function of T(K) +kThermLiq 0.62; // W/m-K +rho0MixLiq 1000; // kg/m^3 +sigmaLiq 0.07; //surface tension N/m +//Wilke-Chang params for diffusion coefficient of a given solute in water (solvent) +WC_psi 2.6; +WC_M 18; // kg/kmol +WC_V_O2 25.6e-3; // m3/kmol molar volume at normal boiling temperature (Treybal 1968) +WC_V_H2 14.3e-3; +WC_V_CO2 34e-3; +WC_V_CO 30.7e-3; +WC_V_N2 31.2e-3; +WC_V_CH4 35e-3; // V_b[cm3/mol]=0.285*V_critical^1.048 (Tyn and Calus; ESTIMATING LIQUID MOLAL VOLUME; Processing, Volume 21, Issue 4, Pages 16 - 17) +//****** diffusion coeff *********** +D_H2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_H2,0.6)"; +D_CO2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CO2,0.6)"; +D_CO #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CO,0.6)"; +D_CH4 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CH4,0.6)"; +D_N2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_N2,0.6)"; +//****** Henry coeff *************** +H_O2_298 0.032; +DH_O2 1700; +H_CO2_298 0.83; +DH_CO2 2400; +H_CO_298 0.023; +DH_CO 1300; +H_H2_298 0.019; +DH_H2 500; +H_CH4_298 0.032; +DH_CH4 1900; +H_N2_298 0.015; +DH_N2 1300; +He_H2 #calc "$H_H2_298 * exp($DH_H2 *(1. / $T0 - 1./298.15))"; +He_CO #calc "$H_CO_298 * exp($DH_CO *(1. / $T0 - 1./298.15))"; +He_CO2 #calc "$H_CO2_298 * exp($DH_CO2 *(1. / $T0 - 1./298.15))"; +He_CH4 #calc "$H_CH4_298 * exp($DH_CH4 *(1. / $T0 - 1./298.15))"; +He_N2 #calc "$H_N2_298 * exp($DH_N2 *(1. / $T0 - 1./298.15))"; +//*******inlet gas frac************* +f_H2 0.1; +f_CO2 0.9; +f_N2 0.0; +//*******inlet gas frac************* +inletA 0.0039; +liqVol 0.003625; +alphaGas 1; +alphaLiq 0; +uGasPhase #calc "$liqVol * $VVM / (60 * $inletA * $alphaGas)"; +//********************************* +LeLiqH2 #calc "$kThermLiq / $rho0MixLiq / $D_H2 / $CpMixLiq"; +LeLiqCO #calc "$kThermLiq / $rho0MixLiq / $D_CO / $CpMixLiq"; +LeLiqCO2 #calc "$kThermLiq / $rho0MixLiq / $D_CO2 / $CpMixLiq"; // = 74 +LeLiqCH4 #calc "$kThermLiq / $rho0MixLiq / $D_CH4 / $CpMixLiq"; +LeLiqN2 #calc "$kThermLiq / $rho0MixLiq / $D_N2 / $CpMixLiq"; +LeLiqMix #calc "$f_CO2*$LeLiqCO2+$f_H2*$LeLiqH2"; +PrMixLiq #calc "$CpMixLiq * $muMixLiq / $kThermLiq"; +//********************************* +kH2 #calc "$D_H2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrH2 #calc "$muMixLiq*$CpMixLiq / $kH2"; + +kCO #calc "$D_CO*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCO #calc "$muMixLiq*$CpMixLiq / $kCO"; + +kCO2 #calc "$D_CO2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCO2 #calc "$muMixLiq*$CpMixLiq / $kCO2"; + +kCH4 #calc "$D_CH4*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCH4 #calc "$muMixLiq*$CpMixLiq / $kCH4"; + +kN2 #calc "$D_N2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrN2 #calc "$muMixLiq*$CpMixLiq / $kN2"; +//********************************* +l_scale 0.5; +intensity 0.05; +k_inlet_gas #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)"; +k_inlet_liq #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)"; +eps_inlet_gas #calc "pow(0.09,0.75) * Foam::pow($k_inlet_gas, 1.5) / ($l_scale * 0.07)"; +eps_inlet_liq #calc "pow(0.09,0.75) * Foam::pow($k_inlet_liq, 1.5) / ($l_scale * 0.07)"; +omega_inlet_gas #calc "pow(0.09,-0.25) * pow($k_inlet_gas,0.5) / ($l_scale * 0.07)"; +omega_inlet_liq #calc "pow(0.09,-0.25) * pow($k_inlet_liq,0.5) / ($l_scale * 0.07)"; diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/globalVars_temp b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/globalVars_temp new file mode 100644 index 00000000..fcb076a7 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/globalVars_temp @@ -0,0 +1,83 @@ +T0 300; //initial T(K) which stays constant +VVM 0.2; +//****water Liquid properties************** +CpMixLiq 4181; +muMixLiq #calc "2.414e-5 * pow(10,247.8/($T0 - 140.0))"; //viscosity (Pa.s) of water as a function of T(K) +kThermLiq 0.62; // W/m-K +rho0MixLiq 1000; // kg/m^3 +sigmaLiq 0.07; //surface tension N/m +//Wilke-Chang params for diffusion coefficient of a given solute in water (solvent) +WC_psi 2.6; +WC_M 18; // kg/kmol +WC_V_O2 25.6e-3; // m3/kmol molar volume at normal boiling temperature (Treybal 1968) +WC_V_H2 14.3e-3; +WC_V_CO2 34e-3; +WC_V_CO 30.7e-3; +WC_V_N2 31.2e-3; +WC_V_CH4 35e-3; // V_b[cm3/mol]=0.285*V_critical^1.048 (Tyn and Calus; ESTIMATING LIQUID MOLAL VOLUME; Processing, Volume 21, Issue 4, Pages 16 - 17) +//****** diffusion coeff *********** +D_H2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_H2,0.6)"; +D_CO2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CO2,0.6)"; +D_CO #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CO,0.6)"; +D_CH4 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_CH4,0.6)"; +D_N2 #calc "1.173e-16 * pow($WC_psi * $WC_M,0.5) * $T0 / $muMixLiq / pow($WC_V_N2,0.6)"; +//****** Henry coeff *************** +H_O2_298 0.032; +DH_O2 1700; +H_CO2_298 0.83; +DH_CO2 2400; +H_CO_298 0.023; +DH_CO 1300; +H_H2_298 0.019; +DH_H2 500; +H_CH4_298 0.032; +DH_CH4 1900; +H_N2_298 0.015; +DH_N2 1300; +He_H2 #calc "$H_H2_298 * exp($DH_H2 *(1. / $T0 - 1./298.15))"; +He_CO #calc "$H_CO_298 * exp($DH_CO *(1. / $T0 - 1./298.15))"; +He_CO2 #calc "$H_CO2_298 * exp($DH_CO2 *(1. / $T0 - 1./298.15))"; +He_CH4 #calc "$H_CH4_298 * exp($DH_CH4 *(1. / $T0 - 1./298.15))"; +He_N2 #calc "$H_N2_298 * exp($DH_N2 *(1. / $T0 - 1./298.15))"; +//*******inlet gas frac************* +f_H2 0.1; +f_CO2 0.9; +f_N2 0.0; +//*******inlet gas frac************* +inletA ; +liqVol ; +alphaGas 1; +alphaLiq 0; +uGasPhase #calc "$liqVol * $VVM / (60 * $inletA * $alphaGas)"; +//********************************* +LeLiqH2 #calc "$kThermLiq / $rho0MixLiq / $D_H2 / $CpMixLiq"; +LeLiqCO #calc "$kThermLiq / $rho0MixLiq / $D_CO / $CpMixLiq"; +LeLiqCO2 #calc "$kThermLiq / $rho0MixLiq / $D_CO2 / $CpMixLiq"; // = 74 +LeLiqCH4 #calc "$kThermLiq / $rho0MixLiq / $D_CH4 / $CpMixLiq"; +LeLiqN2 #calc "$kThermLiq / $rho0MixLiq / $D_N2 / $CpMixLiq"; +LeLiqMix #calc "$f_CO2*$LeLiqCO2+$f_H2*$LeLiqH2"; +PrMixLiq #calc "$CpMixLiq * $muMixLiq / $kThermLiq"; +//********************************* +kH2 #calc "$D_H2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrH2 #calc "$muMixLiq*$CpMixLiq / $kH2"; + +kCO #calc "$D_CO*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCO #calc "$muMixLiq*$CpMixLiq / $kCO"; + +kCO2 #calc "$D_CO2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCO2 #calc "$muMixLiq*$CpMixLiq / $kCO2"; + +kCH4 #calc "$D_CH4*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrCH4 #calc "$muMixLiq*$CpMixLiq / $kCH4"; + +kN2 #calc "$D_N2*$rho0MixLiq*$CpMixLiq*$LeLiqMix"; +PrN2 #calc "$muMixLiq*$CpMixLiq / $kN2"; +//********************************* +l_scale 0.5; +intensity 0.05; +k_inlet_gas #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)"; +k_inlet_liq #calc "1.5 * Foam::pow(($uGasPhase), 2) * Foam::pow($intensity, 2)"; +eps_inlet_gas #calc "pow(0.09,0.75) * Foam::pow($k_inlet_gas, 1.5) / ($l_scale * 0.07)"; +eps_inlet_liq #calc "pow(0.09,0.75) * Foam::pow($k_inlet_liq, 1.5) / ($l_scale * 0.07)"; +omega_inlet_gas #calc "pow(0.09,-0.25) * pow($k_inlet_gas,0.5) / ($l_scale * 0.07)"; +omega_inlet_liq #calc "pow(0.09,-0.25) * pow($k_inlet_liq,0.5) / ($l_scale * 0.07)"; diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/momentumTransport.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/momentumTransport.gas new file mode 100644 index 00000000..ca916714 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/momentumTransport.gas @@ -0,0 +1,26 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object momentumTransport.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +//simulationType laminar; +simulationType RAS; +RAS +{ + model mixtureKEpsilon; + turbulence on; + printCoeff on; +} + +// ************************************************************************* // diff --git a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/chemistryProperties.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/momentumTransport.liquid similarity index 64% rename from OFsolvers/tutorial_cases/loop_reactor_reacting/constant/chemistryProperties.liquid rename to bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/momentumTransport.liquid index 3f5a0e1d..2063de0d 100644 --- a/OFsolvers/tutorial_cases/loop_reactor_reacting/constant/chemistryProperties.liquid +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/momentumTransport.liquid @@ -7,36 +7,21 @@ \*---------------------------------------------------------------------------*/ FoamFile { - version 2.0; format ascii; class dictionary; location "constant"; - object chemistryProperties.liquid; + object momentumTransport.liquid; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -chemistryType -{ - solver EulerImplicit; -} - -chemistry on; - -initialChemicalTimeStep 1e-07; +//simulationType laminar; +simulationType RAS; -EulerImplicitCoeffs +RAS { - cTauChem 1; - equilibriumRateLimiter off; + model mixtureKEpsilon; + turbulence on; + printCoeffs on; } -odeCoeffs -{ - solver Rosenbrock43; - absTol 1e-8; - relTol 0.01; -} - -#include "reactions.liquid" - // ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties new file mode 100644 index 00000000..a3c90f5a --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties @@ -0,0 +1,295 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object phaseProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "$FOAM_CASE/constant/globalVars" + +type interfaceCompositionPhaseChangePopulationBalanceMultiphaseSystem; + +phases (gas liquid); + +populationBalances (bubbles); + +gas +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel velocityGroup; + + velocityGroupCoeffs + { + populationBalance bubbles; + + shapeModel spherical; + + sizeGroups + ( + f1 {dSph 1.4e-3; value 0.0;} + f2 {dSph 1.8e-3; value 0.0;} + f3 {dSph 2.2e-3; value 0.0;} + f4 {dSph 2.6e-3; value 0.0;} + f5 {dSph 3e-3; value 1.0;} + f6 {dSph 3.4e-3; value 0.0;} + f7 {dSph 3.8e-3; value 0.0;} + f8 {dSph 4.2e-3; value 0.0;} + f9 {dSph 4.6e-3; value 0.0;} + f10 {dSph 5.0e-3; value 0.0;} + ); + } + + residualAlpha 1e-6; + + Sc 0.7; +} + +liquid +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 1e-4; + } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + + residualAlpha 1e-6; +} + +populationBalanceCoeffs +{ + bubbles + { + continuousPhase liquid; + + coalescenceModels + ( + LehrMilliesMewes{ + efficiency 4.695; + uCrit 0.08; + alphaMax 0.6; + } + ); + + binaryBreakupModels + (); + + breakupModels + ( + Laakkonen { + efficiency 13.83; + daughterSizeDistributionModel Laakkonen; + } + + ); + + driftModels + ( + densityChange{} + ); + + nucleationModels + (); + } +} + +blending +{ + default + { + type linear; + minFullyContinuousAlpha.gas 0.7; + minPartlyContinuousAlpha.gas 0.3; + minFullyContinuousAlpha.liquid 0.7; + minPartlyContinuousAlpha.liquid 0.3; + } + heatTransfer + { + type linear; + minFullyContinuousAlpha.gas 1; + minPartlyContinuousAlpha.gas 0; + minFullyContinuousAlpha.liquid 1; + minPartlyContinuousAlpha.liquid 0; + } + massTransfer + { + $heatTransfer; + } +} + +surfaceTension +( + (gas and liquid) + { + type constant; + sigma $sigmaLiq; + } +); + +interfaceCompression +(); + +aspectRatio +( + (gas in liquid) + { + type Wellek; + } +); + + +drag +( + (gas in liquid) + { + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; + residualRe 1e-3; + swarmCorrection + { + type none; + } + } +); + +virtualMass +( + (gas in liquid) + { + type constantCoefficient; + Cvm 0.5; + } +); + +// heatTransfer +// (); + +heatTransfer.gas +( + (gas in liquid) + { + type spherical; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type RanzMarshall; + residualAlpha 1e-4; + } +); + +heatTransfer.liquid +( + (gas in liquid) + { + type RanzMarshall; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type spherical; + residualAlpha 1e-4; + } +); + +interfaceComposition.gas +(); + +interfaceComposition.liquid +( + (liquid and gas) + { + type Henry; + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); + Le $LeLiqMix; + } +); + +diffusiveMassTransfer.gas +(); + +diffusiveMassTransfer.liquid +( + (gas in liquid) + { + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; + Le $LeLiqMix; + } + + (liquid in gas) + { + type spherical; + Le 1.0; //not used for spherical + } +); + +phaseTransfer +(); + +lift +( + (gas in liquid) + { + type wallDamped; + + wallDamping + { + type cosine; + Cd 3.0; + } + + lift + { + type Tomiyama; + + swarmCorrection + { + type none; + } + } + } + +); + +wallLubrication +( + (gas in liquid) + { + type Antal; + Cw1 -0.01; + Cw2 0.05; + } +); + +turbulentDispersion +( + (gas in liquid) + { + type Burns; + sigma 0.9; + } +); + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties_constantd b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties_constantd new file mode 100644 index 00000000..e029df99 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties_constantd @@ -0,0 +1,261 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object phaseProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "$FOAM_CASE/constant/globalVars" + +type interfaceCompositionPhaseChangeMultiphaseSystem; + +phases (gas liquid); + +gas +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 3e-3; + } + residualAlpha 1e-6; + Sc 0.7; +} + +liquid +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 1e-4; + } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + + residualAlpha 1e-6; +} + +populationBalanceCoeffs +{ + bubbles + { + continuousPhase liquid; + + coalescenceModels + (); + + binaryBreakupModels + (); + + breakupModels + (); + + driftModels + (); + + nucleationModels + (); + } +} + +blending +{ + default + { + type linear; + minFullyContinuousAlpha.gas 0.7; + minPartlyContinuousAlpha.gas 0.3; + minFullyContinuousAlpha.liquid 0.7; + minPartlyContinuousAlpha.liquid 0.3; + } + heatTransfer + { + type linear; + minFullyContinuousAlpha.gas 1; + minPartlyContinuousAlpha.gas 0; + minFullyContinuousAlpha.liquid 1; + minPartlyContinuousAlpha.liquid 0; + } + massTransfer + { + $heatTransfer; + } +} + +surfaceTension +( + (gas and liquid) + { + type constant; + sigma $sigmaLiq; + } +); + +interfaceCompression +(); + +aspectRatio +( + (gas in liquid) + { + type Wellek; + } +); + + +drag +( + (gas in liquid) + { + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; + residualRe 1e-3; + swarmCorrection + { + type none; + } + } +); + +virtualMass +( + (gas in liquid) + { + type constantCoefficient; + Cvm 0.5; + } +); + +// heatTransfer +// (); + +heatTransfer.gas +( + (gas in liquid) + { + type spherical; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type RanzMarshall; + residualAlpha 1e-4; + } +); + +heatTransfer.liquid +( + (gas in liquid) + { + type RanzMarshall; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type spherical; + residualAlpha 1e-4; + } +); + +interfaceComposition.gas +(); + +interfaceComposition.liquid +( + (liquid and gas) + { + type Henry; + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); + Le $LeLiqMix; + } +); + +diffusiveMassTransfer.gas +(); + +diffusiveMassTransfer.liquid +( + (gas in liquid) + { + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; + Le $LeLiqMix; + } + + (liquid in gas) + { + type spherical; + Le 1.0; //not used for spherical + } +); + +phaseTransfer +(); + +lift +( + (gas in liquid) + { + type wallDamped; + + wallDamping + { + type cosine; + Cd 3.0; + } + + lift + { + type Tomiyama; + + swarmCorrection + { + type none; + } + } + } + +); + +wallLubrication +( + (gas in liquid) + { + type Antal; + Cw1 -0.01; + Cw2 0.05; + } +); + +turbulentDispersion +( + (gas in liquid) + { + type Burns; + sigma 0.9; + } +); + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties_pbe b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties_pbe new file mode 100644 index 00000000..a3c90f5a --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/phaseProperties_pbe @@ -0,0 +1,295 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: 9 + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object phaseProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "$FOAM_CASE/constant/globalVars" + +type interfaceCompositionPhaseChangePopulationBalanceMultiphaseSystem; + +phases (gas liquid); + +populationBalances (bubbles); + +gas +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel velocityGroup; + + velocityGroupCoeffs + { + populationBalance bubbles; + + shapeModel spherical; + + sizeGroups + ( + f1 {dSph 1.4e-3; value 0.0;} + f2 {dSph 1.8e-3; value 0.0;} + f3 {dSph 2.2e-3; value 0.0;} + f4 {dSph 2.6e-3; value 0.0;} + f5 {dSph 3e-3; value 1.0;} + f6 {dSph 3.4e-3; value 0.0;} + f7 {dSph 3.8e-3; value 0.0;} + f8 {dSph 4.2e-3; value 0.0;} + f9 {dSph 4.6e-3; value 0.0;} + f10 {dSph 5.0e-3; value 0.0;} + ); + } + + residualAlpha 1e-6; + + Sc 0.7; +} + +liquid +{ + type multiComponentPhaseModel;//pureIsothermalPhaseModel; + + diameterModel constant; + + constantCoeffs + { + d 1e-4; + } + Sc #codeStream + { + code + #{ + os << ($LeLiqMix * $CpMixLiq * $muMixLiq / $kThermLiq); + #}; + }; + + residualAlpha 1e-6; +} + +populationBalanceCoeffs +{ + bubbles + { + continuousPhase liquid; + + coalescenceModels + ( + LehrMilliesMewes{ + efficiency 4.695; + uCrit 0.08; + alphaMax 0.6; + } + ); + + binaryBreakupModels + (); + + breakupModels + ( + Laakkonen { + efficiency 13.83; + daughterSizeDistributionModel Laakkonen; + } + + ); + + driftModels + ( + densityChange{} + ); + + nucleationModels + (); + } +} + +blending +{ + default + { + type linear; + minFullyContinuousAlpha.gas 0.7; + minPartlyContinuousAlpha.gas 0.3; + minFullyContinuousAlpha.liquid 0.7; + minPartlyContinuousAlpha.liquid 0.3; + } + heatTransfer + { + type linear; + minFullyContinuousAlpha.gas 1; + minPartlyContinuousAlpha.gas 0; + minFullyContinuousAlpha.liquid 1; + minPartlyContinuousAlpha.liquid 0; + } + massTransfer + { + $heatTransfer; + } +} + +surfaceTension +( + (gas and liquid) + { + type constant; + sigma $sigmaLiq; + } +); + +interfaceCompression +(); + +aspectRatio +( + (gas in liquid) + { + type Wellek; + } +); + + +drag +( + (gas in liquid) + { + type Grace; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type IshiiZuber; + residualRe 1e-3; + swarmCorrection + { + type none; + } + } +); + +virtualMass +( + (gas in liquid) + { + type constantCoefficient; + Cvm 0.5; + } +); + +// heatTransfer +// (); + +heatTransfer.gas +( + (gas in liquid) + { + type spherical; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type RanzMarshall; + residualAlpha 1e-4; + } +); + +heatTransfer.liquid +( + (gas in liquid) + { + type RanzMarshall; + residualAlpha 1e-4; + } + + (liquid in gas) + { + type spherical; + residualAlpha 1e-4; + } +); + +interfaceComposition.gas +(); + +interfaceComposition.liquid +( + (liquid and gas) + { + type Henry; + species ( CO2 H2 ); + k ( $He_CO2 $He_H2 ); + Le $LeLiqMix; + } +); + +diffusiveMassTransfer.gas +(); + +diffusiveMassTransfer.liquid +( + (gas in liquid) + { + type Higbie; // Need to install the model available at https://github.com/NREL/BioReactorDesign + //type Frossling; + Le $LeLiqMix; + } + + (liquid in gas) + { + type spherical; + Le 1.0; //not used for spherical + } +); + +phaseTransfer +(); + +lift +( + (gas in liquid) + { + type wallDamped; + + wallDamping + { + type cosine; + Cd 3.0; + } + + lift + { + type Tomiyama; + + swarmCorrection + { + type none; + } + } + } + +); + +wallLubrication +( + (gas in liquid) + { + type Antal; + Cw1 -0.01; + Cw2 0.05; + } +); + +turbulentDispersion +( + (gas in liquid) + { + type Burns; + sigma 0.9; + } +); + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/thermophysicalProperties.gas b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/thermophysicalProperties.gas new file mode 100644 index 00000000..11b1c4b9 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/thermophysicalProperties.gas @@ -0,0 +1,142 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties.gas; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heRhoThermo; + mixture multiComponentMixture; + transport sutherland; + thermo janaf; + equationOfState perfectGas; + specie specie; + energy sensibleInternalEnergy; + //energy sensibleEnthalpy; +} + + +species +( + H2 + CO2 + N2 +); + +defaultSpecie N2; + +CO2 +{ + specie + { + molWeight 44.00995; + } + thermodynamics + { + Tlow 200; + Thigh 3500; + Tcommon 1000; + highCpCoeffs ( 3.85746029 0.00441437026 -2.21481404e-06 5.23490188e-10 -4.72084164e-14 -48759.166 2.27163806 ); + lowCpCoeffs ( 2.35677352 0.00898459677 -7.12356269e-06 2.45919022e-09 -1.43699548e-13 -48371.9697 9.90105222 ); + } + transport + { + As 1.572e-06; + Ts 240; + } + elements + { + C 1; + O 2; + } +} + +water +{ + specie + { + molWeight 18.01534; + } + thermodynamics + { + Tlow 200; + Thigh 3500; + Tcommon 1000; + highCpCoeffs ( 3.03399249 0.00217691804 -1.64072518e-07 -9.7041987e-11 1.68200992e-14 -30004.2971 4.9667701 ); + lowCpCoeffs ( 4.19864056 -0.0020364341 6.52040211e-06 -5.48797062e-09 1.77197817e-12 -30293.7267 -0.849032208 ); + } + transport + { + As 1.512e-06; + Ts 120; + } + elements + { + H 2; + O 1; + } +} + +N2 +{ + specie + { + molWeight 28.0134; + } + thermodynamics + { + Tlow 250; + Thigh 5000; + Tcommon 1000; + highCpCoeffs ( 2.92664 0.0014879768 -5.68476e-07 1.0097038e-10 -6.753351e-15 -922.7977 5.980528 ); + lowCpCoeffs ( 3.298677 0.0014082404 -3.963222e-06 5.641515e-09 -2.444854e-12 -1020.8999 3.950372 ); + } + transport + { + As 1.512e-06; + Ts 120; + } + elements + { + N 2; + } +} + +H2 +{ + specie + { + molWeight 2.01594; + } + thermodynamics + { + Tlow 200; + Thigh 3500; + Tcommon 1000; + highCpCoeffs ( 3.3372792 -4.94024731e-05 4.99456778e-07 -1.79566394e-10 2.00255376e-14 -950.158922 -3.20502331 ); + lowCpCoeffs ( 2.34433112 0.00798052075 -1.9478151e-05 2.01572094e-08 -7.37611761e-12 -917.935173 0.683010238 ); + } + transport + { + As 6.362e-07; + Ts 72; + } + elements + { + H 2; + } +} + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/thermophysicalProperties.liquid b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/thermophysicalProperties.liquid new file mode 100644 index 00000000..d324ec51 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/constant/thermophysicalProperties.liquid @@ -0,0 +1,108 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties.liquid; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "$FOAM_CASE/constant/globalVars" + +thermoType +{ + type heRhoThermo; + mixture multiComponentMixture; + transport const; + thermo hConst; + equationOfState rhoConst;//rPolynomial; + specie specie; + energy sensibleInternalEnergy; + //energy sensibleEnthalpy; +} + +species +( + CO2 + water + H2 +); + +inertSpecie water; + +water +{ + specie + { + molWeight 18.0153; + } + equationOfState + { + rho $rho0MixLiq; + } + thermodynamics + { + Cp $CpMixLiq; + Hf -1.5879e+07; + } + transport + { + mu $muMixLiq; + Pr $PrMixLiq; + } +} + +CO2 +{ + specie + { + molWeight 44.00995; + } + equationOfState + { + rho $rho0MixLiq; + } + thermodynamics + { + Cp $CpMixLiq; + Hf -1.5879e+07; + } + transport + { + mu $muMixLiq; + Pr $PrCO2; + } +} + +H2 +{ + specie + { + molWeight 2.01594; + } + equationOfState + { + rho $rho0MixLiq; + } + thermodynamics + { + Cp $CpMixLiq; + Hf -1.5879e+07;//-9402451; + } + transport + { + mu $muMixLiq; + Pr $PrH2; + } +} + + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/get_qoi.py b/bird/preprocess/data_preprocess/loop_reactor_3_6L/get_qoi.py new file mode 100644 index 00000000..9562cc65 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/get_qoi.py @@ -0,0 +1,183 @@ +import json +import os +import pickle as pkl + +import matplotlib as mpl +import numpy as np +from prettyPlot.plotting import * +from scipy.optimize import curve_fit + + +def get_sim_folds(path): + folds = os.listdir(path) + sim_folds = [] + for fold in folds: + if fold.startswith("loop"): + sim_folds.append(fold) + return sim_folds + + +def func(t, cstar, kla): + t = t + t0 = 0 + c0 = 0 + return (cstar - c0) * (1 - np.exp(-kla * (t - t0))) + c0 + + +def get_vl(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("liqVol"): + vol = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read liqVol = {vol}m3") + return vol + + +def get_vvm(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("VVM"): + vvm = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read VVM = {vvm} [-]") + return vvm + + +def get_As(verb=False): + filename = os.path.join("constant", "globalVars") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if line.startswith("inletA"): + As = float(line.split()[-1][:-1]) + break + if verb: + print(f"Read As = {As}m2") + return As + + +def get_pmix(verb=False): + with open("system/mixers.json", "r+") as f: + data = json.load(f) + mixer_list = data["mixers"] + pmix = 0 + for mix in mixer_list: + pmix += mix["power"] / 1000 + if verb: + print(f"Read Mixing power = {pmix}kW") + return pmix + + +def get_lh(verb=False): + filename = os.path.join("system", "setFieldsDict") + with open(filename, "r+") as f: + lines = f.readlines() + for line in lines: + if "box (-1.0 -1.0 -1.0)" in line: + height = float(line.split("(")[2].split()[1]) + break + if verb: + print(f"Read Height = {height}m") + return height + + +def get_pinj(vvm, Vl, As, lh): + rhog = 1.25 # kg /m3 + Vg = Vl * vvm / (60 * As * 1) # m/s + Ptank = 101325 # Pa + # Ptank = 0 # Pa + rhoL = 1000 # kg / m3 + Pl = 101325 + rhoL * 9.8 * lh # Pa + # W + P1 = rhog * As * Vg**3 + # W + P2 = (Pl - Ptank) * As * Vg + # kg /s + MF = rhog * Vg * As + # kwh / kg + e_m = (P1 + P2) / (3600 * 1000 * MF) + + # returns kW + return (P1 + P2) * 1e-3 + + +def get_qoi(kla_co2, cs_co2, kla_h2, cs_h2, verb=False): + vvm = get_vvm(verb) + As = get_As(verb) + V_l = get_vl(verb) + liqh = get_lh(verb) + P_inj = get_pinj(vvm, V_l, As, liqh) + P_mix = get_pmix(verb) + + qoi_co2 = kla_co2 * cs_co2 * V_l * 0.04401 / (P_mix / 3600 + P_inj / 3600) + qoi_h2 = kla_h2 * cs_h2 * V_l * 0.002016 / (P_mix / 3600 + P_inj / 3600) + return qoi_co2 * qoi_h2 + + +def get_qoi_uq(kla_co2, cs_co2, kla_h2, cs_h2): + qoi = [] + for i in range(len(kla_co2)): + if i == 0: + verb = True + else: + verb = False + qoi.append(get_qoi(kla_co2[i], cs_co2[i], kla_h2[i], cs_h2[i], verb)) + qoi = np.array(qoi) + return np.mean(qoi), np.std(qoi) + + +os.makedirs("Figures", exist_ok=True) + +dataFolder = "data" +fold = "local" + +nuq = 100 +mean_cstar_co2 = np.random.uniform(12.6, 13.3, nuq) +mean_cstar_h2 = np.random.uniform(0.902, 0.96, nuq) + + +tmp_cs_h2 = [] +tmp_cs_co2 = [] +tmp_kla_h2 = [] +tmp_kla_co2 = [] +cs_co2 = mean_cstar_co2 +cs_h2 = mean_cstar_h2 + +a = np.load(os.path.join(dataFolder, fold, "conv.npz")) +endindex = -1 +if ( + "c_h2" in a + and "c_co2" in a + and len(a["time"][:endindex] > 0) + and (a["time"][:endindex][-1] > 95) +): + for i in range(nuq): + fitparamsH2, _ = curve_fit( + func, + np.array(a["time"][:endindex]), + np.array(a["c_h2"][:endindex]), + bounds=[(cs_h2[i] - 1e-6, 0), (cs_h2[i] + 1e-6, 1)], + ) + fitparamsCO2, _ = curve_fit( + func, + np.array(a["time"][:endindex]), + np.array(a["c_co2"][:endindex]), + bounds=[(cs_co2[i] - 1e-6, 0), (cs_co2[i] + 1e-6, 1)], + ) + tmp_kla_co2.append(fitparamsCO2[1]) + tmp_kla_h2.append(fitparamsH2[1]) + tmp_cs_h2.append(cs_h2[i]) + tmp_cs_co2.append(cs_co2[i]) + +qoi_m, qoi_s = get_qoi_uq(tmp_kla_co2, tmp_cs_co2, tmp_kla_h2, tmp_cs_h2) + + +with open("qoi.txt", "w+") as f: + f.write(f"{qoi_m},{qoi_s}\n") diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/presteps.sh b/bird/preprocess/data_preprocess/loop_reactor_3_6L/presteps.sh new file mode 100644 index 00000000..899655b8 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/presteps.sh @@ -0,0 +1,71 @@ +# Clean case +module load anaconda3/2023 +conda activate /projects/gas2fuels/conda_env/bird +source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc +./Allclean + +echo PRESTEP 1 +# Generate blockmeshDict +python /projects/gas2fuels/BioReactorDesign/applications/write_block_rect_mesh.py -i system/mesh.json -o system +#python ../../../applications/write_block_rect_mesh.py -i system/mesh.json -o system + +# Generate boundary stl +python /projects/gas2fuels/BioReactorDesign/applications/write_stl_patch.py -i system/inlets_outlets.json +#python ../../../applications/write_stl_patch.py -i system/inlets_outlets.json + +# Generate mixers +python /projects/gas2fuels/BioReactorDesign/applications/write_dynMix_fvModels_force_sign.py -i system/mixers.json -o constant +#python ../../../applications/write_dynMix_fvModels.py -i system/mixers.json -o constant + +echo PRESTEP 2 +# Mesh gen +blockMesh -dict system/blockMeshDict + +# Inlet BC +surfaceToPatch -tol 1e-3 inlets.stl +export newmeshdir=$(foamListTimes -latestTime) +rm -rf constant/polyMesh/ +cp -r $newmeshdir/polyMesh ./constant +rm -rf $newmeshdir +cp constant/polyMesh/boundary /tmp +sed -i -e 's/inlets\.stl/inlet/g' /tmp/boundary +cat /tmp/boundary > constant/polyMesh/boundary + +# Outlet BC +surfaceToPatch -tol 1e-3 outlets.stl +export newmeshdir=$(foamListTimes -latestTime) +rm -rf constant/polyMesh/ +cp -r $newmeshdir/polyMesh ./constant +rm -rf $newmeshdir +cp constant/polyMesh/boundary /tmp +sed -i -e 's/outlets\.stl/outlet/g' /tmp/boundary +cat /tmp/boundary > constant/polyMesh/boundary + + +# Scale +transformPoints "scale=(0.05 0.05 0.05)" + + +# setup IC +cp -r 0.orig 0 +setFields + +# Setup mass flow rate +# Get inlet area +postProcess -func 'patchIntegrate(patch="inlet", field="alpha.gas")' +postProcess -func writeCellVolumes +writeMeshObj + +echo PRESTEP 3 +python writeGlobalVars.py +cp constant/phaseProperties_constantd constant/phaseProperties + + +if [ -f qoi.txt ]; then + rm qoi.txt +fi +if [ -f data/local/conv.npz ]; then + rm data/local/conv.npz +fi + +conda deactivate diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/read_history.py b/bird/preprocess/data_preprocess/loop_reactor_3_6L/read_history.py new file mode 100644 index 00000000..264711f8 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/read_history.py @@ -0,0 +1,239 @@ +import argparse +import os +import sys + +import numpy as np +from prettyPlot.plotting import plt, pretty_labels + +from bird.utilities.ofio import * + + +def compute_gas_holdup(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + alpha_liq = field_dict["alpha_liq"] + volume = field_dict["volume"] + holdup = np.sum((1 - alpha_liq) * volume) / np.sum(volume) + return holdup, field_dict + + +def co2liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("co2_liq" in field_dict) or field_dict["co2_liq"] is None: + co2_liq_file = os.path.join(caseFolder, timeFolder, "CO2.liquid") + co2_liq = readOFScal(co2_liq_file, nCells) + # print("computing co2 liq") + field_dict["co2_liq"] = co2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + co2_liq = field_dict["co2_liq"] + met = np.sum( + alpha_liq[indliq] * co2_liq[indliq] * volume[indliq] + ) / np.sum(volume[indliq]) + return met, field_dict + + +def cliq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("rho_liq" in field_dict) or field_dict["rho_liq"] is None: + rho_liq_file = os.path.join(caseFolder, timeFolder, "rhom") + rho_liq = readOFScal(rho_liq_file, nCells) + field_dict["rho_liq"] = rho_liq + if not ("co2_liq" in field_dict) or field_dict["co2_liq"] is None: + co2_liq_file = os.path.join(caseFolder, timeFolder, "CO2.liquid") + co2_liq = readOFScal(co2_liq_file, nCells) + # print("computing co2 liq") + field_dict["co2_liq"] = co2_liq + if not ("h2_liq" in field_dict) or field_dict["h2_liq"] is None: + h2_liq_file = os.path.join(caseFolder, timeFolder, "H2.liquid") + h2_liq = readOFScal(h2_liq_file, nCells) + # print("computing h2 liq") + field_dict["h2_liq"] = h2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + co2_liq = field_dict["co2_liq"] + h2_liq = field_dict["h2_liq"] + rho_liq = field_dict["rho_liq"] + + # c_h2 = rho_liq[indliq] * alpha_liq[indliq] * h2_liq[indliq] / 0.002016 + # c_co2 = rho_liq[indliq] * alpha_liq[indliq] * co2_liq[indliq] / 0.04401 + + c_h2 = 1000 * alpha_liq[indliq] * h2_liq[indliq] / 0.002016 + c_co2 = 1000 * alpha_liq[indliq] * co2_liq[indliq] / 0.04401 + + c_h2 = np.sum(c_h2 * volume[indliq]) / np.sum(volume[indliq]) + c_co2 = np.sum(c_co2 * volume[indliq]) / np.sum(volume[indliq]) + + return c_co2, c_h2, field_dict + + +def h2liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("h2_liq" in field_dict) or field_dict["h2_liq"] is None: + h2_liq_file = os.path.join(caseFolder, timeFolder, "H2.liquid") + h2_liq = readOFScal(h2_liq_file, nCells) + # print("computing h2 liq") + field_dict["h2_liq"] = h2_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + if not ("indliq" in field_dict) or field_dict["indliq"] is None: + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.5) + # print("computing indliq") + field_dict["indliq"] = indliq + volume = field_dict["volume"] + indliq = field_dict["indliq"] + alpha_liq = field_dict["alpha_liq"] + h2_liq = field_dict["h2_liq"] + met = np.sum(alpha_liq[indliq] * h2_liq[indliq] * volume[indliq]) / np.sum( + volume[indliq] + ) + return met, field_dict + + +def vol_liq(caseFolder, timeFolder, nCells, field_dict={}): + if not ("alpha_liq" in field_dict) or field_dict["alpha_liq"] is None: + alpha_liq_file = os.path.join(caseFolder, timeFolder, "alpha.liquid") + alpha_liq = readOFScal(alpha_liq_file, nCells) + # print("reading alpha_liq") + field_dict["alpha_liq"] = alpha_liq + if not ("volume" in field_dict) or field_dict["volume"] is None: + volume_file = os.path.join(caseFolder, "0", "V") + volume = readOFScal(volume_file, nCells) + # print("reading Volume") + field_dict["volume"] = volume + volume = field_dict["volume"] + alpha_liq = field_dict["alpha_liq"] + indliq = np.argwhere(alpha_liq > 0.0) + liqvol = np.sum(alpha_liq[indliq] * volume[indliq]) / np.sum( + volume[indliq] + ) + return liqvol, field_dict + + +parser = argparse.ArgumentParser(description="Convergence of GH") +parser.add_argument( + "-cn", + "--case_name", + type=str, + metavar="", + required=True, + help="Case name", +) +parser.add_argument( + "-df", + "--data_folder", + type=str, + metavar="", + required=False, + help="data folder name", + default="data", +) + +args, unknown = parser.parse_known_args() + + +case_root = "." # "../" +case_name = args.case_name # "12_hole_sparger_snappyRefine_700rpm_opt_coeff" +case_path = "." +dataFolder = args.data_folder + +if os.path.isfile(os.path.join(dataFolder, case_name, "conv.npz")): + sys.exit("WARNING: History already created, Skipping") + +time_float_sorted, time_str_sorted = getCaseTimes(case_path, remove_zero=True) +cellCentres = readMesh(os.path.join(case_path, f"meshCellCentres_0.obj")) +nCells = len(cellCentres) + + +co2_history = np.zeros(len(time_str_sorted)) +c_co2_history = np.zeros(len(time_str_sorted)) +h2_history = np.zeros(len(time_str_sorted)) +c_h2_history = np.zeros(len(time_str_sorted)) +gh_history = np.zeros(len(time_str_sorted)) +liqvol_history = np.zeros(len(time_str_sorted)) +print(f"case_path = {case_path}") +field_dict = {} +for itime, time in enumerate(time_float_sorted): + time_folder = time_str_sorted[itime] + print(f"\tTime : {time_folder}") + if not field_dict == {}: + new_field_dict = {} + if "volume" in field_dict: + new_field_dict["volume"] = field_dict["volume"] + field_dict = new_field_dict + gh_history[itime], field_dict = compute_gas_holdup( + case_path, time_str_sorted[itime], nCells, field_dict + ) + co2_history[itime], field_dict = co2liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + h2_history[itime], field_dict = h2liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + liqvol_history[itime], field_dict = vol_liq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + c_co2_history[itime], c_h2_history[itime], field_dict = cliq( + case_path, time_str_sorted[itime], nCells, field_dict + ) + + +os.makedirs(dataFolder, exist_ok=True) +os.makedirs(os.path.join(dataFolder, case_name), exist_ok=True) +np.savez( + os.path.join(dataFolder, case_name, "conv.npz"), + time=np.array(time_float_sorted), + gh=gh_history, + co2=co2_history, + h2=h2_history, + vol_liq=liqvol_history, + c_h2=c_h2_history, + c_co2=c_co2_history, +) diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/run.sh b/bird/preprocess/data_preprocess/loop_reactor_3_6L/run.sh new file mode 100644 index 00000000..6b7eb516 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/run.sh @@ -0,0 +1,5 @@ +multiphaseEulerFoam + + + + diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/script b/bird/preprocess/data_preprocess/loop_reactor_3_6L/script new file mode 100755 index 00000000..090e5c05 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/script @@ -0,0 +1,14 @@ +#!/bin/bash +#SBATCH --qos=high +#SBATCH --job-name=val2 +##SBATCH --partition=debug +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=16 +#SBATCH --time=07:59:00 +#SBATCH --account=co2snow + +bash presteps.sh +source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc +decomposePar -fileHandler collated +srun -n 16 multiphaseEulerFoam -parallel -fileHandler collated +reconstructPar -newTimes diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/script_post b/bird/preprocess/data_preprocess/loop_reactor_3_6L/script_post new file mode 100755 index 00000000..aabbc33e --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/script_post @@ -0,0 +1,10 @@ +#!/bin/bash +#SBATCH --qos=high +#SBATCH --job-name=val2 +##SBATCH --partition=debug +#SBATCH --nodes=1 +#SBATCH --ntasks-per-node=16 +#SBATCH --time=00:59:00 +#SBATCH --account=co2snow + +bash computeQOI.sh diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/blockMeshDict b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/blockMeshDict new file mode 100644 index 00000000..1183d262 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/blockMeshDict @@ -0,0 +1,746 @@ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +convertToMeters 1.0; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +vertices +( +( 0.0 0.0 0.0) +( 1.0 0.0 0.0) +( 2.0 0.0 0.0) +( 3.0 0.0 0.0) +( 4.0 0.0 0.0) +( 5.0 0.0 0.0) +( 6.0 0.0 0.0) +( 7.0 0.0 0.0) +( 8.0 0.0 0.0) +( 9.0 0.0 0.0) +( 10.0 0.0 0.0) +( 0.0 1.0 0.0) +( 1.0 1.0 0.0) +( 2.0 1.0 0.0) +( 3.0 1.0 0.0) +( 4.0 1.0 0.0) +( 5.0 1.0 0.0) +( 6.0 1.0 0.0) +( 7.0 1.0 0.0) +( 8.0 1.0 0.0) +( 9.0 1.0 0.0) +( 10.0 1.0 0.0) +( 0.0 2.0 0.0) +( 1.0 2.0 0.0) +( 2.0 2.0 0.0) +( 3.0 2.0 0.0) +( 4.0 2.0 0.0) +( 5.0 2.0 0.0) +( 6.0 2.0 0.0) +( 7.0 2.0 0.0) +( 8.0 2.0 0.0) +( 9.0 2.0 0.0) +( 10.0 2.0 0.0) +( 0.0 3.0 0.0) +( 1.0 3.0 0.0) +( 2.0 3.0 0.0) +( 3.0 3.0 0.0) +( 4.0 3.0 0.0) +( 5.0 3.0 0.0) +( 6.0 3.0 0.0) +( 7.0 3.0 0.0) +( 8.0 3.0 0.0) +( 9.0 3.0 0.0) +( 10.0 3.0 0.0) +( 0.0 4.0 0.0) +( 1.0 4.0 0.0) +( 2.0 4.0 0.0) +( 3.0 4.0 0.0) +( 4.0 4.0 0.0) +( 5.0 4.0 0.0) +( 6.0 4.0 0.0) +( 7.0 4.0 0.0) +( 8.0 4.0 0.0) +( 9.0 4.0 0.0) +( 10.0 4.0 0.0) +( 0.0 5.0 0.0) +( 1.0 5.0 0.0) +( 2.0 5.0 0.0) +( 3.0 5.0 0.0) +( 4.0 5.0 0.0) +( 5.0 5.0 0.0) +( 6.0 5.0 0.0) +( 7.0 5.0 0.0) +( 8.0 5.0 0.0) +( 9.0 5.0 0.0) +( 10.0 5.0 0.0) +( 0.0 6.0 0.0) +( 1.0 6.0 0.0) +( 2.0 6.0 0.0) +( 3.0 6.0 0.0) +( 4.0 6.0 0.0) +( 5.0 6.0 0.0) +( 6.0 6.0 0.0) +( 7.0 6.0 0.0) +( 8.0 6.0 0.0) +( 9.0 6.0 0.0) +( 10.0 6.0 0.0) +( 0.0 7.0 0.0) +( 1.0 7.0 0.0) +( 2.0 7.0 0.0) +( 3.0 7.0 0.0) +( 4.0 7.0 0.0) +( 5.0 7.0 0.0) +( 6.0 7.0 0.0) +( 7.0 7.0 0.0) +( 8.0 7.0 0.0) +( 9.0 7.0 0.0) +( 10.0 7.0 0.0) +( 0.0 0.0 1.0) +( 1.0 0.0 1.0) +( 2.0 0.0 1.0) +( 3.0 0.0 1.0) +( 4.0 0.0 1.0) +( 5.0 0.0 1.0) +( 6.0 0.0 1.0) +( 7.0 0.0 1.0) +( 8.0 0.0 1.0) +( 9.0 0.0 1.0) +( 10.0 0.0 1.0) +( 0.0 1.0 1.0) +( 1.0 1.0 1.0) +( 2.0 1.0 1.0) +( 3.0 1.0 1.0) +( 4.0 1.0 1.0) +( 5.0 1.0 1.0) +( 6.0 1.0 1.0) +( 7.0 1.0 1.0) +( 8.0 1.0 1.0) +( 9.0 1.0 1.0) +( 10.0 1.0 1.0) +( 0.0 2.0 1.0) +( 1.0 2.0 1.0) +( 2.0 2.0 1.0) +( 3.0 2.0 1.0) +( 4.0 2.0 1.0) +( 5.0 2.0 1.0) +( 6.0 2.0 1.0) +( 7.0 2.0 1.0) +( 8.0 2.0 1.0) +( 9.0 2.0 1.0) +( 10.0 2.0 1.0) +( 0.0 3.0 1.0) +( 1.0 3.0 1.0) +( 2.0 3.0 1.0) +( 3.0 3.0 1.0) +( 4.0 3.0 1.0) +( 5.0 3.0 1.0) +( 6.0 3.0 1.0) +( 7.0 3.0 1.0) +( 8.0 3.0 1.0) +( 9.0 3.0 1.0) +( 10.0 3.0 1.0) +( 0.0 4.0 1.0) +( 1.0 4.0 1.0) +( 2.0 4.0 1.0) +( 3.0 4.0 1.0) +( 4.0 4.0 1.0) +( 5.0 4.0 1.0) +( 6.0 4.0 1.0) +( 7.0 4.0 1.0) +( 8.0 4.0 1.0) +( 9.0 4.0 1.0) +( 10.0 4.0 1.0) +( 0.0 5.0 1.0) +( 1.0 5.0 1.0) +( 2.0 5.0 1.0) +( 3.0 5.0 1.0) +( 4.0 5.0 1.0) +( 5.0 5.0 1.0) +( 6.0 5.0 1.0) +( 7.0 5.0 1.0) +( 8.0 5.0 1.0) +( 9.0 5.0 1.0) +( 10.0 5.0 1.0) +( 0.0 6.0 1.0) +( 1.0 6.0 1.0) +( 2.0 6.0 1.0) +( 3.0 6.0 1.0) +( 4.0 6.0 1.0) +( 5.0 6.0 1.0) +( 6.0 6.0 1.0) +( 7.0 6.0 1.0) +( 8.0 6.0 1.0) +( 9.0 6.0 1.0) +( 10.0 6.0 1.0) +( 0.0 7.0 1.0) +( 1.0 7.0 1.0) +( 2.0 7.0 1.0) +( 3.0 7.0 1.0) +( 4.0 7.0 1.0) +( 5.0 7.0 1.0) +( 6.0 7.0 1.0) +( 7.0 7.0 1.0) +( 8.0 7.0 1.0) +( 9.0 7.0 1.0) +( 10.0 7.0 1.0) +( 0.0 0.0 2.0) +( 1.0 0.0 2.0) +( 2.0 0.0 2.0) +( 3.0 0.0 2.0) +( 4.0 0.0 2.0) +( 5.0 0.0 2.0) +( 6.0 0.0 2.0) +( 7.0 0.0 2.0) +( 8.0 0.0 2.0) +( 9.0 0.0 2.0) +( 10.0 0.0 2.0) +( 0.0 1.0 2.0) +( 1.0 1.0 2.0) +( 2.0 1.0 2.0) +( 3.0 1.0 2.0) +( 4.0 1.0 2.0) +( 5.0 1.0 2.0) +( 6.0 1.0 2.0) +( 7.0 1.0 2.0) +( 8.0 1.0 2.0) +( 9.0 1.0 2.0) +( 10.0 1.0 2.0) +( 0.0 2.0 2.0) +( 1.0 2.0 2.0) +( 2.0 2.0 2.0) +( 3.0 2.0 2.0) +( 4.0 2.0 2.0) +( 5.0 2.0 2.0) +( 6.0 2.0 2.0) +( 7.0 2.0 2.0) +( 8.0 2.0 2.0) +( 9.0 2.0 2.0) +( 10.0 2.0 2.0) +( 0.0 3.0 2.0) +( 1.0 3.0 2.0) +( 2.0 3.0 2.0) +( 3.0 3.0 2.0) +( 4.0 3.0 2.0) +( 5.0 3.0 2.0) +( 6.0 3.0 2.0) +( 7.0 3.0 2.0) +( 8.0 3.0 2.0) +( 9.0 3.0 2.0) +( 10.0 3.0 2.0) +( 0.0 4.0 2.0) +( 1.0 4.0 2.0) +( 2.0 4.0 2.0) +( 3.0 4.0 2.0) +( 4.0 4.0 2.0) +( 5.0 4.0 2.0) +( 6.0 4.0 2.0) +( 7.0 4.0 2.0) +( 8.0 4.0 2.0) +( 9.0 4.0 2.0) +( 10.0 4.0 2.0) +( 0.0 5.0 2.0) +( 1.0 5.0 2.0) +( 2.0 5.0 2.0) +( 3.0 5.0 2.0) +( 4.0 5.0 2.0) +( 5.0 5.0 2.0) +( 6.0 5.0 2.0) +( 7.0 5.0 2.0) +( 8.0 5.0 2.0) +( 9.0 5.0 2.0) +( 10.0 5.0 2.0) +( 0.0 6.0 2.0) +( 1.0 6.0 2.0) +( 2.0 6.0 2.0) +( 3.0 6.0 2.0) +( 4.0 6.0 2.0) +( 5.0 6.0 2.0) +( 6.0 6.0 2.0) +( 7.0 6.0 2.0) +( 8.0 6.0 2.0) +( 9.0 6.0 2.0) +( 10.0 6.0 2.0) +( 0.0 7.0 2.0) +( 1.0 7.0 2.0) +( 2.0 7.0 2.0) +( 3.0 7.0 2.0) +( 4.0 7.0 2.0) +( 5.0 7.0 2.0) +( 6.0 7.0 2.0) +( 7.0 7.0 2.0) +( 8.0 7.0 2.0) +( 9.0 7.0 2.0) +( 10.0 7.0 2.0) +( 0.0 0.0 3.0) +( 1.0 0.0 3.0) +( 2.0 0.0 3.0) +( 3.0 0.0 3.0) +( 4.0 0.0 3.0) +( 5.0 0.0 3.0) +( 6.0 0.0 3.0) +( 7.0 0.0 3.0) +( 8.0 0.0 3.0) +( 9.0 0.0 3.0) +( 10.0 0.0 3.0) +( 0.0 1.0 3.0) +( 1.0 1.0 3.0) +( 2.0 1.0 3.0) +( 3.0 1.0 3.0) +( 4.0 1.0 3.0) +( 5.0 1.0 3.0) +( 6.0 1.0 3.0) +( 7.0 1.0 3.0) +( 8.0 1.0 3.0) +( 9.0 1.0 3.0) +( 10.0 1.0 3.0) +( 0.0 2.0 3.0) +( 1.0 2.0 3.0) +( 2.0 2.0 3.0) +( 3.0 2.0 3.0) +( 4.0 2.0 3.0) +( 5.0 2.0 3.0) +( 6.0 2.0 3.0) +( 7.0 2.0 3.0) +( 8.0 2.0 3.0) +( 9.0 2.0 3.0) +( 10.0 2.0 3.0) +( 0.0 3.0 3.0) +( 1.0 3.0 3.0) +( 2.0 3.0 3.0) +( 3.0 3.0 3.0) +( 4.0 3.0 3.0) +( 5.0 3.0 3.0) +( 6.0 3.0 3.0) +( 7.0 3.0 3.0) +( 8.0 3.0 3.0) +( 9.0 3.0 3.0) +( 10.0 3.0 3.0) +( 0.0 4.0 3.0) +( 1.0 4.0 3.0) +( 2.0 4.0 3.0) +( 3.0 4.0 3.0) +( 4.0 4.0 3.0) +( 5.0 4.0 3.0) +( 6.0 4.0 3.0) +( 7.0 4.0 3.0) +( 8.0 4.0 3.0) +( 9.0 4.0 3.0) +( 10.0 4.0 3.0) +( 0.0 5.0 3.0) +( 1.0 5.0 3.0) +( 2.0 5.0 3.0) +( 3.0 5.0 3.0) +( 4.0 5.0 3.0) +( 5.0 5.0 3.0) +( 6.0 5.0 3.0) +( 7.0 5.0 3.0) +( 8.0 5.0 3.0) +( 9.0 5.0 3.0) +( 10.0 5.0 3.0) +( 0.0 6.0 3.0) +( 1.0 6.0 3.0) +( 2.0 6.0 3.0) +( 3.0 6.0 3.0) +( 4.0 6.0 3.0) +( 5.0 6.0 3.0) +( 6.0 6.0 3.0) +( 7.0 6.0 3.0) +( 8.0 6.0 3.0) +( 9.0 6.0 3.0) +( 10.0 6.0 3.0) +( 0.0 7.0 3.0) +( 1.0 7.0 3.0) +( 2.0 7.0 3.0) +( 3.0 7.0 3.0) +( 4.0 7.0 3.0) +( 5.0 7.0 3.0) +( 6.0 7.0 3.0) +( 7.0 7.0 3.0) +( 8.0 7.0 3.0) +( 9.0 7.0 3.0) +( 10.0 7.0 3.0) +( 0.0 0.0 4.0) +( 1.0 0.0 4.0) +( 2.0 0.0 4.0) +( 3.0 0.0 4.0) +( 4.0 0.0 4.0) +( 5.0 0.0 4.0) +( 6.0 0.0 4.0) +( 7.0 0.0 4.0) +( 8.0 0.0 4.0) +( 9.0 0.0 4.0) +( 10.0 0.0 4.0) +( 0.0 1.0 4.0) +( 1.0 1.0 4.0) +( 2.0 1.0 4.0) +( 3.0 1.0 4.0) +( 4.0 1.0 4.0) +( 5.0 1.0 4.0) +( 6.0 1.0 4.0) +( 7.0 1.0 4.0) +( 8.0 1.0 4.0) +( 9.0 1.0 4.0) +( 10.0 1.0 4.0) +( 0.0 2.0 4.0) +( 1.0 2.0 4.0) +( 2.0 2.0 4.0) +( 3.0 2.0 4.0) +( 4.0 2.0 4.0) +( 5.0 2.0 4.0) +( 6.0 2.0 4.0) +( 7.0 2.0 4.0) +( 8.0 2.0 4.0) +( 9.0 2.0 4.0) +( 10.0 2.0 4.0) +( 0.0 3.0 4.0) +( 1.0 3.0 4.0) +( 2.0 3.0 4.0) +( 3.0 3.0 4.0) +( 4.0 3.0 4.0) +( 5.0 3.0 4.0) +( 6.0 3.0 4.0) +( 7.0 3.0 4.0) +( 8.0 3.0 4.0) +( 9.0 3.0 4.0) +( 10.0 3.0 4.0) +( 0.0 4.0 4.0) +( 1.0 4.0 4.0) +( 2.0 4.0 4.0) +( 3.0 4.0 4.0) +( 4.0 4.0 4.0) +( 5.0 4.0 4.0) +( 6.0 4.0 4.0) +( 7.0 4.0 4.0) +( 8.0 4.0 4.0) +( 9.0 4.0 4.0) +( 10.0 4.0 4.0) +( 0.0 5.0 4.0) +( 1.0 5.0 4.0) +( 2.0 5.0 4.0) +( 3.0 5.0 4.0) +( 4.0 5.0 4.0) +( 5.0 5.0 4.0) +( 6.0 5.0 4.0) +( 7.0 5.0 4.0) +( 8.0 5.0 4.0) +( 9.0 5.0 4.0) +( 10.0 5.0 4.0) +( 0.0 6.0 4.0) +( 1.0 6.0 4.0) +( 2.0 6.0 4.0) +( 3.0 6.0 4.0) +( 4.0 6.0 4.0) +( 5.0 6.0 4.0) +( 6.0 6.0 4.0) +( 7.0 6.0 4.0) +( 8.0 6.0 4.0) +( 9.0 6.0 4.0) +( 10.0 6.0 4.0) +( 0.0 7.0 4.0) +( 1.0 7.0 4.0) +( 2.0 7.0 4.0) +( 3.0 7.0 4.0) +( 4.0 7.0 4.0) +( 5.0 7.0 4.0) +( 6.0 7.0 4.0) +( 7.0 7.0 4.0) +( 8.0 7.0 4.0) +( 9.0 7.0 4.0) +( 10.0 7.0 4.0) +( 0.0 0.0 5.0) +( 1.0 0.0 5.0) +( 2.0 0.0 5.0) +( 3.0 0.0 5.0) +( 4.0 0.0 5.0) +( 5.0 0.0 5.0) +( 6.0 0.0 5.0) +( 7.0 0.0 5.0) +( 8.0 0.0 5.0) +( 9.0 0.0 5.0) +( 10.0 0.0 5.0) +( 0.0 1.0 5.0) +( 1.0 1.0 5.0) +( 2.0 1.0 5.0) +( 3.0 1.0 5.0) +( 4.0 1.0 5.0) +( 5.0 1.0 5.0) +( 6.0 1.0 5.0) +( 7.0 1.0 5.0) +( 8.0 1.0 5.0) +( 9.0 1.0 5.0) +( 10.0 1.0 5.0) +( 0.0 2.0 5.0) +( 1.0 2.0 5.0) +( 2.0 2.0 5.0) +( 3.0 2.0 5.0) +( 4.0 2.0 5.0) +( 5.0 2.0 5.0) +( 6.0 2.0 5.0) +( 7.0 2.0 5.0) +( 8.0 2.0 5.0) +( 9.0 2.0 5.0) +( 10.0 2.0 5.0) +( 0.0 3.0 5.0) +( 1.0 3.0 5.0) +( 2.0 3.0 5.0) +( 3.0 3.0 5.0) +( 4.0 3.0 5.0) +( 5.0 3.0 5.0) +( 6.0 3.0 5.0) +( 7.0 3.0 5.0) +( 8.0 3.0 5.0) +( 9.0 3.0 5.0) +( 10.0 3.0 5.0) +( 0.0 4.0 5.0) +( 1.0 4.0 5.0) +( 2.0 4.0 5.0) +( 3.0 4.0 5.0) +( 4.0 4.0 5.0) +( 5.0 4.0 5.0) +( 6.0 4.0 5.0) +( 7.0 4.0 5.0) +( 8.0 4.0 5.0) +( 9.0 4.0 5.0) +( 10.0 4.0 5.0) +( 0.0 5.0 5.0) +( 1.0 5.0 5.0) +( 2.0 5.0 5.0) +( 3.0 5.0 5.0) +( 4.0 5.0 5.0) +( 5.0 5.0 5.0) +( 6.0 5.0 5.0) +( 7.0 5.0 5.0) +( 8.0 5.0 5.0) +( 9.0 5.0 5.0) +( 10.0 5.0 5.0) +( 0.0 6.0 5.0) +( 1.0 6.0 5.0) +( 2.0 6.0 5.0) +( 3.0 6.0 5.0) +( 4.0 6.0 5.0) +( 5.0 6.0 5.0) +( 6.0 6.0 5.0) +( 7.0 6.0 5.0) +( 8.0 6.0 5.0) +( 9.0 6.0 5.0) +( 10.0 6.0 5.0) +( 0.0 7.0 5.0) +( 1.0 7.0 5.0) +( 2.0 7.0 5.0) +( 3.0 7.0 5.0) +( 4.0 7.0 5.0) +( 5.0 7.0 5.0) +( 6.0 7.0 5.0) +( 7.0 7.0 5.0) +( 8.0 7.0 5.0) +( 9.0 7.0 5.0) +( 10.0 7.0 5.0) +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +blocks +( + + //block 0 +hex (0 1 12 11 88 89 100 99 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 1 +hex (1 2 13 12 89 90 101 100 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 2 +hex (2 3 14 13 90 91 102 101 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 3 +hex (3 4 15 14 91 92 103 102 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 4 +hex (4 5 16 15 92 93 104 103 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 5 +hex (5 6 17 16 93 94 105 104 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 6 +hex (6 7 18 17 94 95 106 105 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 7 +hex (7 8 19 18 95 96 107 106 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 8 +hex (8 9 20 19 96 97 108 107 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 9 +hex (9 10 21 20 97 98 109 108 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 10 +hex (97 98 109 108 185 186 197 196 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 11 +hex (185 186 197 196 273 274 285 284 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 12 +hex (273 274 285 284 361 362 373 372 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 13 +hex (361 362 373 372 449 450 461 460 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 14 +hex (360 361 372 371 448 449 460 459 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 15 +hex (359 360 371 370 447 448 459 458 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 16 +hex (358 359 370 369 446 447 458 457 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 17 +hex (357 358 369 368 445 446 457 456 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 18 +hex (356 357 368 367 444 445 456 455 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 19 +hex (355 356 367 366 443 444 455 454 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 20 +hex (354 355 366 365 442 443 454 453 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 21 +hex (353 354 365 364 441 442 453 452 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 22 +hex (352 353 364 363 440 441 452 451 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 23 +hex (363 364 375 374 451 452 463 462 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 24 +hex (374 375 386 385 462 463 474 473 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 25 +hex (385 386 397 396 473 474 485 484 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 26 +hex (396 397 408 407 484 485 496 495 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 27 +hex (407 408 419 418 495 496 507 506 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 28 +hex (418 419 430 429 506 507 518 517 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 29 +hex (308 309 320 319 396 397 408 407 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 30 +hex (220 221 232 231 308 309 320 319 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 31 +hex (132 133 144 143 220 221 232 231 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 32 +hex (44 45 56 55 132 133 144 143 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 33 +hex (55 56 67 66 143 144 155 154 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 34 +hex (66 67 78 77 154 155 166 165 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 35 +hex (33 34 45 44 121 122 133 132 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 36 +hex (22 23 34 33 110 111 122 121 ) +( 10 10 10 ) +SimpleGrading (1 1 1) + + //block 37 +hex (11 12 23 22 99 100 111 110 ) +( 10 10 10 ) +SimpleGrading (1 1 1) +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +defaultPatch +{ type wall;} + +patches +( +); diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/controlDict b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/controlDict new file mode 100644 index 00000000..7374023a --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/controlDict @@ -0,0 +1,67 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application multiphaseEulerFoam; + +startFrom latestTime;//startTime; + +startTime 0; + +stopAt endTime; + +endTime 100; + +deltaT 0.0001; + +writeControl adjustableRunTime; + +writeInterval 2; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.5; + +maxDeltaT 0.0005; + + +functions +{ + + #includeFunc writeObjects(d.gas) + #includeFunc writeObjects(thermo:rho.gas) + #includeFunc writeObjects(thermo:rho.liquid) +} +//functions +//{ +// #includeFunc fieldAverage(U.air, U.water, alpha.air, p) +//} + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/decomposeParDict b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/decomposeParDict new file mode 100755 index 00000000..f8397e73 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/decomposeParDict @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 3.0.x | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 16; + +method scotch; + +hierarchicalCoeffs +{ + n (4 4 1); + delta 0.001; + order xyz; +} + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvConstraints b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvConstraints new file mode 100644 index 00000000..334f1c8f --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvConstraints @@ -0,0 +1,56 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + object fvConstraints; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +limitp +{ + type limitPressure; + + min 1e4; +} +limitUliq +{ + type limitVelocity; + active yes; + U U.liquid; + selectionMode all; + max 1e1; +} +limitUgas +{ + type limitVelocity; + active yes; + U U.gas; + selectionMode all; + max 2e1; +} +limitTgas +{ + type limitTemperature; + selectionMode all; + min 290; + max 310; + phase gas; +} +limitTliq +{ + type limitTemperature; + selectionMode all; + min 290; + max 310; + phase liquid; +} + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvSchemes b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvSchemes new file mode 100644 index 00000000..52e6e13a --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvSchemes @@ -0,0 +1,70 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; + limited cellLimited Gauss linear 1; +} + +divSchemes +{ + default none; + + "div\(phi,alpha.*\)" Gauss vanLeer; + + "div\(phir,alpha.*,alpha.*\)" Gauss vanLeer; + + "div\(alphaRhoPhi.*,U.*\)" Gauss limitedLinearV 1; + "div\(phi.*,U.*\)" Gauss limitedLinearV 1; + "div\(alphaRhoPhi.*,Yi\)" Gauss limitedLinear 1; + "div\(alphaRhoPhi.*,(h|e).*\)" Gauss limitedLinear 1; + "div\(alphaRhoPhi.*,(K|k|epsilon|omega).*\)" Gauss limitedLinear 1; + "div\(alphaPhi.*,f.*\)" Gauss limitedLinear 1; + "div\(alphaRhoPhi.*,\(p\|thermo:rho.*\)\)" Gauss limitedLinear 1; + + "div\(phim,(k|epsilon)m\)" Gauss upwind; + "div\(\(\(\(alpha.*\*thermo:rho.*\)*nuEff.*\)*dev2\(T\(grad\(U.*\)\)\)\)\)" Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + +wallDist +{ + method Poisson; + nRequired true; +} + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvSolution b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvSolution new file mode 100644 index 00000000..2e69fdfa --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/fvSolution @@ -0,0 +1,120 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha.*" + { + nAlphaCorr 2; + nAlphaSubCycles 5; + } + + bubbles + { + nCorr 1; + tolerance 1e-4; + scale true; + solveOnFinalIterOnly true; + sourceUpdateInterval 1; + } + + p_rgh + { + solver GAMG; + smoother DIC; + tolerance 1e-7; + relTol 0; + } + + p_rghFinal + { + $p_rgh; + relTol 0; + } + + "(k|omega).*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-7; + relTol 0; + minIter 1; + } + + "(e|h).*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-8; + relTol 0; + minIter 0; + maxIter 3; + } + + "f.*" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-6; + relTol 0; + } + + "Yi.*" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-12; + relTol 0; + residualAlpha 1e-8; + } + + "U.*" + { + solver smoothSolver; + smoother symGaussSeidel; + tolerance 1e-5; + relTol 0; + minIter 1; + } + + yPsi + { + solver PCG; + preconditioner DIC; + tolerance 1e-10; + relTol 0; + } + +} + +PIMPLE +{ + nOuterCorrectors 3; + nCorrectors 1; + nNonOrthogonalCorrectors 0; + +} + +relaxationFactors +{ + equations + { + ".*" 1; + } +} + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/inlets_outlets.json b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/inlets_outlets.json new file mode 100644 index 00000000..2b53da73 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/inlets_outlets.json @@ -0,0 +1,28 @@ +{ + "Geometry": { + "OverallDomain": { + "x" : {"nblocks": 10, "size_per_block": 1.0}, + "y" : {"nblocks": 11, "size_per_block": 1.0}, + "z" : {"nblocks": 5, "size_per_block": 1.0} + }, + "Fluids": [ + [ [0,0,0], [9,0,0] ], + [ [9,0,0], [9,0,4] ], + [ [9,0,4], [0,0,4] ], + [ [0,1,4], [0,4,4] ], + [ [0,4,4], [0,10,4] ], + [ [0,4,4], [0,4,0] ], + [ [0,4,0], [0,10,0] ], + [ [0,4,0], [0,1,0] ] + ] + }, + "inlets": [ + {"branch_id": 0, "type": "circle", "frac_space": 0.2222222222222222, "normal_dir": 1, "radius": 0.4, "nelements": 50, "block_pos": "bottom"}, + {"branch_id": 0, "type": "circle", "frac_space": 0.5, "radius": 0.4, "normal_dir": 1,"nelements": 50, "block_pos": "bottom"}, + {"branch_id": 0, "type": "circle", "frac_space": 0.7777777777777778, "radius": 0.4, "normal_dir": 1,"nelements": 50, "block_pos": "bottom"} + ], + "outlets": [ + {"branch_id": 6, "type": "circle", "frac_space": 1, "normal_dir": 1, "radius": 0.4, "nelements": 50, "block_pos": "top"}, + {"branch_id": 4, "type": "circle", "frac_space": 1, "normal_dir": 1, "radius": 0.4, "nelements": 50, "block_pos": "top"} + ] +} diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/mesh.json b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/mesh.json new file mode 100644 index 00000000..29841d7e --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/mesh.json @@ -0,0 +1,26 @@ +{ + "Meshing": { + "Blockwise": { + "x" : 10, + "y" : 10, + "z" : 10 + } + }, + "Geometry": { + "OverallDomain": { + "x" : {"nblocks": 10, "size_per_block": 1.0}, + "y" : {"nblocks": 11, "size_per_block": 1.0}, + "z" : {"nblocks": 5, "size_per_block": 1.0} + }, + "Fluids": [ + [ [0,0,0], [9,0,0] ], + [ [9,0,0], [9,0,4] ], + [ [9,0,4], [0,0,4] ], + [ [0,1,4], [0,4,4] ], + [ [0,4,4], [0,10,4] ], + [ [0,4,4], [0,4,0] ], + [ [0,4,0], [0,10,0] ], + [ [0,4,0], [0,1,0] ] + ] + } +} diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/mixers.json b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/mixers.json new file mode 100644 index 00000000..10fdbd99 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/mixers.json @@ -0,0 +1,29 @@ +{ + "Meshing": { + "Blockwise": { + "x" : 10, + "y" : 10, + "z" : 10 + } + }, + "Geometry": { + "OverallDomain": { + "x" : {"nblocks": 10, "size_per_block": 1.0, "rescale": 0.05}, + "y" : {"nblocks": 11, "size_per_block": 1.0, "rescale": 0.05}, + "z" : {"nblocks": 5, "size_per_block": 1.0, "rescale": 0.05} + }, + "Fluids": [ + [ [0,0,0], [9,0,0] ], + [ [9,0,0], [9,0,4] ], + [ [9,0,4], [0,0,4] ], + [ [0,1,4], [0,4,4] ], + [ [0,4,4], [0,10,4] ], + [ [0,4,4], [0,4,0] ], + [ [0,4,0], [0,10,0] ], + [ [0,4,0], [0,1,0] ] + ] + }, + "mixers": [ + {"branch_id": 2, "frac_space": 0.5, "start_time": 1, "power": 1, "sign": "+"} + ] +} diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/setFieldsDict b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/setFieldsDict new file mode 100644 index 00000000..7faaeb15 --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/system/setFieldsDict @@ -0,0 +1,37 @@ +/*--------------------------------*- C++ -*----------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Version: dev + \\/ M anipulation | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha.gas 0.99 + volScalarFieldValue alpha.liquid 0.01 +); + +regions +( + boxToCell + { + box (-1.0 -1.0 -1.0) (10 0.2 10.0); + fieldValues + ( + volScalarFieldValue alpha.gas 0.01 + volScalarFieldValue alpha.liquid 0.99 + ); + } +); + + +// ************************************************************************* // diff --git a/bird/preprocess/data_preprocess/loop_reactor_3_6L/writeGlobalVars.py b/bird/preprocess/data_preprocess/loop_reactor_3_6L/writeGlobalVars.py new file mode 100644 index 00000000..0594eccc --- /dev/null +++ b/bird/preprocess/data_preprocess/loop_reactor_3_6L/writeGlobalVars.py @@ -0,0 +1,47 @@ +import os + +import numpy as np + +from bird.utilities.ofio import * + + +def writeGvars(inletA, liqVol): + filename_tmp = os.path.join("constant", "globalVars_temp") + with open(filename_tmp, "r+") as f: + lines = f.readlines() + filename = os.path.join("constant", "globalVars") + with open(filename, "w+") as f: + for line in lines: + if line.startswith("inletA"): + f.write(f"inletA\t{inletA:g};\n") + elif line.startswith("liqVol"): + f.write(f"liqVol\t{liqVol:g};\n") + else: + f.write(line) + + +def readInletArea(): + filename = os.path.join( + "postProcessing", + "patchIntegrate(patch=inlet,field=alpha.gas)", + "0", + "surfaceFieldValue.dat", + ) + with open(filename, "r+") as f: + lines = f.readlines() + return float(lines[4].split()[-1]) + + +def getLiqVol(): + cellCentres = readMesh(os.path.join(".", f"meshCellCentres_0.obj")) + volume_field = readOFScal(os.path.join("0", "V"), len(cellCentres)) + alpha_field = readOFScal( + os.path.join("0", "alpha.liquid"), len(cellCentres) + ) + return np.sum(volume_field * alpha_field) + + +if __name__ == "__main__": + A = readInletArea() + V = getLiqVol() + writeGvars(A, V) diff --git a/bird/preprocess/dynamic_mixer/io_fvModels.py b/bird/preprocess/dynamic_mixer/io_fvModels.py index 46092969..6d405984 100644 --- a/bird/preprocess/dynamic_mixer/io_fvModels.py +++ b/bird/preprocess/dynamic_mixer/io_fvModels.py @@ -42,18 +42,26 @@ def write_preamble(output_folder): f.write("\t\tconst volVectorField& UL =\n") f.write('\t\t\tmesh().lookupObject("U.liquid");\n') f.write("\t\tdouble pi=3.141592654;\n") + f.write(f"\t\tdouble source_pt_x;\n") + f.write(f"\t\tdouble source_pt_y;\n") + f.write(f"\t\tdouble source_pt_z;\n") + f.write(f"\t\tdouble disk_rad;\n") + f.write("\t\tdouble disk_area;\n") + f.write(f"\t\tdouble power;\n") + f.write(f"\t\tdouble smear_factor;\n") + f.write(f"\t\tdouble startTime;\n") def write_mixer(mixer, output_folder): with open(os.path.join(output_folder, "fvModels"), "a+") as f: - f.write(f"\t\tdouble source_pt_x={mixer.x};\n") - f.write(f"\t\tdouble source_pt_y={mixer.y};\n") - f.write(f"\t\tdouble source_pt_z={mixer.z};\n") - f.write(f"\t\tdouble disk_rad={mixer.rad};\n") - f.write("\t\tdouble disk_area=pi*disk_rad*disk_rad;\n") - f.write(f"\t\tdouble power={mixer.power};\n") - f.write(f"\t\tdouble smear_factor={float(mixer.smear)};\n") - f.write(f"\t\tconst scalar startTime = {mixer.start_time};\n") + f.write(f"\t\tsource_pt_x={mixer.x};\n") + f.write(f"\t\tsource_pt_y={mixer.y};\n") + f.write(f"\t\tsource_pt_z={mixer.z};\n") + f.write(f"\t\tdisk_rad={mixer.rad};\n") + f.write("\t\tdisk_area=pi*disk_rad*disk_rad;\n") + f.write(f"\t\tpower={mixer.power};\n") + f.write(f"\t\tsmear_factor={float(mixer.smear)};\n") + f.write(f"\t\tstartTime = {mixer.start_time};\n") f.write("\t\tif (time.value() > startTime)\n") f.write("\t\t{\n") f.write("\t\t\t// Get V1\n") @@ -61,7 +69,7 @@ def write_mixer(mixer, output_folder): f.write("\t\t\tdouble V1 = 0;\n") f.write("\t\t\tdouble V2 = 0;\n") f.write("\t\t\tdouble rhoV;\n") - f.write("\t\t\tdouble dist_tol = disk_rad*5;\n") + f.write("\t\t\tdouble dist_tol = disk_rad*3;\n") f.write("\n") f.write("\t\t\tdouble dist_n;\n") f.write("\t\t\tdouble upV = 0;\n") @@ -184,6 +192,139 @@ def write_mixer(mixer, output_folder): f.write("\t\t}\n") +def write_mixer_force_sign(mixer, output_folder): + with open(os.path.join(output_folder, "fvModels"), "a+") as f: + f.write(f"\t\tsource_pt_x={mixer.x};\n") + f.write(f"\t\tsource_pt_y={mixer.y};\n") + f.write(f"\t\tsource_pt_z={mixer.z};\n") + f.write(f"\t\tdisk_rad={mixer.rad};\n") + f.write("\t\tdisk_area=pi*disk_rad*disk_rad;\n") + f.write(f"\t\tpower={mixer.power};\n") + f.write(f"\t\tsmear_factor={float(mixer.smear)};\n") + f.write(f"\t\tstartTime = {mixer.start_time};\n") + f.write("\t\tif (time.value() > startTime)\n") + f.write("\t\t{\n") + f.write("\t\t\t// Get V1\n") + f.write("\t\t\tdouble source_sign_factor = 1.0;\n") + f.write("\t\t\tdouble V1 = 0;\n") + f.write("\t\t\tdouble V2 = 0;\n") + f.write("\t\t\tdouble rhoV;\n") + f.write("\t\t\tdouble dist_tol = disk_rad*3;\n") + f.write("\n") + f.write("\t\t\tdouble dist_n;\n") + f.write("\t\t\tdouble upV = 0;\n") + f.write("\t\t\tdouble uprhoV = 0;\n") + f.write("\t\t\tdouble upVvol = 0;\n") + f.write("\t\t\tdouble downV = 0;\n") + f.write("\t\t\tdouble downrhoV = 0;\n") + f.write("\t\t\tdouble downVvol = 0;\n") + f.write("\t\t\tdouble dist2;\n") + + f.write("\t\t\tforAll(C,i)\n") + f.write("\t\t\t{\n") + f.write( + "\t\t\t\tdist2 = (C[i].x()-source_pt_x)*(C[i].x()-source_pt_x);\n" + ) + f.write( + "\t\t\t\tdist2 += (C[i].y()-source_pt_y)*(C[i].y()-source_pt_y);\n" + ) + f.write( + "\t\t\t\tdist2 += (C[i].z()-source_pt_z)*(C[i].z()-source_pt_z);\n" + ) + f.write("\n") + if mixer.normal_dir == 0: + f.write("\t\t\t\tdist_n = (C[i].x()-source_pt_x);\n") + elif mixer.normal_dir == 1: + f.write("\t\t\t\tdist_n = (C[i].y()-source_pt_y);\n") + elif mixer.normal_dir == 2: + f.write("\t\t\t\tdist_n = (C[i].z()-source_pt_z);\n") + f.write("\n") + + f.write( + "\t\t\t\tif (dist2 < dist_tol*dist_tol && dist_n < -dist_tol/2) {\n" + ) + f.write("\t\t\t\t\tupVvol += V[i] * alphaL[i];\n") + f.write( + f"\t\t\t\t\tupV += V[i] * alphaL[i] * UL[i][{int(mixer.normal_dir)}];\n" + ) + f.write("\t\t\t\t\tuprhoV += V[i] * alphaL[i] * rhoL[i];\n") + f.write("\t\t\t\t}\n") + f.write( + "\t\t\t\tif (dist2 < dist_tol*dist_tol && dist_n > dist_tol/2) {\n" + ) + f.write("\t\t\t\t\tdownVvol += V[i] * alphaL[i];\n") + f.write( + f"\t\t\t\t\tdownV += V[i] * alphaL[i] * UL[i][{int(mixer.normal_dir)}];\n" + ) + f.write("\t\t\t\t\tdownrhoV += V[i] * alphaL[i] * rhoL[i];\n") + f.write("\t\t\t\t}\n") + f.write("\t\t\t}\n") + f.write("\n") + f.write("\t\t\treduce(uprhoV, sumOp());\n") + f.write("\t\t\treduce(downrhoV, sumOp());\n") + f.write("\t\t\treduce(upV, sumOp());\n") + f.write("\t\t\treduce(downV, sumOp());\n") + f.write("\t\t\treduce(downVvol, sumOp());\n") + f.write("\t\t\treduce(upVvol, sumOp());\n") + f.write("\n") + f.write("\t\t\tdownV /= downVvol;\n") + f.write("\t\t\tupV /= upVvol;\n") + f.write("\t\t\tdownrhoV /= downVvol;\n") + f.write("\t\t\tuprhoV /= upVvol;\n") + f.write("\n") + if mixer.sign == "+": + f.write("\t\t\tsource_sign_factor = -1.0;\n") + f.write("\t\t\tif (upV >= 0){\n") + f.write("\t\t\t\tV1 = 0.0;\n") + f.write("\t\t\t} else {\n") + f.write("\t\t\t\tV1 = std::abs(upV);\n") + f.write("\t\t\t}\n") + f.write("\t\t\trhoV = uprhoV;\n") + elif mixer.sign == "-": + f.write("\t\t\tsource_sign_factor = 1.0;\n") + f.write("\t\t\tif (downV <= 0){\n") + f.write("\t\t\t\tV1 = 0.0;\n") + f.write("\t\t\t} else {\n") + f.write("\t\t\t\tV1 = std::abs(downV);\n") + f.write("\t\t\t}\n") + f.write("\t\t\trhoV = downrhoV;\n") + # f.write("\t\t\t}\n") + f.write( + '\t\t\tFoam::Info << "[BIRD:DYNMIX INFO] V1 = " << V1 << endl;\n' + ) + f.write("\t\t\t\n") + f.write("\t\t\t// Get V2\n") + f.write("\t\t\tV2 = findV2(power, rhoV, disk_area, V1);\n") + f.write("\n") + f.write("\t\t\tforAll(C,i)\n") + f.write("\t\t\t{\n") + f.write( + "\t\t\t\tdouble Thrust=0.5*rhoL[i]*(V2*V2 - V1*V1)*disk_area;\n" + ) + f.write( + "\t\t\t\tdouble dist2=(C[i].x()-source_pt_x)*(C[i].x()-source_pt_x);\n" + ) + f.write( + "\t\t\t\tdist2 += (C[i].y()-source_pt_y)*(C[i].y()-source_pt_y);\n" + ) + f.write( + "\t\t\t\tdist2 += (C[i].z()-source_pt_z)*(C[i].z()-source_pt_z);\n" + ) + + f.write("\t\t\t\tdouble epsilon=pow(V[i],0.33333)*smear_factor;\n") + f.write( + "\t\t\t\tdouble sourceterm=alphaL[i]*(Thrust/pow(pi,1.5)/pow(epsilon,3.0))*\n" + ) + f.write("\t\t\t\t\texp(-dist2/(epsilon*epsilon));\n") + + f.write( + f"\t\t\t\tUsource[i][{int(mixer.normal_dir)}] -= source_sign_factor*sourceterm*V[i];\n" + ) + + f.write("\t\t\t}\n") + f.write("\t\t}\n") + + def write_end(output_folder): with open(os.path.join(output_folder, "fvModels"), "a+") as f: f.write("\t#};\n") diff --git a/bird/preprocess/dynamic_mixer/mixer.py b/bird/preprocess/dynamic_mixer/mixer.py index 1cc9b8b5..d3068427 100644 --- a/bird/preprocess/dynamic_mixer/mixer.py +++ b/bird/preprocess/dynamic_mixer/mixer.py @@ -15,6 +15,7 @@ def __init__(self): self.ready = False def update_from_expl_dict(self, mixer_dict): + print("\nMaking dynamic mixer with explicit input") if "x" in mixer_dict: self.x = mixer_dict["x"] if "y" in mixer_dict: @@ -36,6 +37,7 @@ def update_from_expl_dict(self, mixer_dict): self.check_status() def update_from_loop_dict(self, mixer_dict, geom_dict, mesh_dict=None): + print("\nMaking dynamic mixer from loop specific input") segment = geom_dict["segments"][mixer_dict["branch_id"]] pos = segment["start"] + mixer_dict["frac_space"] * segment["conn"] self.x = pos[0] @@ -81,13 +83,13 @@ def check_status(self, blocks=None): self.ready = False else: print( - f"\n\tpos({self.x:.2g}, {self.y:.2g}, {self.z:.2g})" + f"\tpos({self.x:.2g}, {self.y:.2g}, {self.z:.2g})m" + f"\n\tnormal_dir {self.normal_dir}" - + f"\n\trad {self.rad:.2g}" - + f"\n\tpower {self.power:.2g}" + + f"\n\trad {self.rad:.2g}m" + + f"\n\tpower {self.power:.2g}W" + f"\n\tsign {self.sign}" - + f"\n\tsmear {self.smear}" - + f"\n\tstart_time {self.start_time:.2g}" + + f"\n\tsmear {self.smear} grid points" + + f"\n\tstart_time {self.start_time:.2g}s" ) if blocks is not None: print(f"\tbranch = {blocks}") diff --git a/bird/preprocess/dynamic_mixer/mixing_fvModels.py b/bird/preprocess/dynamic_mixer/mixing_fvModels.py index 95eb04f6..c5db71a7 100644 --- a/bird/preprocess/dynamic_mixer/mixing_fvModels.py +++ b/bird/preprocess/dynamic_mixer/mixing_fvModels.py @@ -10,6 +10,7 @@ def check_input(input_dict): assert isinstance(input_dict, dict) mix_type = [] for mix in input_dict["mixers"]: + if "x" in mix: mix_type.append("expl") else: @@ -28,7 +29,7 @@ def check_input(input_dict): return mix_type -def write_fvModel(input_dict, output_folder="."): +def write_fvModel(input_dict, output_folder=".", force_sign=False): mix_type = check_input(input_dict) write_preamble(output_folder) if "loop" in mix_type: @@ -39,13 +40,19 @@ def write_fvModel(input_dict, output_folder="."): if mtype == "expl": mixer.update_from_expl_dict(input_dict["mixers"][imix]) if mixer.ready: - write_mixer(mixer, output_folder) + if force_sign: + write_mixer_force_sign(mixer, output_folder) + else: + write_mixer(mixer, output_folder) elif mtype == "loop": mixer.update_from_loop_dict( input_dict["mixers"][imix], geom_dict, mesh_dict ) if mixer.ready: - write_mixer(mixer, output_folder) + if force_sign: + write_mixer_force_sign(mixer, output_folder) + else: + write_mixer(mixer, output_folder) write_end(output_folder) diff --git a/bird/preprocess/json_gen/design_io.py b/bird/preprocess/json_gen/design_io.py new file mode 100644 index 00000000..d6ed2c72 --- /dev/null +++ b/bird/preprocess/json_gen/design_io.py @@ -0,0 +1,85 @@ +import json + + +def generate_stl_patch(filename, bc_dict, geom_dict): + final_dict = {} + final_dict["Geometry"] = geom_dict["Geometry"] + for patch in bc_dict: + final_dict[patch] = bc_dict[patch] + with open(filename, "w+") as f: + json.dump(final_dict, f, indent=2) + + +def generate_dynamic_mixer(filename, mixers_list, geom_dict): + final_dict = {} + final_dict["Meshing"] = geom_dict["Meshing"] + final_dict["Geometry"] = geom_dict["Geometry"] + final_dict["mixers"] = mixers_list + with open(filename, "w+") as f: + json.dump(final_dict, f, indent=2) + + +def make_default_geom_dict_from_file(filename, rescale=2.7615275385627096): + with open(filename, "r+") as f: + geom_dict = json.load(f) + if "rescale" not in geom_dict["Geometry"]["OverallDomain"]["x"]: + geom_dict["Geometry"]["OverallDomain"]["x"]["rescale"] = rescale + geom_dict["Geometry"]["OverallDomain"]["y"]["rescale"] = rescale + geom_dict["Geometry"]["OverallDomain"]["z"]["rescale"] = rescale + assert "Meshing" in geom_dict + assert "Geometry" in geom_dict + return geom_dict + + +if __name__ == "__main__": + bc_dict = {} + bc_dict["inlets"] = [] + bc_dict["outlets"] = [] + tmp_dict = {} + tmp_dict["type"] = "circle" + tmp_dict["centx"] = 5.0 + tmp_dict["centy"] = 0.0 + tmp_dict["centz"] = 0.5 + tmp_dict["radius"] = 0.4 + tmp_dict["normal_dir"] = 1 + tmp_dict["nelements"] = 50 + bc_dict["inlets"].append(tmp_dict) + tmp_dict = {} + tmp_dict["type"] = "circle" + tmp_dict["centx"] = 2.5 + tmp_dict["centy"] = 0.0 + tmp_dict["centz"] = 0.5 + tmp_dict["radius"] = 0.4 + tmp_dict["normal_dir"] = 1 + tmp_dict["nelements"] = 50 + bc_dict["inlets"].append(tmp_dict) + tmp_dict = {} + tmp_dict["type"] = "circle" + tmp_dict["centx"] = 7.5 + tmp_dict["centy"] = 0.0 + tmp_dict["centz"] = 0.5 + tmp_dict["radius"] = 0.4 + tmp_dict["normal_dir"] = 1 + tmp_dict["nelements"] = 50 + bc_dict["inlets"].append(tmp_dict) + + tmp_dict = {} + tmp_dict["type"] = "circle" + tmp_dict["centx"] = 0.5 + tmp_dict["centy"] = 5.0 + tmp_dict["centz"] = 0.5 + tmp_dict["radius"] = 0.4 + tmp_dict["normal_dir"] = 1 + tmp_dict["nelements"] = 50 + bc_dict["outlets"].append(tmp_dict) + tmp_dict = {} + tmp_dict["type"] = "circle" + tmp_dict["centx"] = 0.5 + tmp_dict["centy"] = 5.0 + tmp_dict["centz"] = 0.5 + tmp_dict["radius"] = 0.4 + tmp_dict["normal_dir"] = 1 + tmp_dict["nelements"] = 50 + bc_dict["outlets"].append(tmp_dict) + + generate_stl_patch("test.json", bc_dict) diff --git a/bird/preprocess/json_gen/generate_designs.py b/bird/preprocess/json_gen/generate_designs.py new file mode 100644 index 00000000..f6c9c265 --- /dev/null +++ b/bird/preprocess/json_gen/generate_designs.py @@ -0,0 +1,344 @@ +import os +import pickle +import shutil + +import numpy as np + +from bird import BIRD_CASE_DIR +from bird.preprocess.json_gen.design_io import * + + +def compare_config(config1, config2): + same = True + for key in config1: + if np.linalg.norm(config1[key] - config2[key]) > 1e-6: + same = False + return same + return same + + +def check_config(config): + success = False + inlet_exist = False + for key in config: + if len(np.argwhere(config[key] == 1)) > 0: + inlet_exist = True + break + if inlet_exist: + success = True + else: + success = False + return success + + +def save_config_dict(filename, config_dict): + with open(filename, "wb") as f: + pickle.dump(config_dict, f) + + +def load_config_dict(filename): + with open(filename, "rb") as f: + config_dict = pickle.load(f) + return config_dict + + +def write_script_start(filename, n): + with open(filename, "w+") as f: + for i in range(n): + f.write(f"cd Sim_{i}\n") + f.write(f"sbatch script\n") + f.write(f"cd ..\n") + + +def write_script_post(filename, n): + with open(filename, "w+") as f: + for i in range(n): + f.write(f"cd Sim_{i}\n") + f.write(f"sbatch script_post\n") + f.write(f"cd ..\n") + + +def write_prep(filename, n): + with open(filename, "w+") as f: + f.write("prep () {\n") + f.write(f"\tcd $1\n") + f.write(f"\treconstructPar -newTimes\n") + f.write(f"\tcd ..\n") + f.write("}\n") + f.write(f"\n") + f.write( + f"source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc\n" + ) + for i in range(n): + f.write(f"prep Sim_{i}\n") + + +def overwrite_vvm(case_folder, vvm): + list_dir = os.listdir(case_folder) + if not "constant" in list_dir: + sys.exit( + f"ERROR: {case_folder} is likely not a case folder, could not find constant/" + ) + else: + filename = os.path.join(case_folder, "constant", "globalVars_temp") + filename_write = os.path.join( + case_folder, "constant", "globalVars_temp2" + ) + with open(filename, "r+") as f: + lines = f.readlines() + with open(filename_write, "w+") as f: + for line in lines: + if line.startswith("VVM"): + f.write(f"VVM\t{vvm};\n") + else: + f.write(line) + shutil.copy( + os.path.join(case_folder, "constant", "globalVars_temp2"), + os.path.join(case_folder, "constant", "globalVars_temp"), + ) + os.remove(os.path.join(case_folder, "constant", "globalVars_temp2")) + + +def overwrite_bubble_size_model(case_folder, constantD=False): + list_dir = os.listdir(case_folder) + if not "constant" in list_dir: + sys.exit( + f"ERROR: {case_folder} is likely not a case folder, could not find constant/" + ) + else: + filename = os.path.join(case_folder, "presteps.sh") + filename_write = os.path.join(case_folder, "presteps2.sh") + with open(filename, "r+") as f: + lines = f.readlines() + with open(filename_write, "w+") as f: + for line in lines: + if line.startswith("cp constant/phaseProperties"): + if constantD: + f.write( + "cp constant/phaseProperties_constantd constant/phaseProperties\n" + ) + else: + f.write( + "cp constant/phaseProperties_pbe constant/phaseProperties\n" + ) + else: + f.write(line) + shutil.copy( + os.path.join(case_folder, "presteps2.sh"), + os.path.join(case_folder, "presteps.sh"), + ) + os.remove(os.path.join(case_folder, "presteps2.sh")) + + +def generate_small_reactor_cases( + config_dict, branchcom_spots, vvm, power, constantD, study_folder +): + templateFolder = "loop_reactor_pbe_dynmix_nonstat_headbranch" + + geom_dict = make_default_geom_dict_from_file( + f"{BIRD_CASE_DIR}/{templateFolder}/system/mesh.json", + rescale=0.05, + ) + try: + shutil.rmtree(study_folder) + except: + pass + os.makedirs(study_folder) + for simid in config_dict: + shutil.copytree( + f"{BIRD_CASE_DIR}/{templateFolder}", + f"{study_folder}/Sim_{simid}", + ) + bc_dict = {} + bc_dict["inlets"] = [] + bc_dict["outlets"] = [] + bc_dict["outlets"].append( + { + "branch_id": 6, + "type": "circle", + "frac_space": 1, + "normal_dir": 1, + "radius": 0.4, + "nelements": 50, + "block_pos": "top", + } + ) + bc_dict["outlets"].append( + { + "branch_id": 4, + "type": "circle", + "frac_space": 1, + "normal_dir": 1, + "radius": 0.4, + "nelements": 50, + "block_pos": "top", + } + ) + for branch in config_dict: + if branch in [0, 1, 2]: + ind = np.argwhere(config_dict[simid][branch] == 1) + if len(ind) > 0: + ind = list(ind[:, 0]) + for iind in ind: + bc_dict["inlets"].append( + { + "branch_id": branch, + "type": "circle", + "frac_space": branchcom_spots[branch][iind], + "normal_dir": 1, + "radius": 0.4, + "nelements": 50, + "block_pos": "bottom", + } + ) + generate_stl_patch( + os.path.join( + study_folder, f"Sim_{simid}", "system", "inlets_outlets.json" + ), + bc_dict, + geom_dict, + ) + + mix_list = [] + for branch in config_dict: + if branch in [0, 1, 2]: + ind = np.argwhere(config_dict[simid][branch] == 0) + if len(ind) > 0: + ind = list(ind[:, 0]) + for iind in ind: + if branch == 0: + sign = "+" + else: + sign = "-" + mix_list.append( + { + "branch_id": branch, + "frac_space": branchcom_spots[branch][iind], + "start_time": 1, + "power": power, + "sign": sign, + } + ) + generate_dynamic_mixer( + os.path.join( + study_folder, f"Sim_{simid}", "system", "mixers.json" + ), + mix_list, + geom_dict, + ) + overwrite_vvm( + case_folder=os.path.join(study_folder, f"Sim_{simid}"), vvm=vvm + ) + overwrite_bubble_size_model( + case_folder=os.path.join(study_folder, f"Sim_{simid}"), + constantD=constantD, + ) + + geom_dict = make_default_geom_dict_from_file( + f"{BIRD_CASE_DIR}/{templateFolder}/system/mesh.json", + rescale=0.05, + ) + + +def generate_scaledup_reactor_cases( + config_dict, branchcom_spots, vvm, power, constantD, study_folder +): + + templateFolder = "loop_reactor_pbe_dynmix_nonstat_headbranch_scaleup" + geom_dict = make_default_geom_dict_from_file( + f"{BIRD_CASE_DIR}/{templateFolder}/system/mesh.json" + ) + try: + shutil.rmtree(study_folder) + except: + pass + os.makedirs(study_folder) + for simid in config_dict: + shutil.copytree( + f"{BIRD_CASE_DIR}/{templateFolder}", + f"{study_folder}/Sim_{simid}", + ) + bc_dict = {} + bc_dict["inlets"] = [] + bc_dict["outlets"] = [] + bc_dict["outlets"].append( + { + "branch_id": 6, + "type": "circle", + "frac_space": 1, + "normal_dir": 1, + "radius": 0.4, + "nelements": 50, + "block_pos": "top", + } + ) + bc_dict["outlets"].append( + { + "branch_id": 4, + "type": "circle", + "frac_space": 1, + "normal_dir": 1, + "radius": 0.4, + "nelements": 50, + "block_pos": "top", + } + ) + for branch in config_dict: + if branch in [0, 1, 2]: + ind = np.argwhere(config_dict[simid][branch] == 1) + if len(ind) > 0: + ind = list(ind[:, 0]) + for iind in ind: + bc_dict["inlets"].append( + { + "branch_id": branch, + "type": "circle", + "frac_space": branchcom_spots[branch][iind], + "normal_dir": 1, + "radius": 0.4, + "nelements": 50, + "block_pos": "bottom", + } + ) + generate_stl_patch( + os.path.join( + study_folder, f"Sim_{simid}", "system", "inlets_outlets.json" + ), + bc_dict, + geom_dict, + ) + + mix_list = [] + for branch in config_dict: + if branch in [0, 1, 2]: + ind = np.argwhere(config_dict[simid][branch] == 0) + if len(ind) > 0: + ind = list(ind[:, 0]) + for iind in ind: + if branch == 0: + sign = "+" + else: + sign = "-" + mix_list.append( + { + "branch_id": branch, + "frac_space": branchcom_spots[branch][iind], + "start_time": 3, + "power": power, + "sign": sign, + } + ) + generate_dynamic_mixer( + os.path.join( + study_folder, f"Sim_{simid}", "system", "mixers.json" + ), + mix_list, + geom_dict, + ) + overwrite_vvm( + case_folder=os.path.join(study_folder, f"Sim_{simid}"), vvm=vvm + ) + overwrite_bubble_size_model( + case_folder=os.path.join(study_folder, f"Sim_{simid}"), + constantD=constantD, + ) diff --git a/bird/preprocess/stl_patch/stl_bc.py b/bird/preprocess/stl_patch/stl_bc.py index 29a96c4c..032f5316 100644 --- a/bird/preprocess/stl_patch/stl_bc.py +++ b/bird/preprocess/stl_patch/stl_bc.py @@ -12,7 +12,7 @@ def check_input(input_dict): assert isinstance(input_dict, dict) need_geom = False for bound in input_dict: - if not bound == "Geometry": + if not bound == "Geometry" and not bound == "Meshing": assert isinstance(input_dict[bound], list) for patch in input_dict[bound]: assert isinstance(patch, dict) @@ -41,7 +41,7 @@ def write_boundaries(input_dict): check_input(input_dict) for boundary_name in input_dict.keys(): if not boundary_name == "Geometry": - print(f"Making {boundary_name}") + print(f"\nMaking {boundary_name}") boundary_mesh = get_all_vert_faces(input_dict, boundary_name) print(f"\tArea {boundary_mesh.area} m2") boundary_mesh.save(f"{boundary_name}.stl") diff --git a/bird/preprocess/stl_patch/stl_shapes.py b/bird/preprocess/stl_patch/stl_shapes.py index e9cc1fec..bb5a9ab6 100644 --- a/bird/preprocess/stl_patch/stl_shapes.py +++ b/bird/preprocess/stl_patch/stl_shapes.py @@ -9,7 +9,7 @@ def make_polygon(rad, nvert, center, normal_dir): print( - f"\tMaking polygon at ({center[0]:.4g}, {center[1]:.4g}, {center[2]:.4g})" + f"\tMaking polygon at ({center[0]:.4g}, {center[1]:.4g}, {center[2]:.4g})m" ) theta = 2 * np.pi / nvert vertices = np.zeros((nvert, 3)) @@ -27,7 +27,7 @@ def make_polygon(rad, nvert, center, normal_dir): def make_rectangle(w, h, center, normal_dir): print( - f"\tMaking rectangle at ({center[0]:.4g}, {center[1]:.4g}, {center[2]:.4g})" + f"\tMaking rectangle at ({center[0]:.4g}, {center[1]:.4g}, {center[2]:.4g})m" ) # Define vertices t1dir = (normal_dir + 1) % 3 @@ -50,7 +50,7 @@ def make_rectangle(w, h, center, normal_dir): def make_circle(radius, center, normal_dir, npts=3): print( - f"\tMaking circle at ({center[0]:.4g}, {center[1]:.4g}, {center[2]:.4g})" + f"\tMaking circle at ({center[0]:.4g}, {center[1]:.4g}, {center[2]:.4g})m" ) vertices = np.zeros((npts + 1, 3)) t1dir = (normal_dir + 1) % 3 diff --git a/bird/utilities/ofio.py b/bird/utilities/ofio.py index 6a0877b4..8f9d8f41 100644 --- a/bird/utilities/ofio.py +++ b/bird/utilities/ofio.py @@ -127,13 +127,16 @@ def readSizeGroups(file): return sizeGroup, binGroup -def getCaseTimes(casePath): +def getCaseTimes(casePath, remove_zero=False): # Read Time times_tmp = os.listdir(casePath) # remove non floats for i, entry in reversed(list(enumerate(times_tmp))): try: a = float(entry) + if remove_zero: + if abs(a) < 1e-12: + _ = times_tmp.pop(i) except ValueError: a = times_tmp.pop(i) # print('removed ', a) diff --git a/bird/version.py b/bird/version.py index 2ed1d089..4b814da6 100644 --- a/bird/version.py +++ b/bird/version.py @@ -1,3 +1,3 @@ """Bio reactor design version""" -__version__ = "0.0.14" +__version__ = "0.0.15" diff --git a/papers/tutorial/calibration/README.md b/papers/tutorial/calibration/README.md deleted file mode 100644 index ab186d5f..00000000 --- a/papers/tutorial/calibration/README.md +++ /dev/null @@ -1,80 +0,0 @@ -# Calibration tutorial - -This tutorial demonstrates how to conduct the calibration with and without a surrogate forward model - -## Running the tutorial -We assume that bird is installed within an environment called `bird` (see installation instruction at the root of the repo) -You will need to install additional dependencies -``` -conda activate bird -cd ${BIRD_DIR}/../papers/tutorial/calibration -pip install -r requirememts.txt -``` -Note that `${BIRD_DIR}` is not an environment variable, and should be replaced by the path to the root of the repo. - -## Calibration Objective - -The PDF of a Beta(alpha,beta) distribution is observed. -Within the context of bioreactors, one can consider this PDF to be a measured bubble size distribution (BSD) - -A separate dummy numerical model is available and predicts BSD as normal distributions N(mu, sigma). The input parameter of the numerical models are mu and sigma. The objective of the modeler is to find mu and sigma such that the predicted BSD matches the observed BSD - -We assume that the numerical model is expensive and instead of using the expensive numerical model for the forward model used in the calibration, one would like to use a cheaper surrogate model. Here the surrogate model is a neural network. - - -## Building the surrogate - -The class `Param_NN` available in BiRD allows to create a parametric surrogate. Here, the input of the surrogate are the parameters `mu` and `sigma`, and the variable `x` that parameterize the PDF. - -Constructing such a surrogate is not computationally useful here since the forward simulation is cheap. This is only for illustrative purposes! - -Generate dataset and train neural net surrogate with `python tut_surrogate.py`. -The following plots should be generated. The first one shows the training and testing loss convergence. The second one shows examples of the surrogate accuracy on unseen data. - -

- - -

- - -## Calibration - -For the calibration, we can use the true function or the surrogate model. The objective PDF is assumed to be noiseless. Even though the observation is noiseless, an uncertainty is computed to account for the missing physics. - -Calibrate without a surrogate for `alpha=5, beta=5`: `python tut_calibration_all.py --alpha 5 --beta 5` - -

- - -

- - -Calibrate without a surrogate for `alpha=2, beta=5`: `python tut_calibration_all.py --alpha 2 --beta 5` - - -

- - -

- -Clearly, the amount of missing physics vary depending on the observations. - -Then the same exercise can be done when using a neural net surrogate. Note that this step will not run if the `Building the surrogate` step was not done first - -Calibrate with a surrogate for `alpha=5, beta=5`: `python tut_calibration_all.py --useNN --alpha 5 --beta 5` - -

- - -

- - -Calibrate with a surrogate for `alpha=2, beta=5`: `python tut_calibration_all.py --useNN --alpha 2 --beta 5` - - -

- - -

- -Using surrogate gives similar predictions as when not using a surrogate. But the surrogate was constructed with 200 forward simulations. diff --git a/papers/tutorial/calibration/assets/Loss_surr.png b/papers/tutorial/calibration/assets/Loss_surr.png deleted file mode 100644 index cee6cf5f..00000000 Binary files a/papers/tutorial/calibration/assets/Loss_surr.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/Surr_a_2_b_5_corner.png b/papers/tutorial/calibration/assets/Surr_a_2_b_5_corner.png deleted file mode 100644 index 3f0373cc..00000000 Binary files a/papers/tutorial/calibration/assets/Surr_a_2_b_5_corner.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/Surr_a_2_b_5_prop.png b/papers/tutorial/calibration/assets/Surr_a_2_b_5_prop.png deleted file mode 100644 index 177bef84..00000000 Binary files a/papers/tutorial/calibration/assets/Surr_a_2_b_5_prop.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/Surr_a_5_b_5_corner.png b/papers/tutorial/calibration/assets/Surr_a_5_b_5_corner.png deleted file mode 100644 index 8a5aab20..00000000 Binary files a/papers/tutorial/calibration/assets/Surr_a_5_b_5_corner.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/Surr_a_5_b_5_prop.png b/papers/tutorial/calibration/assets/Surr_a_5_b_5_prop.png deleted file mode 100644 index 7a84104d..00000000 Binary files a/papers/tutorial/calibration/assets/Surr_a_5_b_5_prop.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/True_a_2_b_5_corner.png b/papers/tutorial/calibration/assets/True_a_2_b_5_corner.png deleted file mode 100644 index 9aaf36d1..00000000 Binary files a/papers/tutorial/calibration/assets/True_a_2_b_5_corner.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/True_a_2_b_5_prop.png b/papers/tutorial/calibration/assets/True_a_2_b_5_prop.png deleted file mode 100644 index f15de0ce..00000000 Binary files a/papers/tutorial/calibration/assets/True_a_2_b_5_prop.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/True_a_5_b_5_corner.png b/papers/tutorial/calibration/assets/True_a_5_b_5_corner.png deleted file mode 100644 index 5c210c7d..00000000 Binary files a/papers/tutorial/calibration/assets/True_a_5_b_5_corner.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/True_a_5_b_5_prop.png b/papers/tutorial/calibration/assets/True_a_5_b_5_prop.png deleted file mode 100644 index a3c55690..00000000 Binary files a/papers/tutorial/calibration/assets/True_a_5_b_5_prop.png and /dev/null differ diff --git a/papers/tutorial/calibration/assets/test_surr.png b/papers/tutorial/calibration/assets/test_surr.png deleted file mode 100644 index 6717a6e4..00000000 Binary files a/papers/tutorial/calibration/assets/test_surr.png and /dev/null differ diff --git a/papers/tutorial/calibration/post_cal.py b/papers/tutorial/calibration/post_cal.py deleted file mode 100644 index 3eafd981..00000000 --- a/papers/tutorial/calibration/post_cal.py +++ /dev/null @@ -1,102 +0,0 @@ -import corner -import jax.numpy as jnp -from prettyPlot.plotting import * - - -def post_process_cal( - labels_np, - labels, - np_mcmc_samples, - rangex, - forward_range, - data_x, - data_y, - sigma, -): - # Post process - ranges = [] - ranges.append((0.01, 0.9)) - ranges.append((0.01, 0.9)) - truths = None - - labels_np_disp = labels_np.copy() - ind_mu = labels_np_disp.index("mu_d") - labels_np_disp[ind_mu] = r"$\mu$" - ind_sigma = labels_np_disp.index("sigma_d") - labels_np_disp[ind_sigma] = r"$\sigma$" - fig = corner.corner( - np_mcmc_samples, - truths=truths, - labels=labels_np_disp, - truth_color="k", - bins=50, - range=ranges, - ) - for ax in fig.get_axes(): - ax.tick_params( - axis="both", labelsize=20 - ) # Customize font size, line width, and tick length - ax.xaxis.label.set_fontweight("bold") # Set the X-axis label to bold - ax.yaxis.label.set_fontweight("bold") # Set the Y-axis label to bold - ax.xaxis.label.set_font( - "Times New Roman" - ) # Set the X-axis label to bold - ax.yaxis.label.set_font( - "Times New Roman" - ) # Set the Y-axis label to bold - ax.xaxis.label.set_fontsize(20) # Set the X-axis label to bold - ax.yaxis.label.set_fontsize(20) # Set the Y-axis label to bold - for tick in ax.get_xticklabels() + ax.get_yticklabels(): - tick.set_fontname("Times New Roman") - tick.set_fontweight("bold") - for ax in fig.get_axes(): - ax.set_xlabel(ax.get_xlabel(), fontweight="bold") - ax.set_ylabel(ax.get_ylabel(), fontweight="bold") - - # Convergence - fig, axes = plt.subplots(2, sharex=True) - for i in range(2): - ax = axes[i] - ax.plot(np_mcmc_samples[:, i], "k", alpha=0.3, rasterized=True) - ax.set_ylabel(labels[i]) - - nsamples = np_mcmc_samples.shape[0] - print("Num samples = ", nsamples) - realization = [] - for i in range(nsamples): - y = forward_range(np_mcmc_samples[i, :].astype("float32")) - realization.append(y) - realization = np.array(realization) - - mean_real = np.mean(realization, axis=0) - min_real = np.min(realization, axis=0) - max_real = np.max(realization, axis=0) - std97_5_real = np.percentile(realization, 97.5, axis=0) - std2_5_real = np.percentile(realization, 2.5, axis=0) - - fig = plt.figure() - plt.plot(data_x, data_y, "o", color="r", markersize=7, label="Data") - plt.plot(data_x, data_y - 2 * sigma, "--", color="r") - plt.plot( - data_x, - data_y + 2 * sigma, - "--", - color="r", - label="95% Exp. confidence interval", - ) - - plt.plot( - rangex, mean_real, color="k", linewidth=3, label="mean degradation" - ) - plt.plot( - rangex, - std97_5_real, - "--", - color="k", - linewidth=3, - label="95% Model confidence interval", - ) - plt.plot(rangex, std2_5_real, "--", color="k", linewidth=3) - pretty_labels("", "", 20, title=f"Missing phys. unc. = {sigma:.2g}") - - plt.show() diff --git a/papers/tutorial/calibration/requirements.txt b/papers/tutorial/calibration/requirements.txt deleted file mode 100644 index 833923e5..00000000 --- a/papers/tutorial/calibration/requirements.txt +++ /dev/null @@ -1,4 +0,0 @@ -joblib -tensorflow -scikit-learn -tf2jax diff --git a/papers/tutorial/calibration/tut_calibration_all.py b/papers/tutorial/calibration/tut_calibration_all.py deleted file mode 100644 index de39f60f..00000000 --- a/papers/tutorial/calibration/tut_calibration_all.py +++ /dev/null @@ -1,267 +0,0 @@ -import argparse -import json -import os -import sys - -import corner -import jax -import jax.numpy as jnp -import jax.random as random -import joblib -import keras -import numpy as np -import numpyro -import numpyro.distributions as dist -import tensorflow as tf -import tf2jax -from keras import layers -from numpyro.infer import MCMC, NUTS -from post_cal import post_process_cal -from prettyPlot.plotting import * - -from bird.calibration.param_nn import Param_NN -from bird.calibration.scaling import * - -parser = argparse.ArgumentParser(description="Calibration Interface") -parser.add_argument( - "-useNN", - "--useNN", - action="store_true", - help="Use neural net surrogate", -) -parser.add_argument( - "-alpha", - "--alpha", - type=float, - metavar="", - required=False, - help="alpha parameter in the beta distributio", - default=5, -) -parser.add_argument( - "-beta", - "--beta", - type=float, - metavar="", - required=False, - help="beta parameter in the beta distributio", - default=5, -) - -args, unknown = parser.parse_known_args() - - -def observation_data(alpha=2, beta=5): - from scipy.special import factorial, gamma - - x = np.random.uniform(1e-6, 1 - 1e-6, 128) - x = x[np.argsort(x)] - B = gamma(alpha) * gamma(beta) / gamma(alpha + beta) - y = x ** (alpha - 1) * (1 - x) ** (beta - 1) / B - return x, y - - -data_x, data_y = observation_data(alpha=args.alpha, beta=args.beta) -rangex = np.reshape( - np.linspace(np.amin(data_x), np.amax(data_x), 250), (250, 1) -) -if args.useNN: - print("INFO: Using NN surrogate") - x = np.reshape(data_x, (data_x.shape[0], 1)) - x_tens = tf.convert_to_tensor(x, dtype=tf.dtypes.float32) - ones_tf32 = tf.ones(tf.shape(x_tens[:, 0]), dtype=tf.dtypes.float32) - nn_kwargs = { - "input_dim": 3, - "output_dim": 1, - "units": [10, 10, 10, 5], - "activation": "tanh", - "final_activation": "elu", - "model_folder": "Modeltmp", - } - nn = Param_NN( - **nn_kwargs, weight_file=os.path.join("Modeltmp", "best.weights.h5") - ) - scale_x_min = joblib.load( - os.path.join(nn.model_folder, "scaler_z.mod") - ).data_min_ - scale_x_max = joblib.load( - os.path.join(nn.model_folder, "scaler_z.mod") - ).data_max_ - scale_par_min = joblib.load( - os.path.join(nn.model_folder, "scaler_par.mod") - ).data_min_ - scale_par_max = joblib.load( - os.path.join(nn.model_folder, "scaler_par.mod") - ).data_max_ - scale_y_mean = joblib.load( - os.path.join(nn.model_folder, "scaler_y.mod") - ).mean_ - scale_y_scale = joblib.load( - os.path.join(nn.model_folder, "scaler_y.mod") - ).scale_ - - @tf.function - def forwardNN(p): - par_tens = tf.stack([p[i] * ones_tf32 for i in range(len(p))], axis=1) - par_tens_resc = scale_par(par_tens, scale_par_min, scale_par_max) - x_tens_resc = scale_x(x_tens, scale_x_min, scale_x_max) - out_resc = nn.model([x_tens_resc, par_tens_resc]) - out = unscale_y(out_resc, scale_y_mean, scale_y_scale) - return out[:, 0] - - p = np.random.normal(size=(2,)).astype(np.float32) - jax_func, jax_params = tf2jax.convert(forwardNN, np.zeros_like(p)) - - def forward(p): - return jax_func(jax_params, p)[0] - - # Uncertainty propagation - rangex_tens = tf.convert_to_tensor(rangex, dtype=tf.dtypes.float32) - rangeones_tf32 = tf.ones(tf.shape(rangex[:, 0]), dtype=tf.dtypes.float32) - - @tf.function - def forward_range(p): - par = tf.stack([p[i] * rangeones_tf32 for i in range(len(p))], axis=1) - par = scale_par(par, scale_par_min, scale_par_max) - rangex_tens_resc = scale_x(rangex_tens, scale_x_min, scale_x_max) - out = nn.model([rangex_tens_resc, par]) - out = unscale_y(out, scale_y_mean, scale_y_scale) - return out[:, 0] - -else: - print("INFO: Using true function") - - def forward(p): - return (1 / jnp.sqrt(2 * jnp.pi * p[1] ** 2)) * jnp.exp( - -((jnp.array(data_x) - p[0]) ** 2) / (2 * p[1] ** 2) - ) - - def forward_range(p): - return (1 / jnp.sqrt(2 * jnp.pi * p[1] ** 2)) * jnp.exp( - -((jnp.array(rangex) - p[0]) ** 2) / (2 * p[1] ** 2) - ) - - -def bayes_step(y=None, y_err=0.1): - mu_d = numpyro.sample("mu_d", dist.Uniform(0.01, 0.9)) - sigma_d = numpyro.sample("sigma_d", dist.Uniform(0.01, 0.9)) - y_model = forward(jnp.array([mu_d, sigma_d])) - std_obs = jnp.ones(y_model.shape[0]) * y_err - numpyro.sample("obs", dist.Normal(y_model, std_obs), obs=y) - - -def mcmc_iter(y_err=0.1, mcmc_method="HMC"): - rng_key = random.PRNGKey(0) - rng_key, rng_key_ = random.split(rng_key) - # Guess - theta = [] - theta.append(np.random.uniform(0.01, 0.9)) - theta.append(np.random.uniform(0.01, 0.9)) - - # Hamiltonian Monte Carlo (HMC) with no u turn sampling (NUTS) - if mcmc_method.lower() == "hmc": - kernel = NUTS(bayes_step, target_accept_prob=0.9) - elif mcmc_method.lower() == "sa": - kernel = SA(bayes_step) - else: - sys.exit(f"MCMC method {mcmc_method} unrecognized") - num_warmup = 1000 - num_samples = 1500 - mcmc = MCMC( - kernel, - num_chains=1, - num_warmup=num_warmup, - num_samples=num_samples, - jit_model_args=True, - ) - mcmc.run(rng_key_, y=data_y, y_err=y_err) - mcmc.print_summary() - - # Draw samples - mcmc_samples = mcmc.get_samples() - labels = list(mcmc_samples.keys()) - nsamples = len(mcmc_samples[labels[0]]) - nparams = len(labels) - np_mcmc_samples = np.zeros((nsamples, nparams)) - labels_np = ["mu_d", "sigma_d"] - for ilabel, label in enumerate(labels): - for ipar, name in enumerate(["mu_d", "sigma_d"]): - if label == name: - nplabel = labels_np.index(name) - np_mcmc_samples[:, nplabel] = np.array(mcmc_samples[label]) - - # Uncertainty propagation - nsamples = np_mcmc_samples.shape[0] - realization = [] - for i in range(nsamples): - y = forward( - jnp.array( - [ - np_mcmc_samples[i, 0].astype("float32"), - np_mcmc_samples[i, 1].astype("float32"), - ] - ) - ) - realization.append(y) - realization = np.array(realization) - - min_real = np.percentile(realization, 2.5, axis=0) - max_real = np.percentile(realization, 97.5, axis=0) - - results = { - "samples": np_mcmc_samples, - "labels_np": labels_np, - "labels": labels, - } - - true_m95 = data_y - 2 * y_err - true_p95 = data_y + 2 * y_err - - if np.amax(true_m95 - min_real) > 0 or np.amin(true_p95 - max_real) < 0: - print( - f" Increase STD {np.amax(true_m95 - min_real)} - {np.amin(true_p95 - max_real)}" - ) - return False, results - else: - return True, results - - -min_sigma = 1e-4 -max_sigma = 1 -guess_sigma = 0.07 -sigma = guess_sigma - -for iteration_sigma in range(10): - print(f"Doing sigma = {sigma:.3g}") - reduce_sigma, results = mcmc_iter(y_err=sigma, mcmc_method="hmc") - if reduce_sigma: - max_sigma = sigma - sigma = sigma - (sigma - min_sigma) / 2 - else: - min_sigma = sigma - sigma = sigma + (max_sigma - sigma) / 2 - -if not reduce_sigma: - reduce_sigma, results = mcmc_iter(y_err=max_sigma, mcmc_method="hmc") - -np_mcmc_samples = results["samples"] -labels_np = results["labels_np"] -labels = results["labels"] -nparams = len(labels) -np.savez( - os.path.join("samp.npz"), - samples=np_mcmc_samples, - labels_np=labels_np, - labels=labels, -) - -post_process_cal( - labels_np, - labels, - np_mcmc_samples, - rangex, - forward_range, - data_x, - data_y, - sigma, -) diff --git a/papers/tutorial/calibration/tut_surrogate.py b/papers/tutorial/calibration/tut_surrogate.py deleted file mode 100644 index 54dd6d3d..00000000 --- a/papers/tutorial/calibration/tut_surrogate.py +++ /dev/null @@ -1,138 +0,0 @@ -import os - -import numpy as np -import tensorflow as tf -from prettyPlot.plotting import * - -from bird.calibration.param_nn import Param_NN - - -def simulation(mu, sigma, x): - return (1 / np.sqrt(2 * np.pi * sigma**2)) * np.exp( - -((x - mu) ** 2) / (2 * sigma**2) - ) - - -def concat_np_dat(x, mu, sigma): - assert len(mu.shape) == 1 - assert mu.shape == sigma.shape - assert len(x.shape) == 1 - n_dat_var = len(x) - n_sim = len(mu) - x_ind = 0 - mu_ind = 1 - sigma_ind = 2 - n_data = n_sim * n_dat_var - dim = 3 - dataset_x = np.zeros((n_data, dim)) - dataset_y = np.zeros((n_data,)) - for i_sim in range(n_sim): - beg = i_sim * n_dat_var - end = (i_sim + 1) * n_dat_var - dataset_x[beg:end, x_ind] = x - dataset_x[beg:end, mu_ind] = mu[i_sim] - dataset_x[beg:end, sigma_ind] = sigma[i_sim] - dataset_y[beg:end] = simulation(mu[i_sim], sigma[i_sim], x) - - return dataset_x, dataset_y - - -def make_dataset(n_sim, n_dat_var=32): - parameter_names = ["mu", "sigma"] - variable_names = ["x"] - - input_names = variable_names + parameter_names - - dim = len(input_names) - dim_var = len(variable_names) - dim_par = len(parameter_names) - - mu = np.random.uniform(0.01, 0.9, n_sim) - sigma = np.random.uniform(0.01, 0.9, n_sim) - x = np.linspace(1e-6, 1 - 1e-6, n_dat_var) - - return concat_np_dat(x, mu, sigma) - - -def plot_loss(loss_dict): - fig = plt.figure() - plt.plot( - loss_dict["epoch"], - loss_dict["train_loss"], - color="k", - linewidth=3, - label="train", - ) - plt.plot( - loss_dict["epoch"], - loss_dict["val_loss"], - color="b", - linewidth=3, - label="test", - ) - pretty_labels("Epoch", "Loss", 16) - pretty_legend() - ax = plt.gca() - ax.set_yscale("log") - plt.tight_layout() - - -def plot_test(nn, n_sim_test=5): - # test - mu = np.random.uniform(0.01, 0.9, n_sim_test) - sigma = np.random.uniform(0.01, 0.9, n_sim_test) - n_dat_var = 64 - x = np.linspace(1e-6, 1 - 1e-6, n_dat_var) - - data_test_x, data_test_y = concat_np_dat(x, mu, sigma) - y_pred = nn.pred(data_test_x[:, 0], data_test_x[:, 1:]) - - fig, axs = plt.subplots(1, n_sim_test, figsize=(4 * n_sim_test, 4)) - for i_sim_test in range(n_sim_test): - beg = i_sim_test * n_dat_var - end = (i_sim_test + 1) * n_dat_var - axs[i_sim_test].plot(x, data_test_y[beg:end], label="true") - axs[i_sim_test].plot(x, y_pred[beg:end], label="pred") - pretty_labels( - "", - "", - 16, - ax=axs[i_sim_test], - title=rf"$\mu = {mu[i_sim_test]:.2f}$ $\sigma = {sigma[i_sim_test]:.2f}$", - grid=False, - ) - if i_sim_test == n_sim_test - 1: - pretty_legend(ax=axs[i_sim_test]) - - -if __name__ == "__main__": - n_par = 2 - n_var = 1 - np.random.seed(0) - tf.random.set_seed(0) - x, y = make_dataset(200, 64) - np.savez("data_raw.npz", x=x.astype("float32"), y=y.astype("float32")) - - nn = Param_NN( - input_dim=n_var + n_par, - output_dim=1, - units=[10, 10, 10, 5], - activation="tanh", - final_activation="elu", - model_folder="Modeltmp", - log_loss_folder="Logtmp", - ) - - nn.train( - learningRateModel=1e-3, - batch_size=128, - nEpochs=2000, - data_file="data_raw.npz", - ) - - # Plot loss - plot_loss(nn.get_loss_dat()) - - # Plot test - plot_test(nn, n_sim_test=5) - plt.show() diff --git a/setup.py b/setup.py index 28cdc688..877ee8a1 100644 --- a/setup.py +++ b/setup.py @@ -39,6 +39,7 @@ "*.yaml", "*.csv", "data_conditional_mean", + "data_preprocess", ] }, include_package_data=True, diff --git a/tests/postprocess/test_cond_mean.py b/tests/postprocess/test_cond_mean.py index c453b99a..2367367d 100644 --- a/tests/postprocess/test_cond_mean.py +++ b/tests/postprocess/test_cond_mean.py @@ -2,6 +2,7 @@ from prettyPlot.plotting import plt, pretty_labels +from bird import BIRD_POST_DIR from bird.postprocess.conditional_mean import ( compute_cond_mean, save_cond, @@ -10,7 +11,12 @@ def test_compute_cond(): - caseFolder = os.path.join("bird", "postprocess", "data_conditional_mean") + if os.path.exists(os.path.join(BIRD_POST_DIR, "data_conditional_mean")): + caseFolder = os.path.join(BIRD_POST_DIR, "data_conditional_mean") + else: + caseFolder = os.path.join( + "bird", "postprocess", "data_conditional_mean" + ) fields_list = [ "CO.gas", "CO.liquid", diff --git a/tests/preprocess/test_generate_case.py b/tests/preprocess/test_generate_case.py new file mode 100644 index 00000000..d0e2536e --- /dev/null +++ b/tests/preprocess/test_generate_case.py @@ -0,0 +1,22 @@ +import os + +import pytest + +from bird import BIRD_PRE_DATA_DIR +from bird.preprocess.json_gen.generate_designs import ( + convert_case_dim, + replace_str_in_file, +) + + +@pytest.mark.parametrize( + "dim_factor", + [2, 4, 8], +) +def test_scale_dim(dim_factor): + input_folder = os.path.join(BIRD_PRE_DATA_DIR, "loop_reactor_3_6L") + convert_case_dim(input_folder, "dummy_loop", dim_factor) + + +if __name__ == "__main__": + test_scale_dim(2)