You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When performing a propeller rotational motion, I define a rotational motion around the x-axis with a rotational speed of 4145r/min, but in the voxelized motion, instead of following a fixed x-axis, the propeller will rotate periodically off-center, what is the cause of this, and how can I fix it?
My code is as follows
voidmain_setup() { // NACA X-57 lift propeller; required extensions in defines.hpp: FP16C, EQUILIBRIUM_BOUNDARIES, MOVING_BOUNDARIES, SUBGRID, INTERACTIVE_GRAPHICS or GRAPHICS// ################################################################## define simulation box size, viscosity and volume force ###################################################################constuint3lbm_N=resolution(float3(2.0f, 1.0f, 1.0f), 4000u); // input: simulation box aspect ratio and VRAM occupation in MB, output: grid resolutionconstfloatlbm_u=0.11f;
constfloatlbm_length=0.5f*(float)lbm_N.x;
constfloatsi_n=4145.0f; //RPM of propellerconstfloatsi_n_t=20.0f;
constfloatsi_T= (60.0f/si_n)si_n_t; // 20 revolutions of the propellerconstuintlbm_dt=30u; // revoxelize rotor every dt time stepsconstfloatsi_length=0.984f;
constfloatsi_J=0.6f; // Advance ratioconstfloatsi_D=0.57592f; //propeller radiusconstfloatsi_u=si_Jsi_D*(si_n/60.0f); //airspeedconstfloatsi_w_u= (si_npif/30.0f)(si_D0.5f); //propeller linear velocityconstfloatsi_nu=1.48E-5f, si_rho=1.225f;
units.set_m_kg_s(lbm_length, lbm_u, 1.0f, si_length, si_u, si_rho);
print_info("lbm_u="+to_string(units.u(si_u)));
LBMlbm(lbm_N, 1u, 1u, 1u, units.nu(si_nu));
// ###################################################################################### define geometry ######################################################################################Meshfuselage=read_stl(get_exe_path()+"../stl/propeller_fuselage_semi.stl"); //Mesh*propeller=read_stl(get_exe_path()+"../stl/propeller_semi.stl"); //constfloatscale=lbm_length/fuselage->get_bounding_box_size().x; // scale body and rotors to simulation box sizefuselage->scale(scale);
propeller->scale(scale);
constfloat3offset=lbm.center()-fuselage->get_bounding_box_center(); // move body and rotors to simulation box centerfuselage->translate(offset);
propeller->translate(offset);
fuselage->set_center(fuselage->get_bounding_box_center()); // set center of meshes to their bounding box centerpropeller->set_center(propeller->get_bounding_box_center());
print_info("diameter="+to_string(units.x(si_D)));
print_info("propeller_max_size="+to_string(propeller->get_max_size()));
constfloatpropeller_radius=0.5funits.x(si_D), propeller_omega=(units.si_u(si_w_u))/(propeller_radius), propeller_domega=propeller_omega(float)lbm_dt;
lbm.voxelize_mesh_on_device(fuselage);
//lbm.voxelize_mesh_on_device(propeller, TYPE_S, propeller->get_center(), float3(0.0f), float3(propeller_omega, 0.0f, 0.0f)); // revoxelize mesh on GPUconstuintNx=lbm.get_Nx(), Ny=lbm.get_Ny(), Nz=lbm.get_Nz(); parallel_for(lbm.get_N(), [&](ulongn) { uintx=0u, y=0u, z=0u; lbm.coordinates(n, x, y, z);
if(lbm.flags[n]!=TYPE_S) lbm.u.x[n] =lbm_u;
if(x==0u||x==Nx-1u||y==0u||y==Ny-1u||z==0u||z==Nz-1u) lbm.flags[n] =TYPE_E; // all non periodic
}); // ####################################################################### run simulation, export images and data ##########################################################################lbm.graphics.visualization_modes=VIS_FLAG_SURFACE|VIS_Q_CRITERION;
lbm.run(0u); // initialize simulationwhile(lbm.get_t()<=units.t(si_T)) { // main simulation looplbm.voxelize_mesh_on_device(propeller, TYPE_S, propeller->get_center(), float3(0.0f), float3(propeller_omega, 0.0f, 0.0f)); // revoxelize mesh on GPUlbm.run(lbm_dt); // run dt time stepspropeller->rotate(float3x3(float3(1.0f, 0.0f, 0.0f), propeller_domega)); // rotate mesh#if defined(GRAPHICS) && !defined(INTERACTIVE_GRAPHICS)
if(lbm.graphics.next_frame(units.t(si_T), 10.0f)) {
lbm.graphics.set_camera_free(float3(0.528513f*(float)Nx, 0.102095f*(float)Ny, 1.302283f*(float)Nz), 16.0f, 47.0f, 96.0f);
lbm.graphics.write_frame(get_exe_path()+"export/a/");
lbm.graphics.set_camera_free(float3(0.0f*(float)Nx, -0.114244f*(float)Ny, 0.543265f*(float)Nz), 90.0f+degrees((float)lbm.get_t()/(float)lbm_dtmain_domega), 36.0f, 120.0f);
lbm.graphics.write_frame(get_exe_path()+"export/b/");
lbm.graphics.set_camera_free(float3(0.557719f(float)Nx, -0.503388f*(float)Ny, -0.591976f*(float)Nz), -43.0f, -21.0f, 75.0f);
lbm.graphics.write_frame(get_exe_path()+"export/c/");
lbm.graphics.set_camera_centered(58.0f, 9.0f, 88.0f, 1.648722f);
lbm.graphics.write_frame(get_exe_path()+"export/d/");
lbm.graphics.set_camera_centered(0.0f, 90.0f, 100.0f, 1.100000f);
lbm.graphics.write_frame(get_exe_path()+"export/e/");
lbm.graphics.set_camera_free(float3(0.001612f*(float)Nx, 0.523852f*(float)Ny, 0.992613f*(float)Nz), 90.0f, 37.0f, 94.0f);
lbm.graphics.write_frame(get_exe_path()+"export/f/");
}
#endif// GRAPHICS && !INTERACTIVE_GRAPHICS
}
}
The text was updated successfully, but these errors were encountered:
when you load an .stl mesh, by default the (rotation) center of the mesh is set to the center of its bounding box. This is correct for 2- or 4-bladed propellers, but fails for 3- or 5-bladed propellers; their rotation center is offset from the bounding box center. Here an illustration:
You can figure out this offset with some geometry.
The solution is to manually correct the position of the mesh center, with
When performing a propeller rotational motion, I define a rotational motion around the x-axis with a rotational speed of 4145r/min, but in the voxelized motion, instead of following a fixed x-axis, the propeller will rotate periodically off-center, what is the cause of this, and how can I fix it?
![image](https://private-user-images.githubusercontent.com/160718220/313265747-a440e789-e3f6-4e45-a6a0-8fc4c37f2b07.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNDQ5MTIsIm5iZiI6MTcyMTI0NDYxMiwicGF0aCI6Ii8xNjA3MTgyMjAvMzEzMjY1NzQ3LWE0NDBlNzg5LWUzZjYtNGU0NS1hNmEwLThmYzRjMzdmMm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4NzkxOGViODNjYmFkYjllMDliMDdjMGEwNmYwZmM2OTk5ZWNjY2UxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.UPHjJ-RRfsspQ-vASCG3kwkJe7jMHz9jD-aD-TBhT1M)
![image](https://private-user-images.githubusercontent.com/160718220/313265907-9fa11cd0-6892-4b49-8d5a-055108ecda3a.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjEyNDQ5MTIsIm5iZiI6MTcyMTI0NDYxMiwicGF0aCI6Ii8xNjA3MTgyMjAvMzEzMjY1OTA3LTlmYTExY2QwLTY4OTItNGI0OS04ZDVhLTA1NTEwOGVjZGEzYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNzE3JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDcxN1QxOTMwMTJaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT03MDJlZDg4ODY1Mjg2NGMwMDVlZDA2ZWJkOTVlOTk2NDFkNWU4NmIwMTE2ODVkOTA0MWU5YTIwNDY2YjVkYjhjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.Qo-jIEtU33ZghNTdGDfoX601mPT_XFBqiP5Xal4Hdxc)
My code is as follows
The text was updated successfully, but these errors were encountered: