sandbox/fintzin/Rising-Suspenion/PA.h
- @file PA.h
- @author fintzi nicolas (fintzi.nicolas@ifpen.fr)
- @brief
- @version 0.1
- @date 2022-09-25
- @copyright Copyright (c) 2022
This file contain all the function to carry out the calculation of the closure terms * using the particular average formulaiton. All the terms are gathered in the PA struct.
##Declaration of the structure gathering particular averaged closure terms.
The below quandtities are for most of them similar to the Drop struct but it is implied that it is averaged on all the droplets
typedef struct PA
{
- @brief average basic quantities.
double V; // volume of droplets
double S; // surface of droplets
double ed; // NRJ diss
; // mean velocity
coord U; // mean centered velocity
coord Uc; // shape tensor
tens G; // moment of momentum
tens Pdouble Gnorm; // shape tensor
double Pnorm; // moment of momentum
double W2; // moment of momentum
- @brief particular average closure terms for the momentum eq
; // product of the fluctuation
coord VpUp; // product of the fluctuation around the mean vel
tens VpUpUp; // product of the fluctuation around the centered vel
tens UpUp; // product of the fluctuation around the centered vel coord UpUpUp
- @brief partcular average closure terms for the moment of momentum eq
- I will need :
; // Stress tensor
tens Sig; // First hydro moment
tens Mh; // First hydro moment of the surface tension
tens Ms; // inner fluctuation around Uc
tens WW; // particule fluid particule stress
tens PFP}PA;
Compute the mean vol and the volume fluctuation
void average_quantities(PA * pa, Drop n[]){
->V = pa->S = pa->ed = pa->Gnorm = pa->Pnorm = pa->W2= 0.;
pa->U = pa->Uc = Coord_nul;
pa->G = pa->P = tens_nul;
paint Nbub = n[0].tagmax;
for(int i = 0; i < Nbub; i++){
->V += n[i].vol/Nbub;
pa->S += n[i].S/Nbub;
pa->ed += n[i].ed/Nbub;
pa->Gnorm += n[i].Gnorm/Nbub;
pa->Pnorm += n[i].Pnorm/Nbub;
pa->W2 += n[i].W2/Nbub;
paeinstein_sum(i,j){
->U.i += n[i].U.i / Nbub;
pa->Uc.i += n[i].Uc.i / Nbub;
pa->G.i.j += n[i].G.i.j / Nbub;
pa->P.i.j += n[i].P.i.j / Nbub;
pa}
}
}
Compute the fluctuation terms in the momentum equation
void momentum_closure(PA * pa, Drop n[]){
->VpUp = pa->UpUpUp = Coord_nul;
pa->VpUpUp = pa->UpUp = tens_nul;
paint Nbub = n[0].tagmax;
for(int i = 0; i < Nbub; i++)
einstein_sum(i,j){
->VpUp.i += (n[i].U.i - pa->U.i) * (n[i].vol - pa->V) / Nbub;
pa->VpUpUp.i.j += (n[i].U.i - pa->U.i)
pa* (n[i].U.j - pa->U.j) * (n[i].vol - pa->V) / Nbub;
->UpUp.i.j += (n[i].U.i - pa->U.i)
pa* (n[i].U.j - pa->U.j) / Nbub;
->UpUpUp.i += (n[i].U.i - pa->U.i) *(n[i].U.i - pa->U.i)
pa* (n[i].U.i - pa->U.i) / Nbub;
}
}
Compute the fluctuation terms in the moment momentum equation
void moment_of_momentum_closure(PA * pa, Drop n[]){
->Sig = pa->Mh = pa->Ms = pa->WW = tens_nul;
paint Nbub = n[0].tagmax;
for(int i = 0; i < Nbub; i++)
einstein_sum(i,j){
->Sig.i.j += n[i].Sig.i.j / Nbub;
pa->Mh.i.j += n[i].Mh.i.j / Nbub;
pa->Ms.i.j += n[i].Ms.i.j / Nbub;
pa->WW.i.j += n[i].WW.i.j / Nbub;
pa}
}
- This function compute the Particule Fluid Particle Stress from Zhang nearest statistics
- theory. We start by computing the drag force applied on one particles.
- Tehn we carry out the formula (4.7) of their paper.
void compute_PFP(PA * pa, Drop n[],Drop nt0[]){
int Nbub = n[0].tagmax;
for (int i = 0; i < Nbub; i++){
= n[i];
Drop ni = nt0[i];
Drop n0 for (int j = 0; j < nt0[0].tagmax ; j++)
if(nt0[j].tag == ni.tag)
= nt0[j];
n0 // we compute the linera momentum
= mult_coord(ni.U , ni.vol * rho_d);
coord qi = mult_coord(n0.U , n0.vol * rho_d);
coord q0 = div_coord(diff_coord(qi,q0),dtprint);
coord dqdt // then the body forces
= {0,- 1,0};
coord g_dir = mult_coord(g_dir , g * ni.vol * (rho_d - rho_f));
coord b // the hydrodinamic drag reads as
[i].Fh = diff_coord(dqdt,b);
n}
Now wecompute the PFP stress by using * * \Sigma_{PFP} = \frac{1}{2V} \Sum_{\alpha} \textbf{r} \textbf{f}^h *
->PFP = tens_nul;
pafor (int i = 0; i < Nbub; i++)
einstein_sum(i,j){
->PFP.i.j += (n[i].D_nbr.i * n[i].Fh.j)/Nbub;
pa}
}
main function
void calcul_PA(PA * pa, Drop n[], Drop n0[]){
average_quantities(pa,n);
momentum_closure(pa,n);
moment_of_momentum_closure(pa,n);
compute_PFP(pa,n,n0);
}
void print_PA(PA pa,int step){
= fopen("fPA.csv","a");
fPA fprintf(fPA,"%d",step);
fprintf(fPA,",%g",t);
fprintf(fPA,",%g",pa.V);
fprintf(fPA,",%g",pa.S);
fprintf(fPA,",%g",pa.ed);
fprintf(fPA,",%g",pa.Gnorm);
fprintf(fPA,",%g",pa.Pnorm);
fprintf(fPA,",%g",pa.W2);
einstein_sum(i,j){
fprintf(fPA,",%g",pa.U.i);
fprintf(fPA,",%g",pa.Uc.i);
fprintf(fPA,",%g",pa.G.i.j);
fprintf(fPA,",%g",pa.P.i.j);
fprintf(fPA,",%g",pa.VpUp.i);
fprintf(fPA,",%g",pa.VpUpUp.i.j);
fprintf(fPA,",%g",pa.UpUp.i.j);
fprintf(fPA,",%g",pa.UpUpUp.i);
fprintf(fPA,",%g",pa.Sig.i.j);
fprintf(fPA,",%g",pa.Mh.i.j);
fprintf(fPA,",%g",pa.Ms.i.j);
fprintf(fPA,",%g",pa.WW.i.j);
fprintf(fPA,",%g",pa.PFP.i.j);
}
fprintf(fPA,"\n");
fclose(fPA);
}