Skip to content

Commit

Permalink
Modifications to droplet collision setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Ladiges committed Nov 5, 2024
1 parent c5f19c0 commit cdca64b
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 25 deletions.
61 changes: 52 additions & 9 deletions exec/multispec/Init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ void InitRhoUmac(std::array< MultiFab, AMREX_SPACEDIM >& umac,
MultiFab& rho_in,
const Geometry& geom)
{

std::cout << "Prob type: " << prob_type << std::endl;

GpuArray<Real,AMREX_SPACEDIM> dx = geom.CellSizeArray();

Expand Down Expand Up @@ -442,20 +440,30 @@ void InitRhoUmac(std::array< MultiFab, AMREX_SPACEDIM >& umac,
});


} else if (prob_type == 17) {
} else if (prob_type == 17 || prob_type == 18) {

/*
torus
colliding droplets
*/
amrex::Real rad = radius_cyl;
amrex::Real alpha = contact_angle_lo[1];
amrex::Real alpha = contact_angle_lo[1];

Real rad2 = 0.00212;
GpuArray<Real,AMREX_SPACEDIM> droplet_center;

AMREX_D_TERM(droplet_center[0] = center[0];,
droplet_center[1] = rad*std::cos(alpha)+rad+rad2;,
droplet_center[2] = center[2];);

int nsub = 10;
Real factor = nsub;
Real dxsub = dx[0]/factor;
Real dysub = dx[1]/factor;
Real dzsub = dx[2]/factor;
Real x,y,z;
Real x,y,z;
Real x2,y2,z2;
Real veldrop = -100.;
//Print() << rad*std::cos(alpha)+rad << ", " << rad2 << ", " << dx[1] << std::endl;
amrex::Print() << "smoothing width " << smoothing_width << " radius " << rad << std::endl;

amrex::ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
Expand All @@ -464,6 +472,7 @@ void InitRhoUmac(std::array< MultiFab, AMREX_SPACEDIM >& umac,
c(i,j,k,n) = 0.;
}
Real x,y,z;
Real x2,y2,z2;

for(int i1=0; i1<nsub; ++i1) {
for(int j1=0; j1<nsub; ++j1) {
Expand All @@ -472,8 +481,13 @@ void InitRhoUmac(std::array< MultiFab, AMREX_SPACEDIM >& umac,
AMREX_D_TERM(x = prob_lo[0] + i*dx[0] + (i1+0.5)*dxsub - center[0];,
y = prob_lo[1] + j*dx[1] + (j1+0.5)*dysub - rad*std::cos(alpha);,
z = prob_lo[2] + k*dx[2] + (k1+0.5)*dzsub - center[2];);

AMREX_D_TERM(x2 = prob_lo[0] + i*dx[0] + (i1+0.5)*dxsub - droplet_center[0];,
y2 = prob_lo[1] + j*dx[1] + (j1+0.5)*dysub - droplet_center[1];,
z2 = prob_lo[2] + k*dx[2] + (k1+0.5)*dzsub - droplet_center[2];);

Real r = (AMREX_SPACEDIM == 2) ? std::sqrt(x*x+y*y) : std::sqrt(x*x+y*y+z*z);
Real r2 = (AMREX_SPACEDIM == 2) ? std::sqrt(x2*x2+y2*y2) : std::sqrt(x2*x2+y2*y2+z2*z2);

if (smoothing_width == 0.) {

Expand All @@ -482,7 +496,17 @@ void InitRhoUmac(std::array< MultiFab, AMREX_SPACEDIM >& umac,
for (int n=0; n<nspecies; ++n) {
c(i,j,k,n) += c_init_1[n];
}
} else {
} else if (r2 < rad2){
for (int n=0; n<nspecies; ++n) {
if(prob_type == 17)
{
c(i,j,k,n) += c_init_3[n];
}else if(prob_type == 18)
{
c(i,j,k,n) += c_init_1[n];
}
}
}else{
for (int n=0; n<nspecies; ++n) {
c(i,j,k,n) += c_init_2[n];
}
Expand All @@ -491,8 +515,9 @@ void InitRhoUmac(std::array< MultiFab, AMREX_SPACEDIM >& umac,
} else {
// smooth interface
for (int n=0; n<nspecies; ++n) {
c(i,j,k,n) += c_init_1[n] + (c_init_2[n]-c_init_1[n]) *
0.5*(1. + std::tanh((r-rad)/(smoothing_width*dx[0])));
c(i,j,k,n) += c_init_1[n] +
(c_init_2[n]-c_init_1[n]) *0.5*(1. + std::tanh((r-rad)/(smoothing_width*dx[0]))) +
(c_init_3[n]-c_init_1[n]) *0.5*(1. + std::tanh((r2-rad2)/(smoothing_width*dx[0])));
}
}
}
Expand All @@ -502,6 +527,24 @@ void InitRhoUmac(std::array< MultiFab, AMREX_SPACEDIM >& umac,
c(i,j,k,n) = c(i,j,k,n)/(factor*factor*factor);
}
});

const Array4<Real> & vmac = (umac[1]).array(mfi);
Box bx_vmac = mfi.tilebox(nodal_flag_y);

amrex::ParallelFor(bx_vmac, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real x2,y2,z2;
AMREX_D_TERM(x2 = prob_lo[0] + (i+0.5)*dx[0] - droplet_center[0];,
y2 = prob_lo[1] + (j)*dx[1] - droplet_center[1];,
z2 = prob_lo[2] + (k+0.5)*dx[2] - droplet_center[2];);

Real r2 = (AMREX_SPACEDIM == 2) ? std::sqrt(x2*x2+y2*y2) : std::sqrt(x2*x2+y2*y2+z2*z2);
if (r2 < rad2) {
for (int n=0; n<nspecies; ++n) {
vmac(i,j,k) = veldrop;
}
}
});


} else if (prob_type == 20) {
Expand Down
42 changes: 26 additions & 16 deletions exec/multispec/inputs_droplet_collision
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Problem specification
prob_lo = 0. 0. 0. # physical lo coordinate
#prob_hi = 9.6e-7 9.6e-7 9.6e-7 # physical hi coordinate
prob_hi = 25.6e-3 12.8e-3 25.6e-3 # physical hi coordinate
# prob_hi = 512e-4 256e-4 512e-4 # physical hi coordinate
prob_hi = 384e-4 192e-4 384e-4 # physical hi coordinate

# cell_depth = 1.0e-7

Expand All @@ -11,16 +12,20 @@
plot_base_name= plt

# number of cells in domain
n_cells = 128 64 128
n_cells = 192 96 192
max_grid_size = 96 48 48
# max number of cells in a box
max_grid_size = 32 64 32

# Time-step control
fixed_dt = 6.e-9
fixed_dt = 0.0000001
# fixed_dt = 6.e-13

advection_type = 2

# Controls for number of steps between actions
max_step = 1000000
plot_int = 5
#max_step = 1000000
max_step = 20000
plot_int = 100
chk_int = 1000
restart = -1

Expand Down Expand Up @@ -73,29 +78,33 @@

# Thermodynamic and transport properties:
#----------------------
nspecies = 2
#molmass = 2.4e-22 2.4e-22 # molecular masses for nspecies (mass per molecule, *not* molar mass)
fh_monomers = 1. 1.
nspecies = 3
#molmass = 2.4e-22 2.4e-22 2.4e-22 # molecular masses for nspecies (mass per molecule, *not* molar mass)
fh_monomers = 1. 1. 1.
monomer_mass = 6.e-23
use_flory_huggins = 1
fh_chi = 0. 3.5 3.5 0.
fh_kappa = 0. 3.e-14 3.e-14 0.
fh_chi = 0. 3.5 3.5 3.5 0. 0. 3.5 0. 0.
#fh_chi = 0. 3.5 3.5 0.
fh_kappa = 0. 3.e-14 3.e-14 3.e-14 0. 0. 3.e-14 0. 0.
#fh_kappa = 0. 3.e-14 3.e-14 0.
fh_tension = 24.3386
fh_ce = 0.037874
contact_angle_lo = 90. 110. 90.
contact_angle_hi = 90. 110. 90.


rhobar = 1. 1. # pure component densities for all species
rhobar = 1. 1. 1. # pure component densities for all species
rho0 = 1.



is_ideal_mixture = 0

# initial values for c
c_init_1 = 0.037874 0.962126
c_init_2 = 0.962126 0.037874
c_init_1 = 0.015 0.97 0.015
c_init_2 = 0.97 0.015 0.015
c_init_3 = 0.015 0.015 0.97

smoothing_width = 0.
radius_cyl = 0.0125

Expand All @@ -104,11 +113,12 @@
# The values are red row by row starting from top going down
# (this allows easy addition/deletion of new species/rows)
# So D_12; D_13, D_23; D_14, D_24, D_34; ...
Dbar = 2.e-5 # Maxwell-Stefan diffusion constant
#Dbar = 2.e-5 # Maxwell-Stefan diffusion constant
Dbar = 1.e-7 1.e-7 2.e-5

use_charged_fluid = 0
dielectric_const = 9.2e-20
charge_per_mass = 0. 0.
charge_per_mass = 0. 0. 0.

#use_multiphase = 1
#alpha_gex = 4.
Expand Down
8 changes: 8 additions & 0 deletions src_multispec/multispec_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ AMREX_GPU_MANAGED amrex::Real multispec::monomer_m
AMREX_GPU_MANAGED int multispec::n_gex;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, MAX_SPECIES> multispec::c_init_1;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, MAX_SPECIES> multispec::c_init_2;
AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, MAX_SPECIES> multispec::c_init_3;

int multispec::midpoint_stoch_mass_flux_type;
AMREX_GPU_MANAGED int multispec::avg_type;
Expand Down Expand Up @@ -107,6 +108,7 @@ void InitializeMultispecNamespace() {
for (int i=0; i<MAX_SPECIES; ++i) {
c_init_1[i] = 1.; // initial values for c
c_init_2[i] = 1.;
c_init_3[i] = 1.;
}

// Thermodynamic and transport properties:
Expand Down Expand Up @@ -253,6 +255,11 @@ void InitializeMultispecNamespace() {
c_init_2[i] = temp[i];
}
}
if(pp.queryarr("c_init_3",temp)) {
for (int i=0; i<nspecies; ++i) {
c_init_3[i] = temp[i];
}
}
if(pp.queryarr("Dtherm",temp,0,nspecies)) {
for (int i=0; i<nspecies; ++i) {
Dtherm[i] = temp[i];
Expand Down Expand Up @@ -306,3 +313,4 @@ void InitializeMultispecNamespace() {
pp.query("zero_eps_on_wall_left_end",zero_eps_on_wall_left_end);
pp.query("zero_eps_on_wall_right_start",zero_eps_on_wall_right_start);
}

1 change: 1 addition & 0 deletions src_multispec/multispec_namespace.H
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace multispec {
extern AMREX_GPU_MANAGED int n_gex;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, MAX_SPECIES> c_init_1;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, MAX_SPECIES> c_init_2;
extern AMREX_GPU_MANAGED amrex::GpuArray<amrex::Real, MAX_SPECIES> c_init_3;

extern int midpoint_stoch_mass_flux_type;
extern AMREX_GPU_MANAGED int avg_type;
Expand Down

0 comments on commit cdca64b

Please sign in to comment.