ProjectPhysX / FluidX3D

The fastest and most memory efficient lattice Boltzmann CFD software, running on all GPUs via OpenCL. Free for non-commercial use.
https://youtube.com/@ProjectPhysX
Other
3.77k stars 300 forks source link

Dynamic Derivatives Support? #102

Closed ylf11235 closed 10 months ago

ylf11235 commented 1 year ago

I'm quite capable to use FluidX3D to generate CDrag, CLift, Cside and 3 torques, but having hard time calculate dynamic derivatives since the model was "fixed" in the flow box. Any method to get them? or does it actually support getting dynamic derivatives? Cos they are really important to describe dynamics of a plane.

ProjectPhysX commented 10 months ago

Hi @ylf11235,

for dynamic derivatives, compute not a single simulation but a simulation row of 10-100 simulations; FluidX3D has the performance to do this in a few hours-days. Make a for-loop in main_setup(), each time change a parameter like pitch angle of an aircraft, simulate, compute bordy force/torque, store reults in an array. Memory allocation (creating the lbm object) is required only once; you can in each iteration just reset the density/velocity fields:

parallel_for(lbm.get_N(), [&](ulong n) {
    lbm.rho[n] = 1.0f; // use here whatever startuing conditions you need
    lbm.u.x[n] = 0.0f;
    lbm.u.y[n] = 0.0f;
    lbm.u.z[n] = 0.0f;
    lbm.flags[n] = 0u;
});
lbm.reset(); // reset simulation on GPU (takes effect in following run() call)

When all simulations are done, you have force/torque as a function of some property, and you can do the partial derivative with finite differences, yielding the dynamic derivative.

Kind regards, Moritz