How to Define Temperature in a MATLAB Mass Transfer Simulation?

In summary, the conversation is about a person seeking help with a simulation of mass transfer using the finite element toolbox in MATLAB. They are facing an error when trying to define temperature in the equations and are asking for assistance with the proper syntax. Another person suggests using the ".*" operator and provides a link for reference. The person seeking help then shares the syntax they have tried and mentions that they are not sure if all variables are coded properly, particularly the temperature. The conversation ends with a suggestion to start with a simpler expression and build it up until the error occurs to easily identify the issue.
  • #1
Meaningless
2
0
Hi Guys,

I'm trying to do a simple first-order, 1d (x-direction) simulation of mass transfer with the finite element toolbox in MATLAB for the following closed set of equations:

.latex?%5Cfrac%7BdX%7D%7Bdt%7D%20%3D%20%5Cfrac%7BK%7D%7BT%7D%5Cfrac%7B%5CDelta%20P%5E2%7D%7BX%7D.gif


ht%20%29%20+%5Cfrac%7Bx%7D%7B2%7Derfc%5Cleft%20%28%5Cfrac%7Bx%7D%7Bt%7D%20%5Cright%20%29%29.gif


gif.gif


(Please note: "X" is not to be confused with the lowercase spatial dimension "x")

However, every time I cannot define the temperature (at least with exponential and erfc) without an error. Does anyone know if there is a proper syntax for this?

I appreciate your help.
 
Physics news on Phys.org
  • #3
This is the syntax I directly entered into the toolbox (I have also directly replaced "P" with the T-dependent expression). I also set x = X for the calculation. I am pretty sure one or two of my variables is not coded properly, particularly the temperature, T.

X' = (K/TX_t)*((10^(A-(B/TX_t + C)))^2)/X_t

TX_t = T0 + C*(t*exp(-X^2/t) + (X/2)*erfc(X/t))
 
  • #4
Okay, I'd start with building up the expression until it fails so then you have an even simpler failure to show us.

Perhaps:
Matlab:
t=(1:0.1:11)           // create t array of (1,1.1,1.2,1.3 ... 10)
x=(0:0.1:10)         // create X array of (0,0.1,0.2,0.3 ... 10)      same number of elements as t

y = erfc(x./t)          // notice the use of ./ because here you want to do an element by element /
 

Related to How to Define Temperature in a MATLAB Mass Transfer Simulation?

What is a numerical solution in matlab?

A numerical solution in matlab is a method of solving mathematical problems using numerical techniques and algorithms in the matlab programming language. It involves converting a problem into a series of mathematical equations that can be solved using numerical methods such as iteration, interpolation, and integration.

What are the benefits of using matlab for numerical solutions?

Matlab is a powerful and versatile programming language that offers a wide range of built-in functions and tools specifically designed for numerical computations. It also has a user-friendly interface and allows for easy visualization of data and results, making it a popular choice for solving complex mathematical problems.

Can matlab handle different types of numerical problems?

Yes, matlab is capable of handling a variety of numerical problems including differential equations, linear algebra, optimization, and statistics. It also allows for customization and user-defined functions, making it suitable for solving unique or specific numerical problems.

Is there a learning curve for using matlab for numerical solutions?

Like any new programming language, there may be a learning curve for beginners when using matlab for numerical solutions. However, matlab has a comprehensive documentation and a large online community, making it easier to learn and troubleshoot any issues that may arise.

Are there any limitations to using matlab for numerical solutions?

While matlab is a powerful tool, it does have some limitations. It may not be suitable for extremely large datasets or problems that require high computational power. Additionally, a matlab license can be expensive for individuals or small organizations.

Similar threads

Replies
5
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
6K
  • Astronomy and Astrophysics
Replies
7
Views
4K
Replies
7
Views
2K
  • Differential Equations
Replies
3
Views
4K
Replies
9
Views
979
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Differential Equations
Replies
1
Views
2K
Replies
1
Views
969
Back
Top