
#19
Mar2911, 09:00 AM

P: 41

Yus: Thanks this is great. I was going through the code and there are some things that are a little confusing to me. I understand the general heat equations and how you are calling the boundary conditions, however could you clearly state the problem at hand (purpose of pulse?) and boundary conditions?
Also, what I am trying to say is that we both initialize a matrix where we perform computations, in your case T=zeros(d,n); The data from the time and space stepping computations gets saved in this matrix after the program runs. This is bad for computations since the memory could get full (happened in my case). A better way to code this would be to use vectors, using the previous vector to calculate the new vector, then the new vector to calculate the next vector, and not saving the used vectors. So at the end of the stepping only 2 vectors remain. Do you understand? 



#20
Mar2911, 09:45 AM

P: 81

you can do as you please... gauss siedel, time marching, either way one matrix is fine enough.. you should not run out of memory.. it means you are doing the problem wrong




#21
Mar2911, 10:45 AM

P: 41

Unfortunately there is no other option other than vectorizing. To keep the stability in my code, the dt has to be extremely small (total time is fixed), which makes the number of time steps in my matrix extremely large (on the order of 500000). Matlab either gives me a memory error or crashes when it runs. It runs when I reduce the number of time steps and increase x, however I cannot do this since my x has to be a fixed value. Using single vectors we can save the same amount of memory as a matrix in a vector, then keep overwriting the vector with new values.




#22
Mar2911, 11:06 AM

P: 81

send me the code, repost again with equations, trust me I will solve it using my method in matlab




#23
Mar2911, 02:17 PM

P: 41

The system is as follows.
Diffusion of 2 species, S and P, through 2 layers. First layer is 1E6 second is 10E9. The diffusion through layer 1 for S and P is:
BC and ICs are as follows:




#24
Mar3011, 09:31 PM

P: 41

Here is my code:




#25
Apr1911, 10:46 AM

P: 81

what is the equation for the last node? Backward difference, flux of concentration at the end?
Where is the interface node between the two layers.. the equation.. again I said assume D1*dCA1/dx=D2*dCA2/dx you need to add a nodal equation for the end and the interface 



#26
Apr1911, 12:13 PM

P: 41

There is no flux at the end, it is a dirchelet boundary condition.



Register to reply 
Related Discussions  
Diffusion equation and neutron diffusion theory  Nuclear Engineering  15  
Conductivity of a set of layers  Advanced Physics Homework  2  
atmosphere layers  Introductory Physics Homework  1  
Dynamics of the Sun's layers.  General Astronomy  8  
COMSOL Unsteady 1D Diffusion modeling  General Engineering  0 