My equations are as shown in the figure, and while the equations themselves aren't particularly complex, I'm having trouble figuring out how to define them in FiPy. I've tried some code, but I keep getting errors. How can I define the second term in the second equation and the second term in the third equation? The PDE Equations
Error:
--> 250 assert len(id1) == len(id2) == len(vector)
252 temp = sp.csr_matrix((vector, (id1, id2)), self.matrix.shape)
254 self.matrix = self.matrix + temp
AssertionError:
def CreatEquation(self):
#h
self.R = self.P * numerix.cos(self.slopeAngle) - self.i
self.eq_h = TransientTerm(var=self.h) + ConvectionTerm(var=self.h, coeff=[self.u]) == self.R
#u
self.f = 8 * self.g * self.h * numerix.sin(self.slopeAngle) / (self.u**2)
self.Sfx = (self.u / numerix.sqrt(8 * self.g / self.f))**2 / self.h
self.eq_u = (TransientTerm(var=self.u) + ConvectionTerm(var=self.u, coeff=[self.u]) +
ConvectionTerm(var=self.h, coeff=[self.g])) == (
self.g * (numerix.tan(self.slopeAngle) - self.Sfx) +
self.P * numerix.cos(self.slopeAngle) * self.Vm / self.h -
self.R * self.u / self.h
)
#h & u
self.eqns = self.eq_h & self.eq_u
When I set the coeff to 1, I don't encounter any errors, but that doesn't represent the equation correctly. How can I define the second term in the second equation and the second term in the third equation without causing errors?
A couple of things:
[self.u]is not a vector field; it's a Python list with a scalar field in it. Instead, writeself.u * [[1]].ConvectionTerm(coeff=u/2, var=u).ConvectionTerm(coeff=g, var=h) - ImplicitSourceTerm(coeff=g.grad, var=h).Generally speaking, 1D equations are an excellent way to get really confused about how to represent things in FiPy (and in general, IMO). It's impossible to tell which derivatives are physically vector and physically scalar.