Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Thruster calculator for Dual Universe
- # Originally osted by Bananabird at https://pastebin.com/m1eYdj91 and to the DU General chat.
- from math import ceil
- ##############
- # User Input #
- ##############
- # Mass
- mass_ship = 5000 #kg of the ship frame (+ estimated adjustor/retro-rocket/fuel mass)
- mass_rated = 5000 #kg of desired max cargo mass
- mass = mass_ship + mass_rated
- # Properties for type A thrusters (hover/atmo/space)
- # Example: you could plug in the values for a large atmospheric engine here. Try requesting 3g of acceleration.
- typeA_name = "Atmo"
- accel_typeA = 3*9.8 #m/s2
- mass_per_typeA = 100 #kg
- force_per_typeA = 20000 #N
- # Properties for type B thrusters (hover/atmo/space)
- # Example: you could plug in the values for a large space engine here. Try requesting 3g of acceleration.
- typeB_name = "Space"
- accel_typeB = 3*9.8 #m/s2
- mass_per_typeB = 300 #kg
- force_per_typeB = 60000 #N
- ################
- # Calculations #
- ################
- # F = ma
- # T = Num of Thrusters Needed
- # m = m + T*Tm
- # TF = ma
- # T = (m*a) / (F - a*Tm)
- num_typeA = ceil((mass * accel_typeA) / (force_per_typeA - accel_typeA * mass_per_typeA))
- num_typeB = ceil((mass * accel_typeB) / (force_per_typeB - accel_typeB * mass_per_typeB))
- print("Solutions, not including the weight of the other solution's thrusters:")
- print("Num {0} Thrusters = {1}".format(typeA_name, num_typeA))
- print("Num {0} Thrusters = {1}".format(typeB_name, num_typeB))
- for i in range(100):
- imass = mass + (num_typeA * mass_per_typeA) + (num_typeB * mass_per_typeB)
- inum_typeA = ceil((imass * accel_typeA) / (force_per_typeA - accel_typeA * mass_per_typeA))
- inum_typeB = ceil((imass * accel_typeB) / (force_per_typeB - accel_typeB * mass_per_typeB))
- if (inum_typeA == num_typeA and inum_typeB == num_typeB):
- print()
- print("Solutions, with the weight of each other's thrusters accounted for:")
- print("Num {0} Thrusters = {1}".format(typeA_name, num_typeA))
- print("Num {0} Thrusters = {1}".format(typeB_name, num_typeB))
- exit()
- elif (inum_typeA < 0 or inum_typeB < 0):
- break;
- else:
- num_typeA = inum_typeA
- num_typeB = inum_typeB
- print()
- print("Converging i={}:".format(i))
- print("Num {0} Thrusters = {1}".format(typeA_name, num_typeA))
- print("Num {0} Thrusters = {1}".format(typeB_name, num_typeB))
- print()
- print("There is no amount of thrusters that can give you those acceleration values")
- exit()
Add Comment
Please, Sign In to add comment