Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --variable declaration
- local fuel = 0
- local hplp_div = 0
- local hp = false
- local hpname = ""
- local size = 0
- local ticks = 0
- local upticks = 0
- local downticks = 0
- local boilticks = 0
- local maxticks = 0
- local temp = 20
- local maxtemp = 0
- local finaltemp = 0
- local heatstep = 0.05
- local heatchange = 0
- local heatup = false
- local efficiency = 0
- local energy = 0
- local energymod = 0
- local deltafuel = 0
- local answer = ""
- --user input
- print("For how many ticks should the boiler be active?")
- maxticks = tonumber(io.read())
- while not ((size == "1") or (size == "8") or (size == "12") or (size == "18") or (size == "27") or (size == "36")) do
- print("What size of boiler will you use? (1,8,12,18,27,36)")
- size = io.read()
- end
- while not ((answer == "h") or (answer == "H") or (answer == "l") or (answer == "L")) do
- print("Is it a (H)igh or (L)ow Pressure boiler?")
- answer = io.read()
- end
- if ((answer == "h") or (answer == "H")) then
- hp = true
- end
- if hp then
- maxtemp = 1000
- hplp_div = 8
- hpname = size.." HP"
- energymod = 4
- else
- maxtemp = 500
- hplp_div = 16
- hpname = size.." LP"
- energymod = 2
- end
- print("What is the starting temp?")
- temp = tonumber(io.read())
- if temp > maxtemp then
- temp = maxtemp
- elseif temp < 20 then
- temp = 20
- end
- local cooltemp = temp
- print(" ")
- print("Simulating a "..hpname.." steam boiler for an active period of "..tostring(maxticks).." ticks...")
- print("Starting at "..tostring(temp).." C.")
- --calculate active burn period
- while ticks < maxticks do
- --calculate fuel for tick
- deltafuel = ((6.4 - size * 0.08) / hplp_div) * size * (1 + 8 * (1 - temp / maxtemp))
- fuel = fuel + deltafuel
- --calculate MJ output
- if temp >= 100 then
- energy = energy + (energymod * size)
- end
- --calculate heatup process
- if temp < maxtemp then
- heatchange = heatstep
- if temp < 0.25*maxtemp then
- heatchange = heatchange + heatstep
- end
- if temp < 0.5*maxtemp then
- heatchange = heatchange + heatstep
- end
- if temp < 0.75*maxtemp then
- heatchange = heatchange + heatstep
- end
- heatchange = heatchange / size
- temp = temp + heatchange
- upticks = upticks + 1
- end
- --advance ticks
- ticks = ticks + 1
- --note down boiling point
- if ((boilticks == 0) and (temp >= 100)) then
- boilticks = ticks
- end
- end
- finaltemp = temp
- --calculate cooldown period
- while temp >= cooltemp do
- --calculate MJ output
- energy = energy + (energymod * size)
- ---calculate cooldown process
- heatchange = heatstep
- if temp >= 0.25*maxtemp then
- heatchange = heatchange + heatstep
- end
- if temp >= 0.5*maxtemp then
- heatchange = heatchange + heatstep
- end
- if temp >= 0.75*maxtemp then
- heatchange = heatchange + heatstep
- end
- heatchange = heatchange / size
- temp = temp - heatchange
- downticks = downticks + 1
- end
- efficiency = energy / fuel
- --output results
- print ("Simulation complete.")
- if boilticks == 0 then
- print("- The water did not start to boil.")
- elseif boilticks > 1 then
- print("- The water started boiling at 100 C after "..tostring(boilticks).." ticks.")
- end
- if finaltemp >= maxtemp then
- print("- The boiler finished heating up to "..tostring(maxtemp).." C over the course of the first "..tostring(upticks).." ticks.")
- else
- print("- The boiler did not finish heating up, reaching a final temperature of "..tostring(finaltemp).." C.")
- end
- if finaltemp >= 100 then
- print("- After the active period, it spent an additional "..tostring(downticks).." ticks cooling back down to below "..tostring(cooltemp).." C.")
- end
- print("- The boiler consumed "..tostring(fuel).." Heat Units of fuel during the active period.")
- if energy > 0 then
- print("- With this much fuel, it produced enough steam for "..tostring(energy).." MJ worth of Buildcraft energy.")
- print("- The fuel efficiency for this simulation is "..tostring(efficiency).." MJ per HU.")
- else
- print("- As the water did not boil, it did not produce any energy.")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement