Use direct momentum in opt-in shifted blocked equilibrium
This commit is contained in:
1 parent
c33caf636d
commit
b77f2238dd
7 files changed
+66
-1
No files matched your search
@@ -13,6 +13,8 @@
|
||||
#define OMEGA_COLLISION_MAX 1.99f
|
||||
struct Params {float omega, fx, fy, fz;} d_params;
|
||||
#include "core/descriptors.cuh"
|
||||
// Host round-to-nearest shim; CUDA intrinsic behavior is tested on-device.
|
||||
inline float __fdiv_rn(float a, float b) { return a / b; }
|
||||
#include "operators/macro.cuh"
|
||||
#include "operators/collision_srt.cuh"
|
||||
#include "operators/collision_trt.cuh"
|
||||
|
||||
@@ -34,6 +34,8 @@ inline int obs_torque_index(int,int){return 0;}
|
||||
#include "core/descriptors.cuh"
|
||||
#include "core/precision.cuh"
|
||||
#include "core/layout.cuh"
|
||||
// Host round-to-nearest shim; CUDA intrinsic behavior is tested on-device.
|
||||
inline float __fdiv_rn(float a, float b) { return a / b; }
|
||||
#include "operators/macro.cuh"
|
||||
#include "operators/collision_srt.cuh"
|
||||
#include "operators/collision_trt.cuh"
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#define WALL_SLOT_WIDTH 0
|
||||
#define NX 16
|
||||
#include "core/descriptors.cuh"
|
||||
// Host round-to-nearest shim; CUDA intrinsic behavior is tested on-device.
|
||||
inline float __fdiv_rn(float a, float b) { return a / b; }
|
||||
#include "operators/macro.cuh"
|
||||
#include "operators/collision_srt.cuh"
|
||||
#include "boundary/planar_velocity.cuh"
|
||||
@@ -23,6 +25,13 @@ int main() {
|
||||
float eq[9]; compute_feq(1.f+delta,u,-.2f*u,eq,delta);
|
||||
printf("E %.9g %.9g %.9g\n",delta,u,-.2f*u);emit(eq);
|
||||
}
|
||||
for(float delta : {0.f, 0x1p-30f, -0x1p-30f, .04f, -.01f})
|
||||
for(float jx : {0.f,.005f,-.02f}) {
|
||||
const float jy = -.2f*jx, rho = 1.f+delta;
|
||||
const float ux = jx/rho, uy = jy/rho;
|
||||
float eq[9];compute_feq_from_momentum(delta,jx,jy,ux,uy,eq);
|
||||
printf("J %.9g %.9g %.9g %.9g %.9g\n",delta,jx,jy,ux,uy);emit(eq);
|
||||
}
|
||||
for(int mode : {0,1,2}) for(float rho : {1.f,1.04f}) {
|
||||
float f[9];const float u=.007f,v=.003f;
|
||||
compute_feq(rho,u,v,f,rho-1.f);
|
||||
|
||||
@@ -19,6 +19,15 @@ def test_retained_density_and_shifted_planar_headers(tmp_path):
|
||||
if u==0:
|
||||
np.testing.assert_allclose(a.sum(),delta,rtol=5e-8,atol=0)
|
||||
if delta: assert np.any(a!=0)
|
||||
elif kind=='J':
|
||||
delta,jx,jy,ux,uy=np.array(numbers,dtype=np.float32).astype(float)
|
||||
jd=cx*jx+cy*jy;ud=cx*ux+cy*uy
|
||||
expected=w*(delta+3*jd+4.5*jd*ud-1.5*(jx*ux+jy*uy))
|
||||
np.testing.assert_allclose(a,expected,rtol=3e-6,atol=2e-9)
|
||||
actual=np.array([a.sum(),a@cx,a@cy,a@(cx*cx),a@(cx*cy),a@(cy*cy)])
|
||||
target=np.array([delta,jx,jy,delta/3+jx*ux,jx*uy,delta/3+jy*uy])
|
||||
np.testing.assert_allclose(actual,target,atol=4e-9,rtol=3e-6)
|
||||
if jx==0 and delta: assert np.any(a!=0)
|
||||
else:
|
||||
mode=int(numbers[0]);rho,u,v=np.array(numbers[1:],dtype=np.float32).astype(float)
|
||||
b=np.fromstring(next(it),sep=' ',dtype=np.float32).astype(float)
|
||||
|
||||
Reference in new issue
Block a user