Solving PDEs: Number of rows required in output of user defined coefficient functions

1 Ansicht (letzte 30 Tage)
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!

Akzeptierte Antwort

Bill Greene
Bill Greene am 23 Okt. 2013
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 Kommentare
Susannah
Susannah am 23 Okt. 2013
Thanks Bill. It's a scalar PDE. I'm still confused about entering coefficients. My c and a coefficients are -1 and 0, respectively, so I am just entering those as scalar numbers. For d and f, I have a one row array with each column containing the appropriate coefficient for the corresponding mesh point. Should I have more rows for these coefficients?
Bill Greene
Bill Greene am 23 Okt. 2013
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by