Appendix E The Source Code
Transcription
Appendix E The Source Code
Appendix E The Source Code Variables that are computed by a sub-function in the UDF can be stored in memory so that the values can be either retrieved from another sub-function or from within F LU ENT for postprocessing. The specific user-defined memory location is accessed using the “C_UDMI” macro for a cell variable or the “F_UDMI” macro for a face variable. In the source code listed below, the memory cells are allocated as follows: UDMI index Variable in the UDF Symbol used in this thesis 0 hea_mix mix 1 xi_vape sat,w 2 3 4 5 6 7 8 9 10 S_vap d_par difko_par xi_solute_par psi_solute_par dm_par rho_par source flow_wall_c r p p s s Definition Heat conductivity of the vapour-carrier gas mixture Saturation or equilibrium water vapour pressure Saturation ratio in the tube Particle / droplet diameter Particle diffusion coefficient Solute mass fraction in the droplet Solute mole fraction in the droplet Single particle growth law Density of the solution droplet Latent heat source at tube wall Vapour mass flux towards the wall for one cell p, sol h, wall v 85 86 The Source Code UDMI index Variable in the UDF Symbol used in this thesis Definition 11 d_par – 12 S_par 13 14 15 m_par d_par_eq d_par_eq Control variable used in the calculation of the equilibrium diameter Saturation ratio at the particle / droplet surface Mass of the particle / droplet Left equilibrium diameter Right equilibrium diameter p – p,eq,left p,eq,right User-defined scalars can be accessed in the UDF using the “C_UDSI” or “F_UDSI” macros. Their allocation is UDSI index Definition 0 Particle / droplet number concentration per kilogram of the vapourcarrier gas mixture Mass of NaCl per kilogram of the vapour-carrier gas mixture Mass of liquid water per kilogram of the vapour-carrier gas mixture 1 2 The source code listed in this appendix has been used for the calculations assuming that the droplet consists of an ideal solution throughout the calculation domain. real real real real zerocelsius=273.15; gasconst=8.3144087; pi=3.14159265; TINY = 1.e-30; real molefraction2massfraction(real psi_a, real amolm_a, real amolm_b) { real xi_a; } psi_a=xi_a / amolm_a /(xi_a/amolm_a + (1.0-xi_a)/amolm_b); return psi_a; /****** Functions *************************************************/ real massfraction2molefraction(real xi_a, real amolm_a, real amolm_b) { real psi_a; /**************************************************************/ /* !!! only for discretisation scheme power law !!! */ #define FPM_CONV_DIFF_COEFFS(flox,diff,flux_01,flux_10)\ {\ if (diff>0)\ {\ real d = 1.0 - 0.1 * ABS(flox) / diff;\ d = (d<0.) ? 0. : pow (d,5.) * diff;\ flux_01 = flux_10 = d;\ }\ else\ {\ flux_01 = flux_10 = diff;\ }\ if ((flox) > 0)\ flux_10 += (flox);\ else\ flux_01 -= (flox);\ } /****** Macros *****************************************************/ #define ABSOLUTE_STATIC_PRESSURE(c,t) ((C_P(c,t))+op_pres) /* --------------------------------------------------------------- */ /* Surface ID's, available from Fluent's boundary conditions panel */ /* --------------------------------------------------------------- */ /* für Gitter aus wolkam_neu.msh mit Wand (L = 1.5m): */ #define I_WALL_ID 14 #define I_WALL_SHADOW_ID 8 #define SOLID_WALL_ID 19 #define AXIS_ID 9 #define INLET1_ID 11 /* Aerosol at tube centre */ static real N_min=1.0; static int udmi_set=0; static int uds_particle=1; static real p_0=101325; static static static static #include "udf.h" #include <math.h> #include "sg.h" molality = psi_salt / (amolm_h2o * (1-psi_salt)); return molality; molality = xi_salt / (amolm_sol * (1. - xi_salt)); return molality; mol_vel_kin = sqrt(8.0*gasconst*C_T(c,t)/(pi*M)); return mol_vel_kin; lat_heat = 2.501e6*pow(zerocelsius/T, 0.167+3.67e-4*T); return lat_heat; real heat_of_vaporization_f(face_t f, Thread *t) { } real heat_of_vaporization(cell_t c, Thread *t) { real T = C_T(c,t); real lat_heat; } mfp_air = mfp_air_0 * (C_T(c,t) / mfp_air_T0) * (p_0 / ABSOLUTE_STATIC_PRESSURE(c,t)) * (1.0 + 110.4 / mfp_air_T0) / (1.0 + 110.4 / C_T(c,t) ); return mfp_air; real mean_free_path_gas(cell_t c, Thread *t) { real mfp_air_T0 = 296.15; real mfp_air_0 = 67.3e-9; real mfp_air; } /* Properties */ real molec_velocity_kinetic(real M, cell_t c, Thread *t) { real mol_vel_kin; } real molality; real massfraction2molality(real xi_salt, real amolm_sol) { /* xi_salt = xi_sol_par */ /* amolm_sol = amolm_solute (mol / kg) */ } real molality; real molefraction2molality(real psi_salt, real amolm_h2o) { /* psi_salt = psi_solute_par */ /* amolm_h2o = amolm_vap */ } xi_a=psi_a * amolm_a /(psi_a * amolm_a + (1.0-psi_a) * amolm_b); return xi_a; 87 return hea_mix; return difko_vap; s1 = 10.79574 * (1.0 - zerocelsius / C_T(c,t)); s2 = -5.028 * log10( C_T(c,t) / zerocelsius); s3 = 1.50475e-4*(1. - pow(10.0,-8.2969*(C_T(c,t)/zerocelsius - 1.0 ))); real saturation_vapor_pressure(cell_t c, Thread *t) { real s1,s2,s3,s4; real p_vape; } mfp_vapor = 32.0/(3.0*pi) * (diffusion_coefficient_vapor(c,t) / molec_velocity_kinetic(molmass_vap,c,t)) * molmass_gas / (molmass_gas + molmass_vap); return mfp_vapor; /* Vapor properties */ real mean_free_path_vapour(real molmass_gas, real molmass_vap, cell_t c, Thread *t) { real mfp_vapor; } difko_vap=0.211e-4*pow(C_T(c,t)/zerocelsius,1.94) *(p_0 / ABSOLUTE_STATIC_PRESSURE(c,t) ); real diffusion_coefficient_vapor(cell_t c, Thread *t) { real difko_vap; } hea_gas=4.1868e-3*(5.69+0.017*(C_T(c,t)-zerocelsius)); hea_vap=4.1868e-3*(3.78+0.020*(C_T(c,t)-zerocelsius)); hea_mix=hea_gas*(1.0-(1.17-1.02*hea_vap/hea_gas)*psi_vap); real heat_conductivity_mixture(real psi_vap, cell_t c, Thread *t) { real hea_gas; real hea_vap; real hea_mix; } amolm_mix=xi_vap/amolm_vap+(1.0-xi_vap)/amolm_gas; amolm_mix=pow(amolm_mix,-1.0); return amolm_mix; kn_par=2.0*mfp_i/d_par; return kn_par; cslip_par=1.0+kn_par*(1.257+.4*exp(-1.1/kn_par)); return cslip_par; fricfac_par=3.0*pi*C_MU_L(c,t)*d_par/cslip_par; return fricfac_par; /* Particle Growth Law subroutine */ real growth_law_particle(real d_par, real R_vap, real rho_vap_par, real amolm_gas, real amolm_vap, real nu_solute, real phi_solute, real eps_solute, cell_t c, Thread *t) { real xi_vap=C_YI(c,t,0); real xi_vape = C_UDMI(c,t,1); real S_vap = C_UDMI(c,t,2); real xi_solute_par=C_UDMI(c,t,5); real psi_solute_par=C_UDMI(c,t,6); real xi_vap_par, psi_vap_par; real difko_vap=diffusion_coefficient_vapor(c,t); real mfp_vap = mean_free_path_vapour(amolm_gas,amolm_vap,c,t); real kn = knudsen_number_particle(mfp_vap,d_par,c,t); real sigma_par; real p_vape, S_par; } difko_par=1.38062e-23*C_T(c,t)/ friction_coefficient_particle (d_par,cslip_par,c,t); return difko_par; real diffusion_coefficient_particle(real d_par, real mfp_i, cell_t c, Thread *t) { real kn_par = knudsen_number_particle(mfp_i, d_par,c,t); real cslip_par = slip_correction_particle (kn_par,c,t); real difko_par; } real friction_coefficient_particle (real d_par, real cslip_par, cell_t c, Thread *t) { real fricfac_par; } real slip_correction_particle (real kn_par, cell_t c, Thread *t) { real cslip_par; } /* Particle properties */ real knudsen_number_particle(real mfp_i, real d_par, cell_t c, Thread *t) { real kn_par; return p_vape; } lat_heat = 2.501e6*pow(zerocelsius/T, 0.167+3.67e-4*T); return lat_heat; /* Mixture properties */ real molar_mass_mixture(real amolm_gas, real amolm_vap, real xi_vap) { real amolm_mix; } s4 = 0.42873e-3 * pow( 10.0, 4.76955 * ( 1.0 - zerocelsius / C_T(c,t))); p_vape = 100.0 * pow( 10.0, s1+s2+s3+s4+0.78614); real T = F_T(f,t); real lat_heat; 88 The Source Code m_par = m_sol_par + m_h2o_par; xi_sol_par = m_sol_par / m_par; xi_vap_par = 1.0 - xi_sol_par; psi_sol_par=massfraction2molefraction(xi_sol_par,amolm_sol,amolm_vap); psi_vap_par=1.0-psi_sol_par; rho_par=pow( xi_sol_par/rho_sol_par +xi_vap_par/rho_vap_par, -1.0); d_par=pow(6.0/pi*m_par/rho_par,1.0/3.0); C_UDMI(c,t,11) = d_par; real equilibrium_d_par(real m_h2o_par, real m_sol_par, real R_vap, real rho_vap_par, real amolm_vap, real nu_sol, real phi_sol, real eps_sol, real amolm_sol, real rho_sol_par, cell_t c, Thread *t) { real S_vap = C_UDMI(c,t,2); real xi_sol_par, psi_sol_par; real xi_vap_par, psi_vap_par; real m_par; real rho_par; real d_par; real sigma_par; real S_par; real S_min=0.; real cor_kelvin, cor_raoult; } /* Wachstumsgesetz */ p_vape=massfraction2molefraction(xi_vape, amolm_vap, amolm_gas) * ABSOLUTE_STATIC_PRESSURE(c,t); dm_par=2.0*pi*d_par*(S_vap-S_par)/ ( R_vap*C_T(c,t)*(1.0-xi_vap*amolm_gas/amolm_vap)/ (difko_vap*p_vape*cor_fusu) +pow(heat_of_vaporization(c,t),2)*S_par/ (R_vap*pow(C_T(c,t),2)*C_UDMI(c,t,0)*cor_fusu) ); return dm_par; /* Fuchs-Sutugin-Korrektur */ cor_fusu=(1.0+kn)/(1.0+(0.377+(4./3.))*kn+(4./3.)*kn*kn); /* Saturation at particle surface */ S_par=cor_kelvin*cor_raoult; C_UDMI(c,t,12) = S_par; /* Raoult-Korrektur */ cor_raoult=exp(-nu_solute*phi_solute*eps_solute*psi_solute_par/ (psi_vap_par+TINY)); /* Kelvin-Korrektur */ cor_kelvin=exp(4.0*sigma_par/(R_vap*C_T(c,t)*rho_vap_par*d_par)); /* Oberflächenspannung */ sigma_par=76.1e-3-0.155e-3*(C_T(c,t)-zerocelsius); xi_vap_par=1.0-xi_solute_par; psi_vap_par=1.0-psi_solute_par; real dm_par=0.; real cor_kelvin, cor_raoult, cor_fusu; hea_mix=C_UDMI(c,thr,0); return hea_mix; visc = 1.83245e-5 * T_0 * sqrt(T_0) * 406.55 / (T + 110.4); return visc; difko_vap=diffusion_coefficient_vapor(c,thr); return difko_vap; difko_uds=C_R(c,thr)*C_UDMI(c,thr,4); return difko_uds; /****** Profile **********************************************************/ /* ------------------------------------------------- */ /* Wall Boundary Condition for Species Mass Fraction */ /* set S_vap = 1 @ wall */ /* ------------------------------------------------- */ DEFINE_PROFILE(vapor_wall,thr,nvar) { face_t f; } DEFINE_DIFFUSIVITY(uds_diffusivity,c,thr,nv) { real difko_uds; } DEFINE_DIFFUSIVITY(mass_diffusivity,c,thr,nv) { real difko_vap; } DEFINE_PROPERTY(air_viscosity_nist,c,thr) { real visc; real T = C_T(c,thr); real T_0 = T / 296.15; } /****** Stoffwerte *************************************************/ DEFINE_PROPERTY(mixture_heat_conductivity,c,thr) { real hea_mix; } /* Difference in saturation */ S_par = cor_kelvin*cor_raoult; S_min = S_vap-S_par; return S_min; /* Raoult-Korrektur */ cor_raoult=exp(-nu_sol*phi_sol*eps_sol*psi_sol_par/ (psi_vap_par+TINY)); /* Kelvin-Korrektur */ cor_kelvin=exp(4.0*sigma_par/(R_vap*C_T(c,t)*rho_vap_par*d_par)); /* Oberflächenspannung */ sigma_par=76.1e-3-0.155e-3*(C_T(c,t)-zerocelsius); 89 if (C_UDSI(c,thr,0) >= N_min) { if(C_UDSI(c,thr,2) <= 0.0 && dm_par < 0.0) { src = 0.0; } else { src = C_R(c,thr)*C_UDSI(c,thr,0)*dm_par *heat_of_vaporization(c,thr); } } if (C_UDSI(c,thr,0) >= N_min) { if(C_UDSI(c,thr,2) <= 0.0 && dm_par < 0.0) { src = 0.0; } else { src=0.0; dsrcdphi=0.0; dS[eqn] = dsrcdphi; return src; } DEFINE_SOURCE(vapour_source,c,thr,dS,eqn) { real dm_par=C_UDMI(c,thr,7); real src, dsrcdphi ; x src=0.0; dsrcdphi=0.0; /****** Source-Routine ***************************************************/ DEFINE_SOURCE(energy_source,c,thr,dS,eqn) { real dm_par=C_UDMI(c,thr,7); real src, dsrcdphi ; } begin_f_loop(f,thr) { if (Data_Valid_P() == 1) { xi_vape=F_UDMI(f, thr, 1); /* calculated in adjust function */ xi_vap_wall=xi_vape; F_PROFILE(f,thr,nvar)=xi_vap_wall; } else { F_PROFILE(f,thr,nvar)=0.0; } } end_f_loop(f,thr) /* cell_t c0; real x[ND_ND],x0[ND_ND]; */ real xi_vape,xi_vap_wall; } src = - C_R(c,thr)*C_UDSI(c,thr,0)*dm_par; dS[eqn] = dsrcdphi; return src; /* ---------------------------------------/* Source term: Latent heat release at wall /* Set as source term in cell thread next /* to inner-wall shadow /* ---------------------------------------DEFINE_SOURCE(heat_source,c,thr,dS,eqn) { real source = 0.; } */ */ */ */ */ if (C_UDSI(c,thr,0) >= N_min) { if(C_UDSI(c,thr,2) <= 0.0 && dm_par < 0.0) { src = 0.0; } else { src = C_R(c,thr)*C_UDSI(c,thr,0)*dm_par; if(dm_par < 0.0) dsrcdphi = src/(C_UDSI(c,thr,2)+TINY); } } src=0.0; dsrcdphi=0.0; dS[eqn] = dsrcdphi; return src; } DEFINE_SOURCE(uds2_source,c,thr,dS,eqn) { real dm_par=C_UDMI(c,thr,7); real src, dsrcdphi ; src=0.0; dsrcdphi=0.0; dS[eqn] = dsrcdphi; return src; } DEFINE_SOURCE(uds1_source,c,thr,dS,eqn) { real src, dsrcdphi ; src=0.0; dsrcdphi=0.0; dS[eqn] = dsrcdphi; return src; } DEFINE_SOURCE(uds0_source,c,thr,dS,eqn) { real src, dsrcdphi ; } 90 The Source Code xi_vap, psi_vap; R_gas,R_vap; amolm_gas, amolm_vap; difko_vap; p_vap, p_vape, xi_vape, S_vap; d_par, m_par, rho_par; amolm_solute; rho_solute_par,rho_vap_par; xi_par; xi_solute_par,xi_vap_par; psi_solute_par,psi_vap_par; dm_par; mfp_gas; nu_solute; phi_solute; eps_solute; difko_par; flox, diff, flux_01, flux_10; flox_uds, bal_uds, bal_heat; flin=0, flout=0; fl_h2o_in=0, fl_h2o_out=0; fl_uds0_in=0, fl_uds0_out=0; fl_uds1_in=0, fl_uds1_out=0; fl_uds2_in=0, fl_uds2_out=0; heat_flow_wall=0., heat_fl=0.; flox2=0.,flow_wall_c=0.; source=0.; real real real real real real real real real real real real real real real real real real real real real real real real real real real /*---- Stoffwerte der Mischung ---------------------------------------*/ amolm_vap = MATERIAL_PROP(MIXTURE_SPECIE(mix, 0),PROP_mwi)/1000.0; amolm_gas = MATERIAL_PROP(MIXTURE_SPECIE(mix, 1),PROP_mwi)/1000.0; R_vap = MATERIAL_PROP(MIXTURE_SPECIE(mix, 0),PROP_Rgas); Material *mix = mixture_material (domain); real c_p, rho, volume; real temp_C, temp_K; F_coord[ND_ND]; C_coord[ND_ND]; A[ND_ND]; s[ND_ND], n; x[ND_ND]; real real real real real /****** Adjust-Routine ***************************************************/ DEFINE_ADJUST(adjust, domain) { Thread *thr; Thread *c_wall_t, *shadow_t; Thread *fluid_t; face_t f; cell_t c,c0; } !!! !!! !!! !!! !!! !!! */ */ */ */ */ */ ----------------------------------------------------------------*/ Calculate convective and diffusive boundary fluxes */ from file udf_masbal.c */ FIXME!!! this code will only work in segregated solver */ !!! VORSICHT only power law !!! */ ----------------------------------------------------------------*/ VORSICHT VORSICHT VORSICHT VORSICHT VORSICHT VORSICHT /* ---------------------------------------------------- */ /* Use mass flow towards wall (ID8) to calculate heat */ F_AREA (A,f,thr); diff = 0.0; C_CENTROID(C_coord, c0, fluid_t); F_CENTROID(F_coord, f, thr); NV_VV (s, =, F_coord, -, C_coord); n = NV_DOT (A, s) / NV_MAG (A); /* !!! FIXME: calculation of n only works for rectangular grids as otherwise the calculation of n is incorrect (see calculation of gradients near at walls !!! */ difko_vap=diffusion_coefficient_vapor(c0,fluid_t); diff = NV_MAG (A) * difko_vap *rho / n; flox = F_FLUX(f,thr); FPM_CONV_DIFF_COEFFS(flox,diff,flux_01,flux_10); flox2 = C_YI(c0,fluid_t,0) * flux_10 F_YI(f,thr,0) * flux_01; flox_uds += C_YI(c0,fluid_t,0) * flux_10 F_YI(f,thr,0) * flux_01; flow_wall_c = fabs(C_YI(c0,fluid_t,0) * flux_10 F_YI(f,thr,0) * flux_01); heat_fl += (C_YI(c0,fluid_t,0) * flux_10 F_YI(f,thr,0) * flux_01) * temp_C * c_p; temp_K = F_T(f,thr); temp_C = temp_K - zerocelsius; c_p = C_P(c0,fluid_t); rho = C_R(c0,fluid_t); bal_uds = 0.0; bal_heat = 0.0; thread_loop_f (thr, domain) { if (BOUNDARY_FACE_THREAD_P(thr) && THREAD_TYPE(thr) != THREAD_F_AXIS) { fluid_t = THREAD_T0 (thr); if (FLUID_THREAD_P(fluid_t)) { flox_uds = 0.0; begin_f_loop (f,thr) { c0 = F_C0(f,thr); /* /* /* /* /* /* if (! Data_Valid_P()) return ; !!! !!! !!! !!! !!! !!! rho_solute_par = 2165.0; amolm_solute = 58.44e-3; nu_solute=2.0; phi_solute=1.0; eps_solute=1.0; rho_vap_par = 1000.0; dS[eqn] = 0.0; source = C_UDMI(c,thr,9); return source; /* /* /* /* /* /* R_gas = MATERIAL_PROP(MIXTURE_SPECIE(mix, 1),PROP_Rgas); if (! Data_Valid_P()) return source; 91 } bal_uds += flox_uds; /* ----------------------------------- */ /* Saturation Vapour Pressure */ /* ----------------------------------- */ thread_loop_c(thr,domain) { if (FLUID_THREAD_P(thr)) { begin_c_loop_all(c,thr) { xi_vap=C_YI(c,thr,0); /* Sättigungsdampfmassenbruch */ xi_vape=molefraction2massfraction (saturation_vapor_pressure(c,thr) / ABSOLUTE_STATIC_PRESSURE(c,thr), amolm_vap,amolm_gas); /* Molenbruch */ /* ----------------------------------------------------- */ /* Species mass fraction at wall for S_vap = 1 */ /* ----------------------------------------------------- */ thread_loop_f(thr,domain) { if(THREAD_ID(thr) == I_WALL_ID) { begin_f_loop(f, thr) { xi_vape=molefraction2massfraction (saturation_vapor_pressure(f,thr) / ABSOLUTE_STATIC_PRESSURE(f,thr), amolm_vap,amolm_gas); F_UDMI(f, thr, 1)=xi_vape; } end_f_loop(f, thr) } } } } } } end_f_loop(f,thr); source = flow_wall_c * heat_of_vaporization_f(f,shadow_t) / volume; C_UDMI(c0,c_wall_t,9) = source; C_UDMI(c0,c_wall_t,10) = flow_wall_c; c0 = F_C0(f,shadow_t); volume = C_VOLUME(c0,c_wall_t); C_CENTROID(x, c0, c_wall_t); /* source in cell thread next to wall-shadow (ID14) */ /* ---------------------------------------------------- */ if (THREAD_ID(thr)== I_WALL_ID) { /* Thread shadow_t = thread "facing" into wall */ shadow_t = Lookup_Thread(domain, I_WALL_SHADOW_ID); /* Thread c_wall_t = thread of solid_wall */ c_wall_t = Lookup_Thread(domain, SOLID_WALL_ID); } /*---- Partikeleigenschaften -----------------------------------------*/ if (uds_particle == 1) { thread_loop_c(thr,domain) { if (FLUID_THREAD_P(thr)) { begin_c_loop_all(c,thr) { if (C_UDSI(c,thr,0) > N_min) /* !!! VORSICHT !!! */ { /* Gesamtpartikelmassenbruch */ xi_par=C_UDSI(c,thr,1)+C_UDSI(c,thr,2); /* Partikelmassenbrüche */ xi_solute_par=C_UDSI(c,thr,1)/xi_par; xi_vap_par=1.0-xi_solute_par; /* Partikelmolenbrüche */ psi_solute_par=massfraction2molefraction (xi_solute_par, amolm_solute, amolm_vap); psi_vap_par=1.0-psi_solute_par; /* Partikelmasse */ m_par=xi_par/C_UDSI(c,thr,0); /* Partikeldichte */ rho_par=pow( xi_solute_par/rho_solute_par +xi_vap_par/rho_vap_par, -1.0); /* Partikeldurchmesser */ d_par=pow(6.0/pi*m_par/rho_par,1.0/3.0); } else { d_par=1.0e-7; m_par=rho_solute_par* (pi/6.0*pow( d_par,3.0) ); xi_solute_par=1.0; xi_vap_par=0.0; psi_solute_par=1.0; psi_vap_par=0.0; rho_par=rho_solute_par; } /* mittl. freie Weglänge */ mfp_gas=mean_free_path_gas(c,thr); } C_CENTROID(x,c,thr); } end_c_loop_all(c,thr) /* Dampfdruck */ p_vap=psi_vap*ABSOLUTE_STATIC_PRESSURE(c,thr); /* Sättigungsdampfdruck */ p_vape=saturation_vapor_pressure(c,thr); /* Sättigung */ S_vap=p_vap/p_vape; /* Zuweisung User-defined Memory */ /* Wärmeleitfähigkeit */ C_UDMI(c,thr,0)=heat_conductivity_mixture(psi_vap, c, thr); C_UDMI(c,thr,1)=xi_vape; C_UDMI(c,thr,2)=S_vap; psi_vap=massfraction2molefraction(xi_vap,amolm_vap,amolm_gas); 92 The Source Code } end_c_loop_all(c,thr); /*---- Bilanzen ------------------------------------------------------*/ if (uds_particle == 1) { thread_loop_f(thr,domain) { /* Inlet */ if (THREAD_TYPE(thr)==THREAD_F_MFINLET ||THREAD_TYPE(thr)==THREAD_F_VINLET) { begin_f_loop(f, thr) { F_AREA(A,f,thr); flox=F_R(f,thr)*(A[0]*F_U(f,thr)+A[1]*F_V(f,thr)); flin=flin+flox; /* Mass Flow */ fl_h2o_in=fl_h2o_in+flox*F_YI(f,thr,0); fl_uds0_in=fl_uds0_in+flox*F_UDSI(f,thr,0); /* uds0 */ } } /*---- Quellen/Senken ------------------------------------------------*/ if (uds_particle == 1) { /*---- Partikelmasse ---- */ thread_loop_c(thr,domain) { if (FLUID_THREAD_P(thr)) { begin_c_loop_all(c,thr) { if (C_UDSI(c,thr,0) > N_min) { d_par=C_UDMI(c,thr,3); dm_par = growth_law_particle(d_par, R_vap, rho_vap_par, amolm_gas, amolm_vap, nu_solute, phi_solute, eps_solute, c, thr); } else { dm_par=0.0; } C_UDMI(c,thr,7)=dm_par; } end_c_loop_all(c,thr); } } } } /* Zuweisung User-defined Memory */ C_UDMI(c,thr,3) = d_par; C_UDMI(c,thr,4) = difko_par; C_UDMI(c,thr,5) = xi_solute_par; C_UDMI(c,thr,6) = psi_solute_par; C_UDMI(c,thr,8) = rho_par; C_UDMI(c,thr,13)= m_par; /* Diffusionskoeffizient */ difko_par=diffusion_coefficient_particle(d_par, mfp_gas, c, thr); /* Variables needed to calculate equilibrium diameter for variable liquid water mass fraction in the drop using a bisectional scheme */ int ID=0; real m_h2o_par; /* mass h2o in actual droplet */ real m_h2o_par1, m_h2o_par2, m_h2o_par3; /* mass h2o for bisection */ real m_untere_gr, m_obere_gr, m_mitte; real d_par_eq, m_solute_par; /****** Execute on Demand ************************************************/ DEFINE_ON_DEMAND(on_demand_equilibrium) { Domain *domain = Get_Domain(1); Thread *thr; cell_t c; real x[ND_ND]; real R_gas,R_vap; real amolm_gas, amolm_vap; real S_vap, S_par; real d_par, m_par; real amolm_solute; real rho_solute_par,rho_vap_par; real xi_solute_par,xi_vap_par; real nu_solute; real phi_solute; real eps_solute; real T; } } fclose(f_o1); fclose(f_o2); } CX_Message ("Mass: %12.4e%12.4e%12.4e\n",flin,flout ,fabs(flout/(flin+TINY))); CX_Message ("H2O: %12.4e%12.4e%12.4e\n",fl_h2o_in,fl_h2o_out ,fabs(fl_h2o_out/(fl_h2o_in+TINY))); CX_Message ("uds0: %12.4e%12.4e%12.4e\n",fl_uds0_in,fl_uds0_out ,fabs(fl_uds0_out/(fl_uds0_in+TINY))); CX_Message ("uds1: %12.4e%12.4e%12.4e\n",fl_uds1_in,fl_uds1_out ,fabs(fl_uds1_out/(fl_uds1_in+TINY))); CX_Message ("uds2: %12.4e%12.4e%12.4e\n",fl_uds2_in,fl_uds2_out ,fabs(fl_uds2_out/(fl_uds2_in+TINY))); fl_uds1_in=fl_uds1_in+flox*F_UDSI(f,thr,1); /* uds1 */ fl_uds2_in=fl_uds2_in+flox*F_UDSI(f,thr,2); /* uds2 */ } end_f_loop(f, thr) } /* Outlet */ if (THREAD_TYPE(thr)==THREAD_F_POUTLET ||THREAD_TYPE(thr)==THREAD_F_OUTFLOW) { begin_f_loop(f, thr) { F_AREA(A,f,thr); flox=F_R(f,thr)*(A[0]*F_U(f,thr)+A[1]*F_V(f,thr)); flout=flout+flox; /* Mass Flow */ fl_h2o_out=fl_h2o_out+flox*F_YI(f,thr,0); fl_uds0_out=fl_uds0_out+flox*F_UDSI(f,thr,0); /* uds0 */ fl_uds1_out=fl_uds1_out+flox*F_UDSI(f,thr,1); /* uds1 */ fl_uds2_out=fl_uds2_out+flox*F_UDSI(f,thr,2); /* uds2 */ } end_f_loop(f, thr) } 93 /* /* /* /* /* /* !!! !!! !!! !!! !!! !!! VORSICHT VORSICHT VORSICHT VORSICHT VORSICHT VORSICHT !!! !!! !!! !!! !!! !!! */ */ */ */ */ */ if (fabs((S_vap-S_par)/S_par) <= acc) { d_par_eq = d_par; S_min3 = equilibrium_d_par(m_h2o_par, m_solute_par, R_vap, rho_vap_par, if (x[1] <= 1.e-4) { m_solute_par=C_UDSI(c,thr,1)/C_UDSI(c,thr,0); m_par = C_UDMI(c,thr,13); xi_solute_par = C_UDMI(c,thr,5); xi_vap_par = 1 - xi_solute_par; m_h2o_par = xi_vap_par * m_par; m_untere_gr = 1.e-25; m_obere_gr = 6.e-10; m_mitte = m_h2o_par; m_h2o_par1 = m_untere_gr; m_h2o_par2 = m_obere_gr; m_h2o_par3 = m_mitte; count = 0; root_test = 0; C_CENTROID(x, c, thr); thread_loop_c(thr,domain) { if (FLUID_THREAD_P(thr)) { begin_c_loop_all(c,thr) { if (C_UDSI(c,thr,0) > N_min) { C_UDMI(c,thr,14) = 0.; C_UDMI(c,thr,15) = 0.; d_par = C_UDMI(c,thr,3); S_vap = C_UDMI(c,thr,2); S_par = C_UDMI(c,thr,12); T = C_T(c,thr); if (! Data_Valid_P()) return ; rho_solute_par = 2165.0; amolm_solute = 58.44e-3; nu_solute=2.0; phi_solute=1.0; eps_solute=1.0; rho_vap_par = 1000.0; /*---- Stoffwerte der Mischung ---------------------------------------*/ amolm_vap = MATERIAL_PROP(MIXTURE_SPECIE(mix, 0),PROP_mwi)/1000.0; amolm_gas = MATERIAL_PROP(MIXTURE_SPECIE(mix, 1),PROP_mwi)/1000.0; R_vap = MATERIAL_PROP(MIXTURE_SPECIE(mix, 0),PROP_Rgas); R_gas = MATERIAL_PROP(MIXTURE_SPECIE(mix, 1),PROP_Rgas); Material *mix = mixture_material (domain); /* growth law for different mass fractions */ real S_min1=0., S_min2=0., S_min3=0.; real acc=1.e-6; /* accuracy of iteration */ real conv=0., m_old=0.; /* for convergence */ int count, root_test; } loop: do { case 0: break; } if (ID==0) { C_UDMI(c,thr,14) = 0.; C_UDMI(c,thr,15) = 0.; goto ende; goto calculus; case 3: m_h2o_par1 = m_h2o_par3; S_min1 = S_min3; goto calculus; case 2: m_h2o_par2 = m_h2o_par3; S_min2 = S_min3; switch (ID) { case 1: root_test = 1; if (S_min1*S_min3 > 0. && S_min2*S_min3 > 0.) goto fini; if (S_min1*S_min3 < 0. && S_min2*S_min3 < 0.) ID = 1; if (S_min2*S_min3 < 0.) ID = 3; if (S_min1*S_min3 < 0.) ID = 2; m_old = m_h2o_par3; S_min1 = equilibrium_d_par(m_h2o_par1, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); S_min2 = equilibrium_d_par(m_h2o_par2, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); S_min3 = equilibrium_d_par(m_h2o_par3, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); goto equilibrium; 94 The Source Code m_h2o_par = 1.e+2*m_h2o_par; m_mitte = m_h2o_par3; S_min3 = equilibrium_d_par(m_h2o_par, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); if (S_min1*S_min3 < 0. && S_min2*S_min3 < 0.) m_h2o_par = 0.1*m_h2o_par; m_mitte = m_h2o_par3; S_min3 = equilibrium_d_par(m_h2o_par, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); if (S_min1*S_min3 < 0. && S_min2*S_min3 < 0.) goto loop; if (count==0 && S_vap>1.0) { m_h2o_par3 = 10.*m_h2o_par; m_mitte = m_h2o_par3; S_min3 = equilibrium_d_par(m_h2o_par3, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); if (S_min1*S_min3 < 0. && S_min2*S_min3 < 0.) goto loop; fini: d_par_eq = C_UDMI(c,thr,11); if ( count == 0) { d_par_eq = 0.; S_min3 = 0.; } } calculus: m_h2o_par3 = sqrt(m_h2o_par1*m_h2o_par2); conv = (m_old-m_h2o_par3)/m_h2o_par3; S_min1 = equilibrium_d_par(m_h2o_par1, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); S_min2 = equilibrium_d_par(m_h2o_par2, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); S_min3 = equilibrium_d_par(m_h2o_par3, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); count = count + 1; } while (fabs(conv) >= acc); } } } } } } end_c_loop_all(c,thr); if (root_test == 2) { C_UDMI(c,thr,15) = d_par_eq; if (count == 1) C_UDMI(c,thr,15) = 0.; } ende: } S_min1 = equilibrium_d_par(m_h2o_par1, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); S_min2 = equilibrium_d_par(m_h2o_par2, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); S_min3 = equilibrium_d_par(m_h2o_par3, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); C_UDMI(c,thr,14) = d_par_eq; if (count == 1) C_UDMI(c,thr,14) = 0.; root_test = 2; goto loop; equilibrium: if (root_test == 0) { C_UDMI(c,thr,14) = d_par_eq; } if (root_test == 1) { m_h2o_par1 = m_mitte; m_h2o_par2 = m_obere_gr; m_h2o_par3 = sqrt(m_h2o_par1*m_h2o_par2); } goto loop; m_h2o_par = 1.e-2*m_h2o_par; m_mitte = m_h2o_par3; S_min3 = equilibrium_d_par(m_h2o_par, m_solute_par, R_vap, rho_vap_par, amolm_vap, nu_solute, phi_solute, eps_solute, amolm_solute, rho_solute_par, c, thr); if (S_min1*S_min3 < 0. && S_min2*S_min3 < 0.) goto loop; 95 /* /* /* /* /* /* !!! !!! !!! !!! !!! !!! VORSICHT VORSICHT VORSICHT VORSICHT VORSICHT VORSICHT !!! !!! !!! !!! !!! !!! thread_loop_f(thr,domain) { if (THREAD_ID(thr)== INLET1_ID) { fluid_t = THREAD_T0 (thr); if (FLUID_THREAD_P(fluid_t)) { begin_f_loop(f,thr) { c0 = F_C0(f,thr); C_CENTROID(C_coord, c0, fluid_t); F_CENTROID(F_coord, f, thr); fprintf(f_o1,"# Köhler curve at %10.4eK\n", T); if (! Data_Valid_P()) return ; rho_solute_par = 2165.0; amolm_solute = 58.44e-3; nu_solute=2.0; phi_solute=1.0; eps_solute=1.0; rho_vap_par = 1000.0; */ */ */ */ */ */ /*---- Stoffwerte der Mischung ---------------------------------------*/ amolm_vap = MATERIAL_PROP(MIXTURE_SPECIE(mix, 0),PROP_mwi)/1000.0; amolm_gas = MATERIAL_PROP(MIXTURE_SPECIE(mix, 1),PROP_mwi)/1000.0; R_vap = MATERIAL_PROP(MIXTURE_SPECIE(mix, 0),PROP_Rgas); R_gas = MATERIAL_PROP(MIXTURE_SPECIE(mix, 1),PROP_Rgas); FILE *f_o1; f_o1 = fopen("koehler.dat", "w"); Material *mix = mixture_material (domain); /* ----- Köhler curve ----- */ DEFINE_ON_DEMAND(on_demand_koehler) { Domain *domain = Get_Domain(1); Thread *thr, *fluid_t; cell_t c0; face_t f; real F_coord[ND_ND]; real C_coord[ND_ND]; real R_gas,R_vap; real amolm_gas, amolm_vap; real amolm_solute; real rho_par, rho_solute_par,rho_vap_par; real xi_par, xi_solute_par,xi_vap_par; real psi_solute_par, psi_vap_par; real molality; real m_par, m_solute_par, m_h2o; real d_par, d_salt; real nu_solute; real phi_solute; real eps_solute; real sigma_par; real S_par; real T = 288.65; real cor_kelvin, cor_raoult; real addend; /* Kelvin-Korrektur */ cor_kelvin=exp(4.0*sigma_par/(R_vap*T* /* Oberflächenspannung */ sigma_par=76.1e-3-0.155e-3*(T-zerocelsius); /* Partikeldichte */ rho_par=pow(xi_solute_par/rho_solute_par+ xi_vap_par/rho_vap_par, -1.0); /* Partikeldurchmesser */ d_par=pow(6.0/pi*m_par/rho_par,1.0/3.0); addend = 1.e-2; m_solute_par=F_UDSI(f,thr,1)/F_UDSI(f,thr,0); for ( m_h2o=1.e-17; m_h2o<=1.e-10; (m_h2o = m_h2o * exp(addend))) { m_par = m_solute_par + m_h2o; xi_solute_par = m_solute_par / m_par; xi_vap_par = 1.0 - xi_solute_par; psi_solute_par=massfraction2molefraction (xi_solute_par,amolm_solute,amolm_vap); psi_vap_par=1.0-psi_solute_par; /* Molalität */ molality = massfraction2molality (xi_solute_par, amolm_solute); if (molality >= 6.25) { fprintf(f_o1,"# molality = %12.4e", molality); fprintf(f_o1," @ %20.6e\n", m_h2o); } if (F_coord[1] > 9.4e-4 && F_coord[1] < 1.e-3) { d_salt = pow(6.0/pi*m_par/rho_solute_par,1.0/3.0); fprintf(f_o1,"# Diameter salt particle 12.4e\n", d_salt); fprintf(f_o1,"# Mass salt particle %12.4e\n", m_solute_par); fprintf(f_o1,"# Mass water in droplet %12.4e\n", m_h2o); fprintf(f_o1,"# Mass fraction salt %12.4e\n", xi_solute_par); /* fprintf(f_o1,"# Molality %12.4e\n", molality); */ /* Gesamtpartikelmassenbruch */ xi_par=F_UDSI(f,thr,1)+F_UDSI(f,thr,2); /* Partikelmassenbrüche */ xi_solute_par=F_UDSI(f,thr,1)/xi_par; xi_vap_par=1.0-xi_solute_par; /* Partikelmolenbrüche */ psi_solute_par=massfraction2molefraction (xi_solute_par, amolm_solute, amolm_vap); psi_vap_par=1.0-psi_solute_par; /* molality = massfraction2molality(xi_solute_par, amolm_solute); */ /* Partikelmasse */ m_par=xi_par/F_UDSI(f,thr,0); m_solute_par = xi_solute_par * m_par; m_h2o = xi_vap_par * m_par; 96 The Source Code } } } } fclose(f_o1); S_par = cor_kelvin*cor_raoult; fprintf(f_o1,"%20.6e ",m_h2o); fprintf(f_o1,"%20.10e ",d_par); fprintf(f_o1,"%20.10e\n",S_par); /* Raoult-Korrektur */ cor_raoult=exp(-nu_solute*phi_solute*eps_solute* psi_solute_par/(psi_vap_par+TINY)); } } } end_f_loop(f, thr) rho_vap_par*d_par)); 97