[ create a new paste ] login | about

Link: http://codepad.org/7uTykSPj    [ raw code | output | fork ]

Python, pasted on Oct 25:
LEAK_RATE = 0.125   #from the source
minutes = 0
new_pollutant1 = 0
new_pollutant2 = 0
new_pollutant3 = 0

Flow_Rate = 0.005   #flowrate between ponds which scales


while True:
    minutes = input("Time since Leakage started (in mins): ")
    try:
        minutes = float(minutes)    #Calculated minutes since leakage
        break
    except ValueError:
        print("Invalid input, input can be numbers only. Try again: ")

while True:
    max_leakage = input("enter the max leakage in liter: ")
    try:
        max_leakage = int(max_leakage)
        leakage = LEAK_RATE * minutes       #max leakage
        if leakage > max_leakage:
            leakage = max_leakage
        break
    except ValueError:
        print ("numbers only: ")

print("Amount of pollutant that leaked into Pond 1 from the source:", leakage, "liters")



outflow1 = Flow_Rate * new_pollutant3
outflow2 = Flow_Rate * new_pollutant1          #some equations
outflow3 = Flow_Rate * new_pollutant2
inflow_pond1 = Flow_Rate * new_pollutant1
inflow_pond2 = Flow_Rate * new_pollutant2
inflow_pond3 = Flow_Rate * new_pollutant3


def calc_new_pollutant_amt(old_pollutant, new_pollutant, inflow, outflow, leakakge):
    new_pollutant = new_pollutant + inflow - outflow + leakage
    return new_pollutant

new_pollutant1 = new_pollutant1 + inflow_pond3 - outflow2 + leakage
new_pollutant2 = new_pollutant2 + inflow_pond1 - outflow3      #equations to get the pollutant in each pond
new_pollutant3 = new_pollutant3 + inflow_pond2 - outflow1      # at t, but they don't work properly either...

while not pond_one == pond_two == pond_three:
    new_pond_values = calculate_pollutant(pond_one, pond_two, pond_three)
    pond_one = new_pond_values[0]
    pond_two = new_pond_values[1]
    pond_three = new_pond_values[2]


Output:
1
2
3
4
Time since Leakage started (in mins): Traceback (most recent call last):
  Line 11, in <module>
    minutes = input("Time since Leakage started (in mins): ")
EOFError


Create a new paste based on this one


Comments: