Description
Hi,
I am interested in investigating acoustic propagation with the LBM. I have been trying to recreate some simple examples from [1] in FluidX3D using the liquid metal on a speaker example as a starting point. The difference is that instead of varying the velocity at a point I am trying to vary the density to create an acoustic source; I have the following main_setup
#include "setup.hpp"
#include <fstream>
void main_setup() { // defines: D3Q19, SRT, FP16S, UPDATE_FIELDS
// params
const uint L = 256u;
const float nu = 0.06f;
const float T = 40.0f;
const float B = 0.01f;
const float omega = 2*pif / T;
// LBM
LBM lbm(L, L, L, nu, 0.0f, 0.0f, 0.0f);
// boundary conditions
const uint Nx=lbm.get_Nx(), Ny=lbm.get_Ny(), Nz=lbm.get_Nz();
parallel_for(lbm.get_N(), [&](ulong n) { uint x=0u, y=0u, z=0u;
lbm.coordinates(n,x,y,z);
if(x==0u || x==Nx-1u || y==0u || y==Ny-1u || z==0u || z==Nz-1u) lbm.flags[n]=TYPE_S;
if(x==L/2u && y==L/2u && z==L/2u) lbm.rho[n] = 1.0f; // initial density
});
// data recording
std::ofstream outfile("bin/export/data/out.txt");
// source and receiver index
const uint src_n = lbm.index(L/2u, L/2u, L/2u), rcvr_n = lbm.index(L/2u, (L/4u), L/2u);
// run sim
lbm.run(0u);
while(lbm.get_t() < 500u) {
//point src density variation
lbm.rho.read_from_device();
lbm.rho[src_n] = 1 + B*sinf(omega*(float)lbm.get_t());
// write data out
outfile << lbm.rho[src_n] << ", " << lbm.rho[rcvr_n] << std::endl;
// update
lbm.rho.write_to_device();
lbm.run(1u);
}
}
The issue is that I observe the density varying at the source position but not anywhere else in the field. Is what I am trying to do possible in FluidX3D/what do I need to do to make it work?
Many thanks,
Fin.
[1] Salomons, E.M., Lohman, W.J. and Zhou, H., 2016. Simulation of sound waves using the lattice Boltzmann method for fluid flow: Benchmark cases for outdoor sound propagation. PloS one, 11(1), p.e0147206.