def __init__(self, seed): self.seed = seed random.seed(seed) # Setter et seed for numpy.random klassen self.Var = DFK(["pi", "G", "u", "k", "M_sol", "R_sol" ]) # Definering av forskjellige fysiske konstanter Mission = SpaceMission( self.seed) # Gjør det mulig å hente konstanter fra ast2000 klassen self.M_p = Mission.system.masses[ 0] * self.Var.M_sol # [kg] Massen til hjemplaneten self.R_p = Mission.system.radii[ 0] * 10**3 # [m] Radien til hjemplaneten self.L = 10**-6 # [m] Lengde og bredde på boksen self.T = 10**4 # [K] Temperatur i boksen self.m_H = 2 * 1.00794 * self.Var.u # [kg] Masse til et hydrogenmolekyl self.n = 10**5 # Antall partikler i boksen self.Dt = 10**-9 # [s] Total tid for simulasjonen self.N = 10**3 # Antall steg i simulasjonen self.dt = self.Dt / self.N # [s] Endring i tid for et steg self.n_fri = 0 # Antall molekyler som unnslipper boksen self.p = 0 # Totale mengden bevegelsesmengde som boksen får self.M = 1000 # [kg] Vekta til raketten
''' We are going on a trip in our favorite rocket ship ''' import numpy as np from PIL import Image import matplotlib.pyplot as plt import scipy.interpolate as interpolate import ast2000tools.constants as const import ast2000tools.utils as utils from ast2000tools.space_mission import SpaceMission from ast2000tools.solar_system import SolarSystem from ast2000tools.shortcuts import SpaceMissionShortcuts from programkode_del4_klasse import did_you_just_assume_my_orientation, launching_sequence seed = utils.get_seed('alinerb') mission = SpaceMission(seed) launch = launching_sequence(mission) orient = did_you_just_assume_my_orientation(mission) Ms = mission.system.star_mass M_planet = mission.system.masses G = const.G_sol planet_positions = np.load('planet_positions.npy') planet_velocities = np.load('planet_velocities.npy') timesteps = np.load('times.npy') plan_v_rocket = np.load('optimal_rakett_hastighet.npy') plan_r_rocket = np.load('optimal_rakett_posisjon.npy') plan_t_rocket = np.load('optimal_rakett_tid.npy') pos_planet = interpolate.interp1d(timesteps, planet_positions,
''' This program calculates how hot and dense we... I mean the atmosphere is. ''' import numpy as np import matplotlib.pyplot as plt import ast2000tools.constants as const import scipy.interpolate as interpolate import ast2000tools.utils as utils from ast2000tools.space_mission import SpaceMission from ast2000tools.solar_system import SolarSystem from ast2000tools.shortcuts import SpaceMissionShortcuts from numba import njit import time seed = utils.get_seed('alinerb') mission = SpaceMission(seed) k = const.k_B c = 299792458 m_H = const.m_H2 / 2 def read_the_files(): spectrum_file = open('spectrum_seed64_600nm_3000nm.txt', 'r') sigma_noise_file = open('sigma_noise.txt', 'r') all_wavelenghts = [] F_obs = [] for line in spectrum_file: s = line.split() all_wavelenghts.append(float(s[0]))
from PIL import Image import numpy as np from ast2000tools.space_mission import SpaceMission from sympy import geometry myseed = 82947 mission = SpaceMission(myseed) img = Image.open("sample0000.png") pixels = np.array(img) sky = np.load("himmelkule.npy") fov = [70, 70] xmm = [ -2 * np.sin(fov[1] / 2) / (1 + np.cos(fov[1] / 2)), 2 * np.sin(fov[1] / 2) / (1 + np.cos(fov[1] / 2)), ] ymm = [ -2 * np.sin(fov[1] / 2) / (1 + np.cos(fov[0] / 2)), 2 * np.sin(fov[1] / 2) / (1 + np.cos(fov[0] / 2)), ] x = np.linspace(xmm[0], xmm[1], len(pixels[0, :])) y = np.linspace(xmm[0], xmm[1], len(pixels[:, 0])) X, Y = np.meshgrid(x, y) XY = np.zeros((480, 640, 2)) XY[:, :, 0] = X XY[:, :, 1] = Y proj = np.zeros((360, 480, 640, 3), dtype=np.uint8) for j in range(359): phi0 = j * np.pi / 180 rho = np.sqrt(X**2 + Y**2) c = 2 * np.arctan(rho / 2) theta = np.pi / 2 - np.arcsin(
# egen kode from ast2000tools.space_mission import SpaceMission from ast2000tools.constants import G_sol import numpy as np G = 6.67428e-11 myseed = 82947 mission = SpaceMission(myseed) def trajectory(inital_time, inital_pos, inital_vel, T, steps=10000): """The trajectory of an object through the system Parameters ----------- t : float Initial time for the start of the simulation x : array_like Initial position for the object at the initial time v : array_like Initial velocity of the object T : Float Total simulation time steps : int Total amount of steps in simulation Returns ------- array_like Final time, final position and final velocity """
''' Calculating our planet trajectories analytical and numerical and actually getting a satisfying awnser!! ''' import numpy as np import matplotlib.pyplot as plt import time import ast2000tools.constants as const import ast2000tools.utils as utils from ast2000tools.space_mission import SpaceMission from ast2000tools.solar_system import SolarSystem from numba import njit seed = utils.get_seed('alinerb') system = SolarSystem(seed) mission = SpaceMission(seed) def simulate_orbits(system, rot, n_time_steps_per_year): G = 4*np.pi**2 # in Astronomical uits (AU) a = system.semi_major_axes e = system.eccentricities f = np.linspace(0, 2*np.pi, n_time_steps_per_year) for i in range(system.number_of_planets): r_ = (a[i]*(1-e[i]**2)) / (1 + e[i]*np.cos(np.pi - system.aphelion_angles[i] + f)) x = r_*np.cos(f) y = r_*np.sin(f) plt.plot(x, y) plt.plot(0, 0, 'yo', label = 'Stjerna') plt.legend()
Alternatively it does nothing... ''' import numpy as np from scipy import integrate from sympy import Derivative from numba import njit import ast2000tools.constants as const import ast2000tools.utils as utils import time from ast2000tools.shortcuts import SpaceMissionShortcuts from ast2000tools.space_mission import SpaceMission from ast2000tools.solar_system import SolarSystem seed = utils.get_seed('alinerb') mission = SpaceMission(seed) system = SolarSystem(seed) shortcuts = SpaceMissionShortcuts(mission, [74952]) k = 1.38 * 10**(-23) # Boltzmann-konstanten # m = 2*1.66*10**(-27) # Mass of hydrogen molecule (kg) m = const.m_H2 M = 1100 def combustionchamber(L, T, N, iterations): part_pos = np.zeros((iterations, N, 3)) part_vel = np.zeros((iterations, N, 3)) init_pos = np.random.uniform( -L / 2, L / 2, size=(N, 3)) # initial positions randomly generated init_vel = np.random.normal(0, np.sqrt(
''' This code creates a box, and then adds many boxes to create a rocket engine! Alternatively it does nothing... ''' import numpy as np from scipy import integrate from sympy import Derivative from numba import njit import ast2000tools.constants as const import ast2000tools.utils as utils import time from ast2000tools.shortcuts import SpaceMissionShortcuts from ast2000tools.space_mission import SpaceMission seed = utils.get_seed('alinerb') mission = SpaceMission(seed) shortcuts = SpaceMissionShortcuts(mission, [74952]) k = 1.38 * 10**(-23) # Boltzmann-konstanten # m = 2*1.66*10**(-27) # Mass of hydrogen molecule (kg) m = const.m_H2 M = 1100 def combustionchamber(L, T, N, iterations): part_pos = np.zeros((iterations, N, 3)) part_vel = np.zeros((iterations, N, 3)) init_pos = np.random.uniform(-L/2, L/2, size=(N, 3)) # initial positions randomly generated init_vel = np.random.normal(0, np.sqrt(k*T/m), size=(N, 3)) # initial velocities randomly generated