MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / Thermodynamics

Class Thermodynamics

gui/builtinViewColumns/heat.py:33–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31import gui.mainFrame
32
33class Thermodynamics():
34 def __init__(self, fit):
35 self.fit = fit
36 self.hgm = fit.ship.getModifiedItemAttr("heatGenerationMultiplier")
37 self.harm = self.calcHeatAbsorbtionRateModifier()
38 self.slotfactor = self.calcSlotFactor()
39 self.simTime = 600
40
41 def getSlotPos(self, mod): # get rack position of mod, 0-7
42 rack = []
43 for m in self.fit.modules:
44 if m.slot == mod.slot:
45 rack.insert(0, m)
46
47 for i, m in enumerate(rack):
48 if m == mod:
49 return i
50
51 def calcHeatAbsorbtionRateModifier(self):
52 harm = [0,0,0,0] # 0 is a dummy slot, align with mod.slot constants, 1=low, 2=med, 3=hi, 4=rig, ...
53
54 for mod in self.fit.modules:
55 if(mod.state == FittingModuleState.OVERHEATED):
56 harm[mod.slot] += mod.getModifiedItemAttr("heatAbsorbtionRateModifier")
57
58 return harm
59
60 def calcSlotFactor(self):
61 slots = self.fit.ship.getModifiedItemAttr("hiSlots") + self.fit.ship.getModifiedItemAttr("medSlots") + self.fit.ship.getModifiedItemAttr("lowSlots")
62 empty = self.fit.getSlotsFree(3) + self.fit.getSlotsFree(2) + self.fit.getSlotsFree(1) # FittingSlot.HIGH doesn"t work here?
63 rigslots = self.fit.getNumSlots(4)
64
65 offline = 0
66 for mod in self.fit.modules:
67 if (mod.state == FittingModuleState.OFFLINE and mod.slot in [1, 2, 3]): # only count offline low, med, hi mods
68 offline += 1
69
70 return (slots - empty - offline) / (slots + rigslots)
71
72 def calcDamageProbability(self, mod, t): # get chance the module is damaged when overheated at time t
73 keys = ["", "heatAttenuationLow", "heatAttenuationMed", "heatAttenuationHi"]
74 att = self.fit.ship.getModifiedItemAttr(keys[mod.slot], 0.25)
75 rackheat = 1 - pow(math.e, (-t * self.hgm * self.harm[mod.slot]))
76 slotpos = self.getSlotPos(mod)
77
78 probs = []
79 for m in self.fit.modules:
80 if (m == mod): continue
81 if m.slot == mod.slot:
82 if m.state == FittingModuleState.OVERHEATED:
83 i = self.getSlotPos(m)
84 pos = abs(i - slotpos) # get rack distance to other overheated module
85 probs.append(pow(att, pos) * self.slotfactor * rackheat)
86
87 p = 1
88 for i in range(0, len(probs)):
89 p *= (1 - probs[i])
90

Callers 1

getTextMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected