from src.OptAlgorithm.AutoConfigClass import AutoConfigClass
from numpy import sqrt

class ConstantCalculator(AutoConfigClass):
    
    params_list = []
    def __init__(self, operator_config : dict, system_config : dict):
        
        super().__init__(ConstantCalculator.params_list, operator_config, system_config)
        
    def calc(self):
        constants = {}
        #self.smin1t = self.smin1 - self.dblock / 2
        #self.smin2t = self.smin2 - self.dblock / 2
        #self.awork = self.umax / (self.l * self.m)
        #self.fl = self.Fd * (1-self.kturn)
        #self.flon = self.Fd * self.kturn
        constants["Fprop"] = self.k_prop * self.force_target
        constants["freq"] = sqrt(self.k_hardness_1 / self.mass_1)
        constants["eff_control"] = self.torque_max_1 / self.transmission_ratio_1
        constants["Ftogrow"] = self.force_target * (1 - self.k_prop)
        constants["Fstart_prop"] = 3 * self.force_target / 2 - 1/2 * sqrt(self.force_target*self.force_target + 16  * self.force_target * constants["Fprop"] - 8 * constants["Fprop"]**2)
        return constants