Rework cap regen graph
This commit is contained in:
@@ -1,111 +0,0 @@
|
||||
# =============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
#
|
||||
# pyfa is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# pyfa is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
|
||||
import math
|
||||
|
||||
from .base import FitGraph, XDef, YDef, Input
|
||||
|
||||
|
||||
class FitCapRegenGraph(FitGraph):
|
||||
|
||||
# UI stuff
|
||||
internalName = 'capRegenGraph'
|
||||
name = 'Capacitor Regeneration'
|
||||
xDefs = [
|
||||
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's')),
|
||||
XDef(handle='capAmount', unit='GJ', label='Cap amount', mainInput=('capAmount', '%')),
|
||||
XDef(handle='capAmount', unit='%', label='Cap amount', mainInput=('capAmount', '%'))]
|
||||
yDefs = [
|
||||
YDef(handle='capAmount', unit='GJ', label='Cap amount'),
|
||||
YDef(handle='capRegen', unit='GJ/s', label='Cap regen')]
|
||||
inputs = [
|
||||
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=120, defaultRange=(0, 300), mainOnly=True),
|
||||
Input(handle='capAmount', unit='%', label='Cap amount', iconID=1668, defaultValue=25, defaultRange=(0, 100), mainOnly=True)]
|
||||
srcExtraCols = ('CapAmount', 'CapTime')
|
||||
|
||||
# Calculation stuff
|
||||
_normalizers = {
|
||||
('capAmount', '%'): lambda v, fit, tgt: v / 100 * fit.ship.getModifiedItemAttr('capacitorCapacity')}
|
||||
_limiters = {
|
||||
'capAmount': lambda fit, tgt: (0, fit.ship.getModifiedItemAttr('capacitorCapacity'))}
|
||||
_denormalizers = {
|
||||
('capAmount', '%'): lambda v, fit, tgt: v * 100 / fit.ship.getModifiedItemAttr('capacitorCapacity')}
|
||||
|
||||
def _time2capAmountFull(self, mainParam, miscParams, fit, tgt):
|
||||
xs = []
|
||||
ys = []
|
||||
maxCapAmount = fit.ship.getModifiedItemAttr('capacitorCapacity')
|
||||
capRegenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000
|
||||
for time in self._iterLinear(mainParam[1]):
|
||||
currentCapAmount = calculateCapAmount(maxCapAmount=maxCapAmount, capRegenTime=capRegenTime, time=time)
|
||||
xs.append(time)
|
||||
ys.append(currentCapAmount)
|
||||
return xs, ys
|
||||
|
||||
def _time2capRegenFull(self, mainParam, miscParams, fit, tgt):
|
||||
xs = []
|
||||
ys = []
|
||||
maxCapAmount = fit.ship.getModifiedItemAttr('capacitorCapacity')
|
||||
capRegenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000
|
||||
for time in self._iterLinear(mainParam[1]):
|
||||
currentCapAmount = calculateCapAmount(maxCapAmount=maxCapAmount, capRegenTime=capRegenTime, time=time)
|
||||
currentCapRegen = calculateCapRegen(maxCapAmount=maxCapAmount, capRegenTime=capRegenTime, currentCapAmount=currentCapAmount)
|
||||
xs.append(time)
|
||||
ys.append(currentCapRegen)
|
||||
return xs, ys
|
||||
|
||||
def _capAmount2capAmountFull(self, mainParam, miscParams, fit, tgt):
|
||||
# Useless, but valid combination of x and y
|
||||
xs = []
|
||||
ys = []
|
||||
for currentCapAmount in self._iterLinear(mainParam[1]):
|
||||
xs.append(currentCapAmount)
|
||||
ys.append(currentCapAmount)
|
||||
return xs, ys
|
||||
|
||||
def _capAmount2capRegenFull(self, mainParam, miscParams, fit, tgt):
|
||||
xs = []
|
||||
ys = []
|
||||
maxCapAmount = fit.ship.getModifiedItemAttr('capacitorCapacity')
|
||||
capRegenTime = fit.ship.getModifiedItemAttr('rechargeRate') / 1000
|
||||
for currentCapAmount in self._iterLinear(mainParam[1]):
|
||||
currentCapRegen = calculateCapRegen(maxCapAmount=maxCapAmount, capRegenTime=capRegenTime, currentCapAmount=currentCapAmount)
|
||||
xs.append(currentCapAmount)
|
||||
ys.append(currentCapRegen)
|
||||
return xs, ys
|
||||
|
||||
_getters = {
|
||||
('time', 'capAmount'): _time2capAmountFull,
|
||||
('time', 'capRegen'): _time2capRegenFull,
|
||||
('capAmount', 'capAmount'): _capAmount2capAmountFull,
|
||||
('capAmount', 'capRegen'): _capAmount2capRegenFull}
|
||||
|
||||
|
||||
def calculateCapAmount(maxCapAmount, capRegenTime, time):
|
||||
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
|
||||
return maxCapAmount * (1 + math.exp(5 * -time / capRegenTime) * -1) ** 2
|
||||
|
||||
|
||||
def calculateCapRegen(maxCapAmount, capRegenTime, currentCapAmount):
|
||||
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
|
||||
return 10 * maxCapAmount / capRegenTime * (math.sqrt(currentCapAmount / maxCapAmount) - currentCapAmount / maxCapAmount)
|
||||
|
||||
|
||||
FitCapRegenGraph.register()
|
||||
1
gui/builtinGraphs/fitCapRegen/__init__.py
Normal file
1
gui/builtinGraphs/fitCapRegen/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
import gui.builtinGraphs.fitCapRegen.graph # noqa: E402,F401
|
||||
89
gui/builtinGraphs/fitCapRegen/getter.py
Normal file
89
gui/builtinGraphs/fitCapRegen/getter.py
Normal file
@@ -0,0 +1,89 @@
|
||||
# =============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
#
|
||||
# pyfa is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# pyfa is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
|
||||
import math
|
||||
|
||||
from gui.builtinGraphs.base import SmoothPointGetter
|
||||
|
||||
|
||||
class Time2CapAmountGetter(SmoothPointGetter):
|
||||
|
||||
def _getCommonData(self, miscParams, fit, tgt):
|
||||
return {
|
||||
'maxCapAmount': fit.ship.getModifiedItemAttr('capacitorCapacity'),
|
||||
'capRegenTime': fit.ship.getModifiedItemAttr('rechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
y = calculateCapAmount(
|
||||
maxCapAmount=commonData['maxCapAmount'],
|
||||
capRegenTime=commonData['capRegenTime'],
|
||||
time=x)
|
||||
return y
|
||||
|
||||
|
||||
class Time2CapRegenGetter(SmoothPointGetter):
|
||||
|
||||
def _getCommonData(self, miscParams, fit, tgt):
|
||||
return {
|
||||
'maxCapAmount': fit.ship.getModifiedItemAttr('capacitorCapacity'),
|
||||
'capRegenTime': fit.ship.getModifiedItemAttr('rechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
currentCapAmount = calculateCapAmount(
|
||||
maxCapAmount=commonData['maxCapAmount'],
|
||||
capRegenTime=commonData['capRegenTime'],
|
||||
time=x)
|
||||
y = calculateCapRegen(
|
||||
maxCapAmount=commonData['maxCapAmount'],
|
||||
capRegenTime=commonData['capRegenTime'],
|
||||
currentCapAmount=currentCapAmount)
|
||||
return y
|
||||
|
||||
|
||||
# Useless, but valid combination of x and y
|
||||
class CapAmount2CapAmountGetter(SmoothPointGetter):
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
return x
|
||||
|
||||
|
||||
class CapAmount2CapRegenGetter(SmoothPointGetter):
|
||||
|
||||
def _getCommonData(self, miscParams, fit, tgt):
|
||||
return {
|
||||
'maxCapAmount': fit.ship.getModifiedItemAttr('capacitorCapacity'),
|
||||
'capRegenTime': fit.ship.getModifiedItemAttr('rechargeRate') / 1000}
|
||||
|
||||
def _calculatePoint(self, x, miscParams, fit, tgt, commonData):
|
||||
y = calculateCapRegen(
|
||||
maxCapAmount=commonData['maxCapAmount'],
|
||||
capRegenTime=commonData['capRegenTime'],
|
||||
currentCapAmount=x)
|
||||
return y
|
||||
|
||||
|
||||
def calculateCapAmount(maxCapAmount, capRegenTime, time):
|
||||
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
|
||||
return maxCapAmount * (1 + math.exp(5 * -time / capRegenTime) * -1) ** 2
|
||||
|
||||
|
||||
def calculateCapRegen(maxCapAmount, capRegenTime, currentCapAmount):
|
||||
# https://wiki.eveuniversity.org/Capacitor#Capacitor_recharge_rate
|
||||
return 10 * maxCapAmount / capRegenTime * (math.sqrt(currentCapAmount / maxCapAmount) - currentCapAmount / maxCapAmount)
|
||||
57
gui/builtinGraphs/fitCapRegen/graph.py
Normal file
57
gui/builtinGraphs/fitCapRegen/graph.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# =============================================================================
|
||||
# Copyright (C) 2010 Diego Duclos
|
||||
#
|
||||
# This file is part of pyfa.
|
||||
#
|
||||
# pyfa is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# pyfa is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with pyfa. If not, see <http://www.gnu.org/licenses/>.
|
||||
# =============================================================================
|
||||
|
||||
|
||||
from gui.builtinGraphs.base import FitGraph, XDef, YDef, Input
|
||||
from .getter import Time2CapAmountGetter, Time2CapRegenGetter, CapAmount2CapAmountGetter, CapAmount2CapRegenGetter
|
||||
|
||||
|
||||
class FitCapRegenGraph(FitGraph):
|
||||
|
||||
# UI stuff
|
||||
internalName = 'capRegenGraph'
|
||||
name = 'Capacitor Regeneration'
|
||||
xDefs = [
|
||||
XDef(handle='time', unit='s', label='Time', mainInput=('time', 's')),
|
||||
XDef(handle='capAmount', unit='GJ', label='Cap amount', mainInput=('capAmount', '%')),
|
||||
XDef(handle='capAmount', unit='%', label='Cap amount', mainInput=('capAmount', '%'))]
|
||||
yDefs = [
|
||||
YDef(handle='capAmount', unit='GJ', label='Cap amount'),
|
||||
YDef(handle='capRegen', unit='GJ/s', label='Cap regen')]
|
||||
inputs = [
|
||||
Input(handle='time', unit='s', label='Time', iconID=1392, defaultValue=120, defaultRange=(0, 300), mainOnly=True),
|
||||
Input(handle='capAmount', unit='%', label='Cap amount', iconID=1668, defaultValue=25, defaultRange=(0, 100), mainOnly=True)]
|
||||
srcExtraCols = ('CapAmount', 'CapTime')
|
||||
|
||||
# Calculation stuff
|
||||
_normalizers = {
|
||||
('capAmount', '%'): lambda v, fit, tgt: v / 100 * fit.ship.getModifiedItemAttr('capacitorCapacity')}
|
||||
_limiters = {
|
||||
'capAmount': lambda fit, tgt: (0, fit.ship.getModifiedItemAttr('capacitorCapacity'))}
|
||||
_denormalizers = {
|
||||
('capAmount', '%'): lambda v, fit, tgt: v * 100 / fit.ship.getModifiedItemAttr('capacitorCapacity')}
|
||||
|
||||
_getters = {
|
||||
('time', 'capAmount'): Time2CapAmountGetter,
|
||||
('time', 'capRegen'): Time2CapRegenGetter,
|
||||
('capAmount', 'capAmount'): CapAmount2CapAmountGetter,
|
||||
('capAmount', 'capRegen'): CapAmount2CapRegenGetter}
|
||||
|
||||
|
||||
FitCapRegenGraph.register()
|
||||
Reference in New Issue
Block a user