DragModel
drag_model
¶
Drag model implementations for ballistic projectiles.
This module provides classes and functions for modeling aerodynamic drag of projectiles, including single and multi-BC (ballistic coefficient) models. Supports standard drag tables and custom drag data points.
Key Components
- DragDataPoint: Individual drag coefficient at specific Mach number
- BCPoint: Ballistic coefficient point for multi-BC models
- DragModel: Primary drag model with ballistic coefficient and drag table
- DragModelMultiBC: Multi-BC drag model for varying ballistic coefficients
Functions:
| Name | Description |
|---|---|
- make_data_points |
Convert drag table data to DragDataPoint objects |
- sectional_density |
Calculate sectional density from weight and diameter |
- linear_interpolation |
Linear interpolation utility function |
The drag models use standard ballistic reference tables (G1, G7, etc.) and allow for custom drag functions based on Mach number vs drag coefficient data.
Classes:
| Name | Description |
|---|---|
DragDataPoint |
Drag coefficient at a specific Mach number. |
DragModel |
Aerodynamic drag model for ballistic projectiles. |
BCPoint |
Ballistic coefficient point for multi-BC drag models. |
DragDataPoint
dataclass
¶
DragModel
¶
DragModel(
bc: float,
drag_table: DragTableDataType,
weight: Union[float, Weight] = 0,
diameter: Union[float, Distance] = 0,
length: Union[float, Distance] = 0,
)
Aerodynamic drag model for ballistic projectiles.
Represents the drag characteristics of a projectile using a ballistic coefficient and drag table.
The ballistic coefficient (BC) is defined as: BC = weight / (diameter^2 * form_factor) where weight is in pounds, diameter is in inches, and form_factor is relative to the selected drag model.
Attributes:
| Name | Type | Description |
|---|---|---|
BC |
Ballistic coefficient (scales drag model for a particular projectile) |
|
drag_table |
List of DragDataPoint objects defining Mach vs CD |
|
weight |
Projectile weight (only needed for spin drift calculations) |
|
diameter |
Projectile diameter (only needed for spin drift calculations) |
|
length |
Projectile length (only needed for spin drift calculations) |
|
sectional_density |
Calculated sectional density (lb/in²) |
|
form_factor |
Calculated form factor (dimensionless) |
Note
The weight, diameter, and length parameters are only required when computing spin drift. For basic trajectory calculations, only BC and drag_table are needed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bc
|
float
|
Ballistic coefficient |
required |
drag_table
|
DragTableDataType
|
Either list of DragDataPoint objects or list of dictionaries with 'Mach' and 'CD' keys |
required |
weight
|
Union[float, Weight]
|
Projectile weight in grains (default: 0) |
0
|
diameter
|
Union[float, Distance]
|
Projectile diameter in inches (default: 0) |
0
|
length
|
Union[float, Distance]
|
Projectile length in inches (default: 0) |
0
|
Examples:
# Constant drag curve with C_d = 0.3:
dm = DragModel(1, [DragDataPoint(1, 0.3)])
from py_ballisticcalc.drag_tables import TableG7
# Standard 155gr OTM bullet:
dm = DragModel(0.23, TableG7, weight=155, diameter=0.308, length=1.2)
Raises:
| Type | Description |
|---|---|
ValueError
|
If BC is not positive or drag_table is empty |
TypeError
|
If drag_table format is invalid |
Source code in py_ballisticcalc/drag_model.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | |
BCPoint
dataclass
¶
Ballistic coefficient point for multi-BC drag models.
Represents a single ballistic coefficient at a specific velocity or Mach number.
Sorts by Mach number for constructing drag models (see DragModelMultiBC).
Attributes:
| Name | Type | Description |
|---|---|---|
BC |
float
|
Ballistic coefficient |
Mach |
float
|
Mach number corresponding to this BC measurement |
V |
Optional[Velocity]
|
Velocity corresponding to this BC measurement (optional) |
Examples:
# Create a BCPoint with BC=0.5 at Mach 2.0
point1 = BCPoint(BC=0.5, Mach=2.0)
# Create a BCPoint with BC=0.4 at 1500fps
point2 = BCPoint(BC=0.4, V=Velocity.FPS(1500))
# Sort points by Mach number
points = [point2, point1]
points.sort() # point1 will come before point2 since Mach 2.0 < Mach at 1500fps
Note
Either Mach or V must be specified, but not both. If V is provided then Mach
will be calculated automatically using standard atmospheric conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
BC
|
float
|
Ballistic coefficient (must be positive) |
required |
Mach
|
Optional[float]
|
Mach number (optional, mutually exclusive with |
None
|
V
|
Optional[Union[float, Velocity]]
|
Velocity (optional, mutually exclusive with |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in py_ballisticcalc/drag_model.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
DragModelMultiBC
¶
DragModelMultiBC(
bc_points: List[BCPoint],
drag_table: DragTableDataType,
weight: Union[float, Weight] = 0,
diameter: Union[float, Distance] = 0,
length: Union[float, Distance] = 0,
) -> DragModel
Create a drag model with multiple ballistic coefficients.
Constructs a DragModel using multiple BC measurements at different velocities, interpolating between them to create a more accurate drag function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bc_points
|
List[BCPoint]
|
List of BCPoint objects with BC measurements at specific velocities |
required |
drag_table
|
DragTableDataType
|
Standard drag table (G1, G7, etc.) or custom drag data |
required |
weight
|
Union[float, Weight]
|
Projectile weight in grains (default: 0) |
0
|
diameter
|
Union[float, Distance]
|
Projectile diameter in inches (default: 0) |
0
|
length
|
Union[float, Distance]
|
Projectile length in inches (default: 0) |
0
|
Returns:
| Type | Description |
|---|---|
DragModel
|
DragModel with interpolated drag coefficients based on multiple BCs |
Example
from py_ballisticcalc.drag_tables import TableG7
DragModelMultiBC([BCPoint(.21, V=Velocity.FPS(1500)), BCPoint(.22, V=Velocity.FPS(2500))],
drag_table=TableG7)
Note
If weight and diameter are provided, BC is set to sectional density. Otherwise, BC=1 and the drag_table contains final drag terms. BC points are automatically sorted by Mach number for interpolation.
Source code in py_ballisticcalc/drag_model.py
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 | |