golfball package

Submodules

golfball.analysis module

golfball.analysis.plot_traj(data, ax=None, **kwargs)[source]

golfball.sim module

3D Golf Ball demo simulation with varying Drag Crisis and Magus Effect.

class golfball.sim.Sim(args=None)[source]

Bases: object

The primary simulation object.

read_inputs(filename)[source]

Read inputs YAML file.

Parameters:

filename (type) – Input YAML file.

Raises:

FileNotFoundError : – Raised if the specified file is not present.

run()[source]

Run the simulation.

write_default_inputs()[source]

Write default parameters to the default input file.

write_outputs()[source]

Write quantities of interest to YAML, and optional traj to HDF5.

write_qoi()[source]

Write Quantities of Interest to YAML.

Parameters:
  • qoi (dict) – Quantities of Interest to write out.

  • filename (str) – name of YAML output file for QoI

write_trajectories(filename)[source]

Save full trajectory to traj_df.h5 HDF5 file.

Parameters:

filename (str) – Name of the output file for the trajectory HDF5.

golfball.sim.calc_drag_coeff(height, vel_mag, l_ref, rho, dimple_size)[source]

Calcualte the Coefficient of Drag (Cd).

Calculate Cd as a function of height, velocity magnitude, reference length, and density. Note: this assumes a Temperature profile from the US Standard ATM, and uses CD

golfball.sim.get_args(arg_list=None)[source]

Make CLI argument parser and parse arguments.

golfball.sim.load_gball_h5(h5_file=None)[source]

Load the saved Pandas DataFrame from the specified HDF5 file.

golfball.sim.main(arg_list=None)[source]

Read in the inputs, run the sim, write out the outputs.

Parameters:

arg_list (list of str, optional) – List of individual commandline arguments to invoke main with. If omitted, the actual commandline arguments will be used.

golfball.stdAtm76 module

Module for querying the 1976 US Standard Atmosphere.

golfball.stdAtm76.getDynViscosity(T)[source]

Return the dynamic viscosity in Pascal-Seconds.

  • of a air (80% N2 20% 02)

  • at a specified temperature in Kelvin.

Inputs

T: int or float (in degrees K)

specified temperature

returns:

Dynamnic viscosity

rtype:

float (in Pa*s)

golfball.stdAtm76.getGeopotential(altitude, units='km', earth_radius=6356.766)[source]

Return the geopotential altitude in the units specified.

Current units supported are ‘m’ and ‘km’

geopot_height = earth_radius * altitude / (earth_radius + altitude)

computations done in km.

golfball.stdAtm76.getReynoldsNumber(velocity, rho, l_ref, temp)[source]

Compute the reynolds number (unitless).

Inputs

velocity: fluid-relative velocity rho: fluid density [kg/m^3] l_ref: reference length [meters] temp: fluid temperature [Kelvin]

golfball.stdAtm76.getSpeedOfSound(altitude=0.0, units='km')[source]

Calculate the speed of sound.

Assumes units are ‘km’, unless otherwise specified in ‘m’.

golfball.stdAtm76.getStandardDensity(altitude=0.0, units='km')[source]

Get the Standard Density given an altitude.

Returns density as a function of altitude from the Standard Pressure and Standard Temperature using the Ideal Gas Law

golfball.stdAtm76.getStandardPressure(altitude=0.0, units='km')[source]

Get the standard Pressure given an altitude.

Below 51 km: Practical Meteorology by Roland Stull, pg 12 Above 51 km: http://www.braeunig.us/space/atmmodel.htm

Validation data: https://www.avs.org/AVS/files/c7/c7edaedb-95b2-438f-adfb-36de54f87b9e.pdf

golfball.stdAtm76.getStandardTemperature(geopot_height=0.0)[source]

Get the Standard Temparature from a given Geopotential Height.

Standard atmospheric temperature, in kelvins (273.15 + Celsius) Below 51 km: Practical Meteorology by Roland Stull, pg 12 Above 51 km: http://www.braeunig.us/space/atmmodel.htm

Module contents

golfball is a Simple 2D Golf Ball Trajectory Simulation in Python.

class golfball.Sim(args=None)[source]

Bases: object

The primary simulation object.

read_inputs(filename)[source]

Read inputs YAML file.

Parameters:

filename (type) – Input YAML file.

Raises:

FileNotFoundError : – Raised if the specified file is not present.

run()[source]

Run the simulation.

write_default_inputs()[source]

Write default parameters to the default input file.

write_outputs()[source]

Write quantities of interest to YAML, and optional traj to HDF5.

write_qoi()[source]

Write Quantities of Interest to YAML.

Parameters:
  • qoi (dict) – Quantities of Interest to write out.

  • filename (str) – name of YAML output file for QoI

write_trajectories(filename)[source]

Save full trajectory to traj_df.h5 HDF5 file.

Parameters:

filename (str) – Name of the output file for the trajectory HDF5.

golfball.load_gball_h5(h5_file=None)[source]

Load the saved Pandas DataFrame from the specified HDF5 file.

golfball.main(arg_list=None)[source]

Read in the inputs, run the sim, write out the outputs.

Parameters:

arg_list (list of str, optional) – List of individual commandline arguments to invoke main with. If omitted, the actual commandline arguments will be used.