Skip to content

Commit

Permalink
physics: force refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
philiplinden committed Nov 17, 2024
1 parent aac9d94 commit 89180a6
Show file tree
Hide file tree
Showing 15 changed files with 549 additions and 399 deletions.
20 changes: 12 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,25 @@ dev_native = [
# Enable system information plugin for native dev builds.
"bevy/sysinfo_plugin",
]
configs = ["ron", "bevy_common_assets"]
config-files = ["ron", "bevy_common_assets", "serde"]
inspect = ["bevy-inspector-egui"]

[dependencies]
# required dependencies
avian3d = { version = "0.1.2", features = ["debug-plugin"] }
# core dependencies
bevy = "0.14.2"
bevy-trait-query = "0.6.0"
iyes_perf_ui = { version = "0.3.0" }
rand = "0.8.5"
serde = { version = "1.0", features = ["derive"] }
# optional dependencies
ron = { version = "0.8.1", optional = true }
bevy_common_assets = { version = "0.11.0", features = ["ron"], optional = true }
# physics dependencies
avian3d = { version = "0.1.2", features = ["debug-plugin"] }
rayon = "1.10.0"
# ui dependencies
bevy-inspector-egui = { version = "0.27.0", features = ["highlight_changes"], optional = true }
bevy_prototype_debug_lines = { version = "0.12.0", features = ["3d"] }
iyes_perf_ui = { version = "0.3.0" }
# file io dependencies
bevy_common_assets = { version = "0.11.0", features = ["ron"], optional = true }
ron = { version = "0.8.1", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }

[[bin]]
name = "yahs"
Expand Down
17 changes: 17 additions & 0 deletions docs/devlog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# development log

## 2024-11-18

Iterating with AI on the drag calculations. It is set up to perform a raycast
along the velocity vector and compute the drag as a function of the angle of
attack. Each raycast hits a point on the surface of the collider and the normal
and differential area is used to compute the drag force for each one.

- Split the `forces` module into `body` and `aero`. The base `forces` module
contains the common code for all forces.
- Added `AeroPlugin` for computing drag on solid bodies.
- Added `BodyForcesPlugin` that deals with forces related to the mass and
volume of the rigid bodies.
- Added `ForceVisualizationPlugin` for visualizing the forces as vectors in the
scene.
- Moved serde features behind the `config-files` feature flag. I'm hoping to
pare down the default dependencies for the project.

## 2024-11-17

Time to see what's going on with the forces through some new UIs instead of
Expand Down
13 changes: 5 additions & 8 deletions docs/drag.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Summary of [Newtonian Aerodynamics for General Body Shapes](https://ntrs.nasa.gov/citations/19660012440)
# Aerodynamic Drag Calculations
This is a summary of the paper
[Newtonian Aerodynamics for General Body Shapes](https://ntrs.nasa.gov/citations/19660012440)
and its implementation in our simulation. It is generated using ChatGPT
`o1-mini`.

## 1. Introduction to Newtonian Aerodynamics
Newtonian Aerodynamics applies Newtonian mechanics to predict aerodynamic forces
Expand Down Expand Up @@ -97,10 +101,3 @@ the implemented models.
of all sampled points to compute total drag and lift forces.
5. **Normalization and Scaling**: Adjust the computed forces based on fluid
density and relative velocity squared.

## 9. Recommendations for Your Simulation
- Implement robust surface sampling methods.
- Calculate actual differential areas for more accurate drag force computation.
- Incorporate correction factors for drag coefficients based on flow conditions.
- Optimize the number of surface sample points for performance.
- Validate simulation results against experimental data.
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// mod assets;
mod simulator;
mod scene;
mod ui;
#[cfg(feature = "config-files")]
mod assets;

use bevy::{asset::AssetMetaCheck, prelude::*};

Expand Down
87 changes: 0 additions & 87 deletions src/simulator/aero.rs

This file was deleted.

7 changes: 5 additions & 2 deletions src/simulator/balloon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
use avian3d::prelude::*;
use bevy::prelude::*;
use serde::Deserialize;
#[cfg(feature = "config-files")]
use serde::{Deserialize, Serialize};

use super::{
ideal_gas::{GasSpecies, IdealGasBundle},
Expand All @@ -28,7 +29,8 @@ pub struct BalloonBundle {
pub pbr: PbrBundle,
}

#[derive(Debug, Deserialize, Clone, PartialEq, Reflect)]
#[derive(Debug, Clone, PartialEq, Reflect)]
#[cfg_attr(feature = "config-files", derive(Serialize, Deserialize))]
pub struct BalloonMaterial {
pub name: String,
pub max_temperature: f32, // temperature (K) where the given material fails
Expand Down Expand Up @@ -64,6 +66,7 @@ impl Default for BalloonMaterial {
/// Balloon properties. The balloon always conforms to the surface of a
/// collider. It does not have its own rigid body.
#[derive(Component, Reflect)]
#[cfg_attr(feature = "config-files", derive(Serialize, Deserialize))]
pub struct Balloon {
/// Balloon material type
pub skin_material: BalloonMaterial,
Expand Down
Loading

0 comments on commit 89180a6

Please sign in to comment.