View difference between Paste ID: E0j6uW3v and m1eYdj91
SHOW: | | - or go back to the newest paste.
1
# Thruster calculator for Dual Universe
2
# Originally osted by Bananabird at https://pastebin.com/m1eYdj91 and to the DU General chat.
3
4
from math import ceil
5
6
##############
7
# User Input #
8
##############
9
# Mass
10
mass_ship = 5000 #kg of the ship frame (+ estimated adjustor/retro-rocket/fuel mass)
11
mass_rated = 5000 #kg of desired max cargo mass
12
mass = mass_ship + mass_rated
13
14
# Properties for type A thrusters (hover/atmo/space)
15
# Example: you could plug in the values for a large atmospheric engine here. Try requesting 3g of acceleration.
16
typeA_name = "Atmo"
17
accel_typeA = 3*9.8 #m/s2
18
mass_per_typeA = 100 #kg
19
force_per_typeA = 20000 #N
20
21
# Properties for type B thrusters (hover/atmo/space)
22
# Example: you could plug in the values for a large space engine here. Try requesting 3g of acceleration.
23
typeB_name = "Space"
24
accel_typeB = 3*9.8 #m/s2
25
mass_per_typeB = 300 #kg
26
force_per_typeB = 60000 #N
27
28
################
29
# Calculations #
30
################
31
# F = ma
32
# T = Num of Thrusters Needed
33
# m = m + T*Tm
34
# TF = ma
35
# T = (m*a) / (F - a*Tm)
36
num_typeA = ceil((mass * accel_typeA) / (force_per_typeA - accel_typeA * mass_per_typeA))
37
num_typeB = ceil((mass * accel_typeB) / (force_per_typeB - accel_typeB * mass_per_typeB))
38
print("Solutions, not including the weight of the other solution's thrusters:")
39
print("Num {0} Thrusters = {1}".format(typeA_name, num_typeA))
40
print("Num {0} Thrusters = {1}".format(typeB_name, num_typeB))
41
        
42
for i in range(100):
43
    imass = mass + (num_typeA * mass_per_typeA) + (num_typeB * mass_per_typeB)
44
    inum_typeA = ceil((imass * accel_typeA) / (force_per_typeA - accel_typeA * mass_per_typeA))
45
    inum_typeB = ceil((imass * accel_typeB) / (force_per_typeB - accel_typeB * mass_per_typeB))
46
    
47
    if (inum_typeA == num_typeA and inum_typeB == num_typeB):
48
        print()
49
        print("Solutions, with the weight of each other's thrusters accounted for:")
50
        print("Num {0} Thrusters = {1}".format(typeA_name, num_typeA))
51
        print("Num {0} Thrusters = {1}".format(typeB_name, num_typeB))
52
        exit()
53
    elif (inum_typeA < 0 or inum_typeB < 0):
54
        break;
55
    else:
56
        num_typeA = inum_typeA
57
        num_typeB = inum_typeB
58
        print()
59
        print("Converging i={}:".format(i))
60
        print("Num {0} Thrusters = {1}".format(typeA_name, num_typeA))
61
        print("Num {0} Thrusters = {1}".format(typeB_name, num_typeB))
62
63
print()
64
print("There is no amount of thrusters that can give you those acceleration values")
65
exit()