mirror of
https://codeberg.org/Yael-II/MSc2-Project-Chaos.git
synced 2026-03-15 04:16:26 +01:00
update
This commit is contained in:
20
Source/energies.py
Normal file
20
Source/energies.py
Normal file
@@ -0,0 +1,20 @@
|
||||
import numpy as np
|
||||
|
||||
def kinetic(W: np.ndarray) -> np.ndarray:
|
||||
"""Computes the kinetic energy.
|
||||
:param W: Phase-space vectors
|
||||
:returns T: Kinetic energy
|
||||
"""
|
||||
U = W[1,0]
|
||||
V = W[1,1]
|
||||
# If U or V is not an array (or a list), but rather a scalar, then we
|
||||
# create a list of one element so that it can work either way
|
||||
if np.ndim(U) == 0: U = np.array([U])
|
||||
if np.ndim(V) == 0: V = np.array([V])
|
||||
|
||||
return (U**2 + V**2)/2
|
||||
|
||||
def total(W: np.ndarray,
|
||||
potential,
|
||||
kinetic = kinetic) -> np.ndarray:
|
||||
return potential(W) + kinetic(W)
|
||||
Reference in New Issue
Block a user