Solving PDEs: Number of rows required in output of user defined coefficient functions
1 次查看(过去 30 天)
显示 更早的评论
Hello, I am trying to solve an inhomogenous wave equation using a script (not PDETool) and the hyperbolic PDE solver. My coefficients are quite complicated so I am writing my own functions to describe them. I understand that the coefficient array the function outputs must have as many columns as mesh elements, but what about the number of rows? I currently only have one row but I get errors from 'pdeasma' indicating that matrix dimensions must agree. When I give the coefficient a single scalar value it's fine, so I am confident the error has to do with my coefficient function. My coefficients are only dependent on position in the mesh (not time or initial conditions). Thanks a lot!
0 个评论
采纳的回答
Bill Greene
2013-10-23
Hi Susannah,
I think I can give you some help on this. I'll discuss the c-coefficient since that is the most complex one.
You didn't say whether you have more than one PDE in your system. If you have only one (i.e. a scalar PDE), the number of rows for the c-coefficient can be 1, 2, 3, or 4. For this case, you can think of c as a 2x2 matrix. If your properties are the same in the x and y directions, you need to input only one row (c11=c22=c). Otherwise, you enter the terms from the 2x2 matrix row by row. For example, if you want to enter the full 2 x 2 matrix, you would need 4 rows.
For the system case (N>1), there is a bewildering number of options depending on which terms in the 2N x 2N c-matrix you need to describe your equations. Those options are described here:
One final tip: you can always define your c-coefficient with 2*N*2*N rows but, usually, many of those entries will be zero.
Hope that helps.
Bill
2 个评论
Bill Greene
2013-10-23
For a scalar PDE, d, f, and a must be scalars (one row).
Bill
PS: FYI, you could also have defined c as:
c = [-1 -1]';
c = [-1 0 -1]';
c = [-1 0 0 -1]';
They are all equivalent to the most convenient form
c = -1;
which you chose.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Boundary Conditions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!