def test_planet_signature(armageddon): """Check planet accepts specified inputs""" inputs = OrderedDict(atmos_func='constant', atmos_filename=None, Cd=1., Ch=0.1, Q=1e7, Cl=1e-3, alpha=0.3, Rp=6371e3, g=9.81, H=8000., rho0=1.2) # call by keyword planet = armageddon.Planet(**inputs) # call by position planet = armageddon.Planet(*inputs.values())
def test_analytical_solution(planet, input_data, armageddon): """Compute analytical solution and compare it with numerical solution. """ # Input constants Cd = 1 H = 8000 rho0 = 1.2 A = np.pi * input_data["radius"]**2 m = 4 / 3 * np.pi * input_data["radius"]**3 * input_data["density"] K = Cd * A * rho0 / (2 * m) # Set the condition for analytical solution another_planet = armageddon.Planet(Cd=1., Ch=0, Q=1e7, Cl=0, alpha=0.3, Rp=math.inf, g=0, H=8000., rho0=1.2) # Calculate the analytical solution and compare it with numerical solution another_result, another_outcome = another_planet.impact(**input_data) analytical_velocity = input_data["velocity"] * np.exp(H*K/np.sin(input_data["angle"]/180*np.pi)\ *(np.exp(- input_data["init_altitude"]/H)-np.exp(-another_result['altitude']/H))) rms = sum((analytical_velocity - another_result['velocity'])**2) rms = math.sqrt(rms / len(analytical_velocity)) assert abs(rms) / input_data["velocity"] < 0.3
def planet_simple(armageddon): """Return a simplified planet for analytical results comparison""" return armageddon.Planet(atmos_func='exponential', atmos_filename=None, Cd=1., Ch=0, Q=1, Cl=0, alpha=0, Rp=np.inf, g=0, H=8000., rho0=1.2)
def test_find_parameter(armageddon): """Compute estimated parameters and compare it with observed value. """ asteroid = armageddon.Planet() e_radius, e_strength = asteroid.find_parameter( filename=os.getcwd() + '/data/ChelyabinskEnergyAltitude.csv') result, outcome = asteroid.impact(radius=e_radius, angle=18.3, strength=e_strength, velocity=19.2e3, density=3300, init_altitude=100e3) energy = pd.read_csv(os.getcwd() + '/data/ChelyabinskEnergyAltitude.csv') burst_attitude = energy['Height (km)'].iloc[ energy['Energy Per Unit Length (kt Km^-1)'].idxmax()] burst_energy = max(energy['Energy Per Unit Length (kt Km^-1)']) assert np.abs(outcome['burst_altitude'] / burst_attitude / 1000 - 1) < 0.2 assert np.abs(outcome['burst_peak_dedz'] / burst_energy - 1) < 0.2
def mars(armageddon): """Return a defalut planet with the parameters of mars""" return armageddon.Planet(atmos_func='mars')
def tabular(armageddon): """Return a defalut planet with a tabulated terrestrial atmosphere""" return armageddon.Planet(atmos_func='tabular', atmos_filename='data/AltitudeDensityTable.csv')
def planet(armageddon): """Return a default planet with a constant atmosphere""" return armageddon.Planet(atmos_func='constant')
def planet(armageddon): """Return a default planet (exponential atmosphere)""" return armageddon.Planet()
import armageddon import matplotlib.pyplot as plt import numpy as np import pandas as pd import time earth = armageddon.Planet() fiducial_impact = {'radius': 10.0, 'angle': 45.0, 'strength': 100000.0, 'velocity': 21000.0, 'density': 3000.0} print('Starting simulation now...') sample_size = 2 for i in range(sample_size): start_time = time.time() ensemble = armageddon.ensemble.solve_ensemble(earth, fiducial_impact, variables=['angle', 'radius', 'strength', 'velocity', 'density'], radians=False, rmin=8, rmax=12) print("--- %s seconds ---" % (time.time() - start_time)) print(ensemble)