How to Define Temperature in a MATLAB Mass Transfer Simulation?

  • Context: MATLAB 
  • Thread starter Thread starter Meaningless
  • Start date Start date
  • Tags Tags
    Matlab Numerical
Click For Summary

Discussion Overview

The discussion revolves around defining temperature in a MATLAB mass transfer simulation, specifically within the context of a first-order, one-dimensional simulation using the finite element toolbox. Participants are addressing syntax issues and potential errors encountered when implementing temperature-dependent expressions in their code.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant seeks assistance with defining temperature in their MATLAB simulation, indicating issues with syntax related to exponential and erfc functions.
  • Another participant suggests that the variable 't' should be treated as an array and recommends using element-wise multiplication (".*") to avoid common MATLAB errors.
  • A participant shares their specific syntax for the temperature-dependent expression and expresses uncertainty about the proper coding of the temperature variable.
  • Another participant advises starting with a simpler expression to isolate the error, providing an example of how to create arrays for 't' and 'x' and emphasizing the need for element-wise operations (".") in the calculations.

Areas of Agreement / Disagreement

The discussion does not appear to reach a consensus, as participants offer different suggestions and approaches to address the syntax issues without agreeing on a definitive solution.

Contextual Notes

Participants have not provided specific details about the errors encountered, and there may be missing assumptions regarding the definitions of variables and the context of the simulation.

Meaningless
Messages
2
Reaction score
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
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))
 
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 /
 

Similar threads

  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
6K
Replies
6
Views
2K
  • · Replies 0 ·
Replies
0
Views
2K
  • · Replies 6 ·
Replies
6
Views
27K
Replies
5
Views
4K
Replies
7
Views
3K
  • · Replies 3 ·
Replies
3
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K