Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.

How to solve 1D ODE using the PDE interface in COMSOL?

Please login with a confirmed email address before reporting spam

Suppose I have a differential equation, du/dx=x, which i need to solve using the "Coefficient Form PDE" in COMSOL. I want to solve the differential equation in an interval from x=0 to x=1. The boundary condition is that u(x=0)=0. However, in COMSOL, it seems that I need to supply boundary conditions at two points, x=0 and x=1. But, doing so would over-determine my equation. Is there any way to give only one boundary condition? P.S. I know using the ODE interface might solve the problem , however, I need to solve using the PDE interface if possible. Thank you


4 Replies Last Post Aug 2, 2023, 12:58 a.m. EDT
Robert Koslover Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Jul 30, 2023, 3:07 p.m. EDT

I've attached an example .mph file that shows one way (among other possibilities) to solve your problem. It's also rather nice to see it yields the correct answer. :)

-------------------
Scientific Applications & Research Associates (SARA) Inc.
www.comsol.com/partners-consultants/certified-consultants/sara
I've attached an example .mph file that shows one way (among other possibilities) to solve your problem. It's also rather nice to see it yields the correct answer. :)


Please login with a confirmed email address before reporting spam

Posted: 1 year ago Jul 30, 2023, 10:21 p.m. EDT
Updated: 1 year ago Jul 30, 2023, 10:22 p.m. EDT

Thank you Robert. This works excellently. I guess the mistake I was making was that I was trying to define the derivative by substituting α=-1, instead of β=1.

However, I do have a couple of questions which I would appreciate, if you could find the time to answer.

  1. Why does substituting α=-1 (instead of β=1) in the coefficient form PDE not work? If u is a regular valued function, div(u)=du/dx in 1D right?

  2. Why does putting a zero flux condition at x=1 not cause an error, or produce incorrect results.

Thanks in advance, AR

Thank you Robert. This works excellently. I guess the mistake I was making was that I was trying to define the derivative by substituting α=-1, instead of β=1. However, I do have a couple of questions which I would appreciate, if you could find the time to answer. 1. Why does substituting α=-1 (instead of β=1) in the coefficient form PDE not work? If u is a regular valued function, div(u)=du/dx in 1D right? 2. Why does putting a zero flux condition at x=1 not cause an error, or produce incorrect results. Thanks in advance, AR

Robert Koslover Certified Consultant

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Aug 1, 2023, 10:33 p.m. EDT

Let's talk about your seond item first: The (default) zero flux condition (if you look at the equation for it) involves a relationship among linear operations on c, alpha, and gamma. But all of those coefficients are zero, in the example that I posted, so in that case, the "zero flux" condition doesn't impose any constraint.

Now, regarding your first item, if I were to instead set alpha = -1, then I could no longer ignore that default flux boundary condition (per the comment above). There is probably a way to make that still work (since a variety of other boundary conditions are available), but in my approach, that issue simply never arises. I chose what seemed to me to be the simplest approach.

-------------------
Scientific Applications & Research Associates (SARA) Inc.
www.comsol.com/partners-consultants/certified-consultants/sara
Let's talk about your seond item first: The (default) zero flux condition (if you look at the equation for it) involves a relationship among linear operations on c, alpha, and gamma. But *all* of those coefficients are zero, in the example that I posted, so in that case, the "zero flux" condition doesn't impose any constraint. Now, regarding your first item, if I were to instead set alpha = -1, then I could no longer ignore that default flux boundary condition (per the comment above). There is probably a way to make that still work (since a variety of other boundary conditions are available), but in my approach, that issue simply never arises. I chose what seemed to me to be the simplest approach.

Please login with a confirmed email address before reporting spam

Posted: 1 year ago Aug 2, 2023, 12:58 a.m. EDT

Thanks Robert. Addresses my queries.

Regards, AR

Thanks Robert. Addresses my queries. Regards, AR

Note that while COMSOL employees may participate in the discussion forum, COMSOL® software users who are on-subscription should submit their questions via the Support Center for a more comprehensive response from the Technical Support team.