1

I am trying to solve a system of linear equations in a subclass using inherited variables from multiple parent classes. The system contains 4 equations and 4 unknowns. Without including the long equations of what I'm working with, f(variable) means those variables are being used in the equation. I understand that is wrong syntax in code. My actual code includes long equations. In my case, self.X_i, self.Y_i, self.T1_i and self.T2_i are the 4 variables I need to make a system of equation solver for within the child subclass.

I have tried using fsolve in the scipy.optimize distribution on a different script with some results but need to replicate the results within a subclass so I can create multiple objects of the same subclass.

class parent1():
     def __init__(self, flow, moisture, temperature)
           self.temp1 = temperature
           self.flow1 = flow
           self.moist1 = moisture

           self.Pv1 = f(self.temp1)
           self.Dflow1 = f(self.moist1, self.flow1)
           self.X_in = f(self.moist1)

class parent2():
    def__init__(self, flow, moisture, temperature)
          self.temp2 = temperature
          self.flow2 = flow
          self.moist2 = moisture

          self.Pv2 = f(self.temp2)
          self.Dflow2 = f(self.moist2,self.flow2)
          self.Y_in = f(self.moist2)

class child(parent1, parent2):
    def__init__(self,flow, moisture, temperature, flow, moisture, 
                temperature):
       parent1.__init__(self, flow, moisture, temperature)
       parent2.__init__(self, flow, moisture, temperature)

       self.E = f(self.Pv1, self.Pv2)

       self.X_i = f(self.X_in, self.E, self.Dflow1)
       self.Y_i = f(self.Y_in, self.E, Self.Dflow2)
       self.T1_i = f(self.X_i, self.E, self.T2_i, self.Dflow1)
       self.T2_i = f(self.Y_i, self.E, self.T1_i, self.Dflow2)
James
  • 32,991
  • 4
  • 47
  • 70

0 Answers0