jmath.physics package¶
Submodules¶
jmath.physics.circuits module¶
jmath/physics/circuits.py
Author: Jordan Hay Date: 2021-06-22
Tools for circuit analysis
- class jmath.physics.circuits.Circuit¶
Bases:
jmath.discrete.Graph
- add_components(*components)¶
Add components to circuit
*components (Components) - Components to add to circuit
- loops()¶
Returns a list of the loops in the circuit around the primary node
- class jmath.physics.circuits.Component(id, weight=0)¶
Bases:
jmath.discrete.Node
- connect(neighbour)¶
Adds a neighbouring component
neighbour (Component) - Neighbouring component to add
- class jmath.physics.circuits.DCSupply(id, voltage, current)¶
- class jmath.physics.circuits.Loop(components)¶
Bases:
jmath.discrete.Loop
- class jmath.physics.circuits.Resistor(id, resistance)¶
Bases:
jmath.physics.circuits.Component
- power(current)¶
Calculate power consumption from current
current (float) - Current in amps flowing through resistor
jmath.physics.mechanics module¶
jmath/physics/mechanics.py
Author: Jordan Hay Date: 2021-06-17
Tools for mechanical systems
- class jmath.physics.mechanics.PhysEnv¶
Bases:
object
Creates an environment for physical objects
Author: Jordan Hay Date: 2021-06-22
- add_object(new_obj)¶
Add a new Physics Object to the environment
- Parameters
new_obj (jmath.physics.mechanics.PhysObj) – Object to add to environment
- Return type
None
- increment_time(increment)¶
Increments the time by the given value
- Parameters
increment (float) – The amount to increase the time by
- Return type
None
- class jmath.physics.mechanics.PhysObj(env, position, velocity, mass=0, charge=0)¶
Bases:
object
Creates an object with physical properties.
- Parameters
env (jmath.physics.mechanics.PhysEnv) – The environment that the object exists in
position (jmath.linearalgebra.vectors.Point) – The initial position of the object
velocity (jmath.linearalgebra.vectors.Vector) – The initial velocity of the object in metres per second
mass (float) – The mass of the object in kilograms
charge (float) – The electric charge of the object in coulombs
- acceleration()¶
Calculates the current acceleration on the object
- Return type
- electrostatic(other)¶
Calculates the force given by charge between two objects
- Parameters
other (jmath.physics.mechanics.PhysObj) – Other physics object
- Return type
- force()¶
Calculates all the forces currently on the object
- Return type
- gravity(other)¶
Calculates the force of gravity between two objects
- Parameters
other (jmath.physics.mechanics.PhysObj) – Other physics object
- Return type
- momentum()¶
Calculates the momentum of the object
- Return type
- update_position(time=0.1)¶
Increments the position kinematically over a time interval. DOES NOT update velocity.
- Parameters
time (float) – The time interval to approximate over.
- update_velocity(time=0.1)¶
Updates the velocity kinematically over a time interval. DOES NOT update position.
- Parameters
time (float) – The time interval to approximate over.
- jmath.physics.mechanics.electrostatic_force(charge1, charge2, distance)¶
Calculates the electrostatic force between two charges
- Parameters
charge1 (float) – The charge in coulombs
charge2 (float) – The other charge in coulombs
distance (float) – The distance between the charges in m
- Return type
float
- jmath.physics.mechanics.gravitational_force(mass1, mass2, distance)¶
Calculates the force of gravity between two masses
- Parameters
mass1 (float) – The mass of one object in kg
mass2 (float) – The mass of the other object in kg
distance (float) – The distance between the objects in m
- Return type
float
- jmath.physics.mechanics.kinematic_position(position, velocity, acceleration, time)¶
Calculates the new position from position, velocity, acceleration, and time
- Parameters
position (jmath.linearalgebra.vectors.Point) – The initial position.
velocity (jmath.linearalgebra.vectors.Vector) – The inital velocity.
acceleration (jmath.linearalgebra.vectors.Vector) – The acceleration.
time (float) – The time to approximate over
- Return type
- jmath.physics.mechanics.kinematic_velocity(velocity, acceleration, time)¶
Calculates the new velocity from velocity, acceleration, and time.
- Parameters
velocity (jmath.linearalgebra.vectors.Vector) – The inital velocity.
acceleration (jmath.linearalgebra.vectors.Vector) – The acceleration.
time (float) – The time to approximate over
- Return type
jmath.physics.prefixes module¶
jmath/physics/prefixes.py
Author: Jordan Hay Date: 2021-07-22
SI prefixes, kilo, yotta etc.
jmath.physics.simulation module¶
Module contents¶
jmath/physics/__init__.py
Tools for physical simulations. By default includes mechanics and prefixes.
Default Packages¶
- jmath.physics.mechanics
Provides tools for modelling mechanical systems, particularly static systems with gravity and electromagnetism.
- jmath.physics.prefixes
Set of SI prefixes used in physics.
Optional Packages¶
- jmath.physics.circuits
Circuit modelling based on jmath.discrete. In development. Not provided by default.
- jmath.physics.simulation
A graphical approach to kinematic/gravitational/charged system modelling.