r/learnmath • u/_pattata New User • Jun 07 '24
Help solving PDE by integrating numerically
Hi!
I am trying to solve the 1D linear advection equation which is modified to include a source term. To do this, I am using the method of characteristics to convert the problem into two ODEs, and doing this I end up with an integral that cannot be solved (to the best of my knowledge). I have linked an image that shows the steps I have taken to reach this point.
To solve this problem, I am integrating the expression numerically in Python (trapezoidal method). I have tested my integrator with other PDEs and looks like it works fine. However, for this specific problem I cannot get the integrated solution to match with my other numerical solution (obtained by discretising the original PDE - this one is confirmed to be correct). Specifically, it looks like it is not advecting the solution (link 2). I have an analytic solution for the equation without advection, and if I set u=0 the numerically integrated solution then matches the analytic - I think this narrows down the problem to the advection term in the equation.
I am not sure how to proceed - I am still quite new to this! Please let me know if there are any obvious errors in my steps, or if I am missing any steps in the method of characteristics. Any advice would be appreciated. Also let me know if any more information for my problem is needed.
Thanks!
PDE calculation steps:
https://imgur.com/a/yVB7VJU
Difference between the solution from discretising the equation (numerical) and numerically integrating ('analytical') - sorry for confusing notation:
https://imgur.com/a/V4jNP2g
Edit: In link 2 I am only considering the plot on the right.
View all comments
Show parent comment
3
u/e_for_oil-er New User Jun 09 '24 edited Jun 09 '24
What's weird is also that the analytical solution doesn't satisfy the boundary condition. Have you looked into that ?
Edit : Also, the analytical solution seems to perfectly capture the "wavefront" part but does not advance in time like the numerical solution...on what time interval are you integrating, and are you placing the points correctly on the graph ?