/
talehunter
/
ballistics
Обзор
Документация
Войти
/
talehunter
/
ballistics
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
main.py
238 строк
7 KB
talehunter
autoformat
24 ноя 2025, 10:53
24 ноя 2025, 10:53
924c8ec
Код
Авторство
О чём код?
import configparser import numpy as np from consts import ( RE, RSE, RSJ, MSUN, ME, MJ, REO, RJOP, RJOA, P1G, E1G, E2G, THETTAG1, THETTAG2, ) from graphics import draw_first, draw_second from scipy.optimize import fsolve from mathematic import v_001, v_002, alpha1, alpha2 from word import create_basic_report class Homman: def calc(self): # Гоммановский перелет e1 = (RSJ - RSE) / (RSJ + RSE) print(e1) p1 = RSJ * (1 - e1) print(p1) Va1 = (MSUN / p1) ** 0.5 * (1 - e1) print(Va1) Vp1 = (MSUN / p1) ** 0.5 * (1 + e1) print(Vp1) Ve = (MSUN / RSE) ** 0.5 print(Ve) dV1 = Vp1 - Ve print(dV1) Vj = (MSUN / RSJ) ** 0.5 print(Vj) dV2 = Vj - Va1 print(dV2) Vg = dV1 + dV2 print(Vg) # отлет КА от Земли Veop = (ME / REO) ** 0.5 print(Veop) Votl = (dV1**2 + (2 * ME / REO)) ** 0.5 print(Votl) detlaVe = Votl - Veop print(detlaVe) # промежуточная орбита вокруг Юпитера Vpril = (dV2**2 + (2 * MJ / RJOP)) ** 0.5 print(Vpril) ej = (RJOA - RJOP) / (RJOA + RJOP) print(ej) pj = RJOA * (1 - ej) print(pj) Vaj = (MJ / pj) ** 0.5 * (1 - ej) print(Vaj) Vpj = (MJ / pj) ** 0.5 * (1 + ej) print(Vpj) delta_V12 = Vpril - Vpj print(delta_V12) T1 = (((p1 / (1 - e1**2)) ** 3 / MSUN) ** 0.5 * np.pi) / (60 * 60 * 24 * 365) config = configparser.ConfigParser() config.read("config.ini") config["Data"]["e1"] = str(e1) config["Data"]["p1"] = str(p1) config["Data"]["Ve"] = str(Ve) config["Data"]["Veop"] = str(Veop) config["Data"]["Vg"] = str(Vg) config["Data"]["T1"] = str(T1) config["Data"]["Vj"] = str(Vj) config["Data"]["Vpj"] = str(Vpj) with open("config.ini", "w") as configfile: config.write(configfile) draw_first() class Grav_flight: def get_data(self): config = configparser.ConfigParser() config.read("config.ini") Ve = float(config["Data"]["Ve"]) Veop = float(config["Data"]["Veop"]) Ra2 = float(config["Data"]["Ra2"]) return [Ve, Veop, Ra2] def equation(self, Ra2s, Rp2, n): time_seconds = 2 * 365 * 24 * 60 * 60 result = (np.cbrt(((time_seconds / (2 * np.pi)) ** 2) * MSUN)) * 2 - Rp2 return result def calc(self): n = 2 Rp2 = RSE print(Rp2) Ra2 = self.equation(0, Rp2, n) Ra2 = round(Ra2, 5) print(f"Апогей орбиты: {Ra2:.2e} км") config = configparser.ConfigParser() config.read("config.ini") config["Data"]["Ra2"] = str(Ra2) with open("config.ini", "w") as configfile: config.write(configfile) e2 = (Ra2 - Rp2) / (Ra2 + Rp2) print(f"e2:{e2}") p2 = Ra2 * (1 - e2) print(f"p2:{p2}") Va2 = np.sqrt(MSUN / p2) * (1 - e2) print(f"Va2:{Va2}") Vp2 = np.sqrt(MSUN / p2) * (1 + e2) print(f"Vp2:{Vp2}") Ve = self.get_data()[0] Veop = self.get_data()[1] dV22 = Vp2 - Ve print(f"dV22:{dV22}") Votl2 = np.sqrt(dV22**2 + 2 * (ME / REO)) print(f"Votl2:{Votl2}") delta_V21 = Votl2 - Veop print(f"delta_V21:{delta_V21}") config = configparser.ConfigParser() config.read("config.ini") config["Data"]["Va2"] = str(Va2) config["Data"]["dV21"] = str(delta_V21) with open("config.ini", "w") as configfile: config.write(configfile) self.second_graph() # гравитационный маневр у Земли def second_graph(self): Ve = self.get_data()[0] Ra2 = self.get_data()[2] Heobl = 559 R = RE + Heobl print(R) config = configparser.ConfigParser() config.read("config.ini") config["Data"]["Ra2"] = str(Ra2) config["Data"]["Ve"] = str(Ve) config["Data"]["R"] = str(R) with open("config.ini", "w") as configfile: config.write(configfile) draw_second() class Passive_grav_condition: # Условие существования пассивного гравитационного маневра def equations_1(self, args): theta1, theta2 = args eq1 = v_001(theta1) - v_002(theta2) eq2 = alpha1(theta1, theta2) - alpha2(theta1) return [eq1, eq2] def equations_2(self, args): i, theta2 = args eq1 = v_002(theta2) - i return eq1 def calc(self): # Первое начальное приближение: θ1 = 0.7, θ2 = 0.2 print("Решение 1:") args = [0.7, 0.2] solution1 = fsolve(self.equations_1, args) theta1_sol1, theta2_sol1 = solution1 print(f"θ1 = {theta1_sol1:.6f}") print(f"θ2 = {theta2_sol1:.6f}") # Второе начальное приближение: θ1 = 1.5, θ2 = 2.0 print("Решение 2:") args = [1.5, 2.0] solution2 = fsolve(self.equations_1, args) theta1_sol2, theta2_sol2 = solution2 class Fuel_costs: def get_data(self): config = configparser.ConfigParser() config.read("config.ini") Va2 = float(config["Data"]["Va2"]) Vj = float(config["Data"]["Vj"]) Vpj = float(config["Data"]["Vpj"]) dV21 = float(config["Data"]["dV21"]) Ra2 = float(config["Data"]["Ra2"]) return [Va2, Vj, Vpj, dV21, Ra2] def calc(self): Va2 = self.get_data()[0] Vj = self.get_data()[1] Vpj = self.get_data()[2] dV21 = self.get_data()[3] Ra2 = self.get_data()[4] dV1 = Va2 - (MSUN / P1G) ** 0.5 * (1 - E1G) print(dV1) dV2 = ((Vj - (MSUN / P1G) ** 0.5 * (1 - E2G)) ** 2 + 2 * MJ / RJOP) ** 0.5 - Vpj print(dV2) dVsum = dV1 + dV2 + dV21 print(dVsum) k1 = np.sqrt(((Ra2 + RSE) / 2) ** 3 / MSUN) * np.pi k2 = np.sqrt((Ra2 / (1 + E1G)) ** 3 / MSUN) k3 = np.sqrt((RSJ / (1 + E2G)) ** 3 / MSUN) t1 = np.arccos((np.cos(THETTAG1) + E1G) / (1 + E1G * np.cos(THETTAG1))) t2 = np.arccos((np.cos(THETTAG2) + E2G) / (1 + E2G * np.cos(THETTAG2))) Tg = ( k1 + k2 * np.pi + k2 * (t1 - E1G * np.sin(t1)) + k3 * np.pi + k3 * (t2 - E2G * np.sin(t2)) ) / (3600 * 24 * 365) print(Tg) config = configparser.ConfigParser() config.read("config.ini") config["Data"]["dVg"] = str(dVsum) config["Data"]["Tg"] = str(Tg) with open("config.ini", "w") as configfile: config.write(configfile) def main(): homman = Homman() homman.calc() obj = Grav_flight() obj.calc() obj = Passive_grav_condition() obj.calc() obj = Fuel_costs() obj.calc() create_basic_report() if __name__ == "__main__": main()