Advertisement
JaMaNi133

Untitled

Mar 1st, 2024 (edited)
614
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.59 KB | None | 0 0
  1. --ctrlRod,power,fuel,tempCore,tempCase
  2. fileName="test1.csv"
  3.  
  4. file=fs.open(fileName,"w")
  5. file.writeLine("rodLevel,prodRate,fuelRate,coreTemp,caseTemp")
  6. file.writeLine("%,fe/t,mb/t,°C,°C")
  7. file.close()
  8.  
  9. ctrlRod = 100
  10. powerProd,fuelRate,tempCore,tempCase=0,0,0,0
  11. reactor = peripheral.wrap("back")
  12. function saveData()
  13.     file=fs.open(fileName,fs.exists(fileName) and "a" or "w")
  14.     print(string.format("%d ,%d ,%.4f ,%d ,%d",ctrlRod,powerProd,fuelRate,tempCore,tempCase))
  15.     file.writeLine(string.format("%d ,%d ,%.4f ,%d ,%d",ctrlRod,powerProd,fuelRate,tempCore,tempCase))
  16.     file.close()
  17. end
  18.  
  19. function measure()
  20.     points = 0
  21.     powerProd,fuelRate,tempCore,tempCase=0,0,0,0
  22.     while points < 20 do
  23.         points = points + 1
  24.         powerProd = powerProd+reactor.getEnergyProducedLastTick()
  25.         fuelRate = fuelRate+reactor.getFuelConsumedLastTick()
  26.         tempCore = tempCore+reactor.getFuelTemperature()
  27.         tempCase = tempCase+reactor.getCasingTemperature()
  28.         sleep(0.25)
  29.     end
  30.     powerProd = powerProd/points
  31.     fuelRate = fuelRate/points
  32.     tempCore = tempCore/points
  33.     tempCase = tempCase/points
  34. end
  35.  
  36. reactor.setAllControlRodLevels(ctrlRod)
  37. reactor.setActive(true)
  38. print("waiting for cooling")
  39. while reactor.getEnergyProducedLastTick() > 10 do
  40.     sleep(2)
  41. end
  42. print("starting")
  43. while ctrlRod >=0 do
  44.     reactor.setAllControlRodLevels(ctrlRod)
  45.     sleep(15)
  46.     measure()
  47.     --print(string.format("rod:%d power:%dfe/t rate:%.4fmb/t core:%d°C case :%d°C",ctrlRod,powerProd,fuelRate,tempCore,tempCase))
  48.     saveData()
  49.     ctrlRod = ctrlRod-1
  50. end
  51. print("done")
  52. reactor.setActive(false)
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement