Jun-06-2019, 01:23 PM
Hello
I would like to get the value of each port area in a pipe in one array. I have developed an array class called Equation where equation.A is an array and equation.c is a vector
I want to assign the value for each area in a different script and then add it to the main program in the array.
so far I have no luck in getting this to work. any help or advice will be appreciated.
This is the main program
I would like to get the value of each port area in a pipe in one array. I have developed an array class called Equation where equation.A is an array and equation.c is a vector
I want to assign the value for each area in a different script and then add it to the main program in the array.
so far I have no luck in getting this to work. any help or advice will be appreciated.
This is the main program
import numpy as np import sys uCounter = 0 class Pipe(object): global uCounter def __init__(self, nPorts, volume): self.volume = volume self.nPorts = nPorts self.freePorts = [] #The ports of the pipe that are not in use self.portSetAreas = [] self.portSetAreasValue = [] for i in range(nPorts): self.freePorts.append(i) self.portSetAreas.append(False) self.portSetAreasValue.append(0.0) self.Areas = D(self.nPorts) # where D refers to the domain and how many ports it contain self.pd = np.zeros((self.nPorts)) self.dt = 0.0 def logics(self): nFree = len(self.freePorts) for port in range(nFree): if self.portSetAreas[self.freePorts[port]]: self.Areas = self.portSetAreasValue[self.freePorts[port]] def Values1(self): equation = Equation(1, uCounter) #where Equation is an array class for p in range(self.nPorts): #nPorts is the number of ports with an area equation.A[0, self.m.gid[p]] = self.Areas[p] #the multible values of the Area will be put into an array equation.A equation.c[0] = 0.0 #This is a vector return(equation) #the problem is with self.Areas[p] this multible values will be called form anoth script "test1"This is the test1 script
import math import numpy as np import sys import scipy.io import mainproject Pipe1.portSetAreas[0] = True Pipe1.portSetAreasValue[0] = 0.1 Pipe1.portSetAreas[1] = True Pipe1.portSetAreasValue[1] = 0.1 #0 refer to the inlet of the pipe #1 refer to the outlet of the pipe
Error:equation.A[0,self.m.gid[p]] = self.Areas
TypeError: float() argument must be a string or a number