Last active
April 28, 2022 08:20
-
-
Save CanadianBaconBoi/e1bacd3bef9ff7fc1910fa8b18509fc9 to your computer and use it in GitHub Desktop.
[Nuclear Science (Minecraft)] Calculator for determining the outputs of a certain amount of Uranium Hexafluoride. (REQUIRES PYTHON 3.10+)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, math | |
# `REQUIRED` in code | |
process_threshold = 2500 | |
# `processed` in code | |
processed_per_cycle = math.floor(process_threshold/60) | |
# `PERCENT_U235` in code | |
u235_yield = 0.172 | |
# `WASTE_MULTIPLIER` in code | |
waste_yield = 0.1 | |
u238_yield = 1-u235_yield-waste_yield | |
increment_u235 = math.floor(processed_per_cycle*u235_yield) | |
increment_u238 = math.floor(processed_per_cycle*u238_yield) | |
increment_waste = math.floor(processed_per_cycle*waste_yield) | |
def process(uhex, amt_235=0, amt_238=0, amt_waste=0): | |
while uhex >= processed_per_cycle: | |
uhex -= processed_per_cycle | |
amt_235 += increment_u235 | |
amt_238 += increment_u238 | |
amt_waste += increment_waste | |
return amt_235, amt_238, amt_waste | |
def parse_input(argv): | |
if len(argv) > 1: | |
match argv[1][-1]: | |
case ('B'|'b'): | |
match argv[1][-2]: | |
case ('M'|'m'): | |
try: | |
return int(argv[1][:-2]) | |
except: | |
print("invalid input") | |
exit(1) | |
case ('0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'): | |
try: | |
return math.floor(float(argv[1][:-1])*1000) | |
except: | |
print("invalid input") | |
exit(1) | |
case _: | |
print("invalid input") | |
exit(1) | |
case ('0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'): | |
try: | |
print("assuming milibuckets as input, specify B or mB at the end of your number.") | |
return int(argv[1][:-1]) | |
except: | |
print("invalid input") | |
exit(1) | |
case _: | |
print("invalid input") | |
exit(1) | |
else: | |
print("no input, example input: 2500mB, 2.5B") | |
exit(0) | |
if __name__ == "__main__": | |
uhex_amt = parse_input(sys.argv) | |
amt_235, amt_238, amt_waste = process(uhex_amt) | |
print(f"From {uhex_amt}mB UF6") | |
print(f"{int((amt_235-amt_235%2500)/2500)}+{((amt_235%2500)/2500)*100}% U-235") | |
print(f"{int((amt_238-amt_238%2500)/2500)}+{((amt_238%2500)/2500)*100}% U-238") | |
print(f"{int((amt_waste-amt_waste%2500)/2500)}+{((amt_waste%2500)/2500)*100}% Waste") | |
print(f"{uhex_amt%processed_per_cycle}mB leftover UF6") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment