MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

# Where can I find the best tutorials/texts on how to export a solution of a PDE equation created in PDE toolbox to the command window to fit equations which include the PDE solution to real data?

Asked by Jeremy Pearson on 9 Nov 2012

I am modeling neutron absorption within a cylindrical sample. Neutron flux is the same on all surfaces of the cylinder and decreases as it is absorbed and approaches the center of the sample. This is a steady state, 2-D in space PDE in the r and z direction. I was able to create a solution to this equation using the PDEtoolbox (finite element method) by reducing the cylindrical problem to 2-D using coordinate transformation as described in one of the matlab examples.

Now using this solution to the neutron flux profile throughout the cylinder, I need to set up an equation which integrates the flux profile change across the entire volume of the sample to reflect the total neutrons absorbed. Then I need to fit this equation to actual data of total neutrons absorbed to solve for the real flux in the reactor (flux on the surface of the samples). I imagine that the solution to the PDE derived in the pdetoolbox needs to be exported into the command window to perform these remaining steps.

So I'm looking to learn how to:

1) Export solutions to PDE's into the command window

2) Manipulate/perform calculations with the solution to the PDE once it is available in the command window

3) Write equations containing the solution to the PDE

4) Do data fitting with equations which include solutions to a PDE from the PDE toolbox

Any direction to examples of this being done would be great!

Thanks,

Jeremy

## Products

No products are associated with this question.

Answer by Deepak Ramaswamy on 13 Nov 2012

For your point 3), in addition to Bill Greene's suggestions, it will be useful to look at the answer to

This shows how express a solution in terms of any (r,z). Once you have this form, you can do useful operations.

Deepak

## 1 Comment

Jeremy Pearson on 20 Nov 2012

Thanks Bill and Deepak for your help,

Bill's comment helped me understand how the exporting works and Deepaks comment directed me to a previous answer by Bill which described TriScatteredInterp which was what I needed to complete the function in the command window. Works great!

Jeremy

Answer by Sean de Wolski on 9 Nov 2012

I fyou coudl give us an example that would probably be best. BUt some friends for your journey:

```doc sprintf
doc disp
dos str2func
doc func2str
```

etc...

## 1 Comment

Jeremy Pearson on 9 Nov 2012

Good point, I'll be a little more specific.

The pdetoolbox has successfully solved for the flux at any point in the cylindrical sample, i.e., it has solved for flux, u, as a function of r and z. flux = u(r,z). There is symmetry in the theta direction so flux is not a function of theta.

The next equation I would like to solve in the command window is the following tripple integral in cylindrical coordinates:

deltaN = SrSzStheta u(r,z,theta)rdrdzdtheta

since flux is not a function of theta, this equation reduces to:

deltaN = 2pi SrSz u(r,z)rdrdz

This integral describes the total number of neutrons absorbed within the sample. In order to solve the triple integral (solve for deltaN), I need to have a way of calling for the function u(r,z) which was solved for in the pdetoolbox.

I saved the work I did in the pdetoolbox and I see that there is a new function that was created in the "current folder" section to the left of the command window, so I imagine that this new function represents the solution u(r,z) somehow, but this is as far as I have gotten.

This is the first question, and first example that I can add, which is how to define the tripple integral in the command window and call the function u(r,z) which was solved for using the pdetoolbox.

Thanks Sean!

Jeremy

Answer by Bill Greene on 13 Nov 2012

Hi Jeremy,

I think I can at least point you in the right direction.

There are a couple of PDE Toolbox functions you will probably need to calculate that integral: pdetrg which will calculate the area of each triangular element, and pdeintrp which will interpolate the solution from the node points to the center of each triangle.

If you look at the documentation for these functions, you see that they require the p and t matrices, and the solution vector, of course. To export these to the MATLAB workspace from pdetool, select Mesh/Export Mesh... and Solve/Export Solution...

Bill