<commit_before>/**************************************************************************
				UDF of ozone deposition & chemical reaction
@author:<NAME>
@e-mail:<EMAIL>
@latest:2016.10.20
This is an UDF file to simulate indoor ozone deposition in CFD, included 
the chemical reaction. The UDF file includes the following terms: 
1  Ozone sink term;
2  B source&sink term;
3  P source term;
**************************************************************************/

#include "udf.h"
#include "sg.h"

#define r 2.0e-5           //reaction probability (-)
#define v 360.0            //Boltzmann velocity (m/s)
#define vs (r*v/4)         //surface uptake velocity (m/s)
#define Dm 1.82e-5         //diffusion coefficient of ozone in air (m2/s)
#define rho 1.205          //density of air (kg/m3)
#define kb_A 5111.111       //second order rate constant for ozone (kg/m3s) (convert from 0.0184ppb-1h-1) 98000.1978
#define kb_B 5111.111        //second order rate constant for ozone (kg/m3s) (convert from 0.0184ppb-1h-1) 34527.4604
#define B_source 5.25e-10  //source of B (kg/m2s) (convert from 1.89mg/m2h)

/*********ozone sink term (ozone deposition & chemical reaction)**********/

DEFINE_SOURCE(ozone_sink_udf,c,t,dS,eqn)
{
	face_t f;
	Thread *tf;
	int n;
	real NV_VEC(A);
	real xc[ND_ND], xf[ND_ND],y0[ND_ND];
	real source,depo_rate;
	real dy0;
	C_CENTROID(xc,c,t);
	source=kb_A*C_YI(c,t,1)*rho;
	c_face_loop (c,t,n)
	{
		f=C_FACE(c,t,n);
		tf=C_FACE_THREAD(c,t,n);
		F_CENTROID(xf,f,tf);
		if (THREAD_TYPE(tf)==THREAD_F_WALL)
		{
			NV_VV(y0,=,xc,-,xf);
			dy0=NV_MAG(y0);
			F_AREA(A,f,tf);
			depo_rate=vs/(1+vs*dy0/Dm)*NV_MAG(A)/C_VOLUME(c,t);
			source+=depo_rate;
		}
	}
	source=-rho*source;
	dS[eqn]=source;
	source*=C_YI(c,t,0);
	return source;
}

/***********B source from floor and sink of chemical reaction*************/

DEFINE_SOURCE(B_source_sink_udf,c,t,dS,eqn)
{
	face_t f;
	Thread *tf;
	int n;
	real NV_VEC(A);
	real source;
	real sourceB;
	real xf[ND_ND];
	C_CENTROID(xf,c,t);
	source=-kb_B*C_YI(c,t,0)*rho*C_YI(c,t,1)*rho;

	c_face_loop (c,t,n)
	{
		f=C_FACE(c,t,n);
		tf=C_FACE_THREAD(c,t,n);
		//F_CENTROID(xf,f,tf);
		if (THREAD_TYPE(tf)==THREAD_F_WALL && xf[1]<=0.00058)
		{
			F_AREA(A,f,tf);
			sourceB=B_source*NV_MAG(A)/C_VOLUME(c,t);
			source+=sourceB;
		}
	}
	dS[eqn]=-kb_B*C_YI(c,t,0)*rho*rho;
	return source;
}

/*********************P source of chemical reaction***********************/

DEFINE_SOURCE(P_source_udf,c,t,dS,eqn)
{
	face_t f;
	Thread *tf;
	real source;

	source=kb_B*C_YI(c,t,0)*rho*C_YI(c,t,1)*rho;
	dS[eqn]=0;
	return source;
}<commit_msg>add some comments<commit_after>/**************************************************************************
		UDF of ozone deposition & chemical reaction
@author:<NAME>
@e-mail:<EMAIL>
@latest:2016.10.20
This is an UDF file to simulate indoor ozone deposition in CFD, included 
the chemical reaction. The UDF file includes the following terms: 
1  Ozone sink term;
2  B source&sink term;
3  P source term;
**************************************************************************/

#include "udf.h"
#include "sg.h"

#define r 2.0e-5           //reaction probability (-)
#define v 360.0            //Boltzmann velocity (m/s)
#define vs (r*v/4)         //surface uptake velocity (m/s)
#define Dm 1.82e-5         //diffusion coefficient of ozone in air (m2/s)
#define rho 1.205          //density of air (kg/m3)
#define kb 5111.111        //second order rate constant for ozone (s-1) (convert from 0.0184ppb-1h-1)
#define B_source 5.25e-10  //source of B (kg/m2s) (convert from 1.89mg/m2h)

/*********ozone sink term (ozone deposition & chemical reaction)**********/

DEFINE_SOURCE(ozone_sink_udf,c,t,dS,eqn)
{
	face_t f;
	Thread *tf;
	int n;
	real NV_VEC(A);
	real xc[ND_ND], xf[ND_ND],y0[ND_ND];
	real source,depo_rate;
	real dy0;
	C_CENTROID(xc,c,t);
	source=kb*C_YI(c,t,1)*rho;	//ozone sink of indoor air owning to chemical reaction
	c_face_loop (c,t,n)
	{
		f=C_FACE(c,t,n);
		tf=C_FACE_THREAD(c,t,n);
		F_CENTROID(xf,f,tf);
		if (THREAD_TYPE(tf)==THREAD_F_WALL)
		{
			NV_VV(y0,=,xc,-,xf);
			dy0=NV_MAG(y0);
			F_AREA(A,f,tf);
			depo_rate=vs/(1+vs*dy0/Dm)*NV_MAG(A)/C_VOLUME(c,t);	//ozone sink of surface deposition of the whole indoor walls
			source+=depo_rate;
		}
	}
	source=-rho*source;
	dS[eqn]=source;
	source*=C_YI(c,t,0);
	return source;
}

/***********B source from floor and sink of chemical reaction*************/

DEFINE_SOURCE(B_source_sink_udf,c,t,dS,eqn)
{
	face_t f;
	Thread *tf;
	int n;
	real NV_VEC(A);
	real source;
	real sourceB;
	real xf[ND_ND];
	source=-kb*C_YI(c,t,0)*rho*C_YI(c,t,1)*rho;	//B sink of indoor air owning to chemical reaction

	c_face_loop (c,t,n)
	{
		f=C_FACE(c,t,n);
		tf=C_FACE_THREAD(c,t,n);
		F_CENTROID(xf,f,tf);
		if (THREAD_TYPE(tf)==THREAD_F_WALL && xf[1]==0.0)	//get the faces belong to floor surface (y coordinate equals 0)
		{
			F_AREA(A,f,tf);
			sourceB=B_source*NV_MAG(A)/C_VOLUME(c,t);	//B source from floor surface
			source+=sourceB;
		}
	}
	dS[eqn]=-kb*C_YI(c,t,0)*rho*rho;
	return source;
}

/*********************P source of chemical reaction***********************/

DEFINE_SOURCE(P_source_udf,c,t,dS,eqn)
{
	face_t f;
	Thread *tf;
	real source;

	source=kb*C_YI(c,t,0)*rho*C_YI(c,t,1)*rho;	//P source of chemical reaction
	dS[eqn]=0;
	return source;
}

{'fraction_non_alphanumeric': 0.2238968585436717, 'fraction_numerical': 0.03304884692209915, 'mean_word_length': 3.7238421955403087, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3216270', 'n_tokens_mistral': 2508, 'n_tokens_neox': 2312, 'n_words': 475}