Showing posts with label MATLAB. Show all posts
Showing posts with label MATLAB. Show all posts

Thursday, 25 August 2011

I am looking for a job

News - I greatly appreciate your comments below and surprisingly plenty of information and valuable advices came to me during the last one year. Thanks to all your concern, I finally accepted a thermal expert position in ABB USA (www.abb.com) and am sitting in North Carolina.

I particularly thank the three companies in England, France and America that I personally consulted for and their encouraging recommendations. I cherish the experiences I have obtained from the part-time working with them.

Within my PhD study, I have published eight research papers. Four of them are in leading journals and their links are as follows:

I am graduating in September 2011 with a PhD degree from School of Electrical and Electronic Engineering, University of Manchester. I am looking for a numerical modelling job.

I spent the past more than three years on the CFD simulations which are coupling between electric, thermal and fluid dynamic fields, from which I have accumulated rich experiences on modelling packages such as SALOME, Code_Saturne, Elmer, ParaView and COMSOL etc. I share experiences in this blog, which has also gained worldwide popularity.

I have been programming in C/C++, C#, VB.NET and Matlab since 2002. I also have experiences in Python (the script widely used for automation of modelling and the software such as SALOME and ParaView etc) and Fortran (the user routine definition for Code_Saturne) etc. Meanwhile, probably as a bonus, I am a fan of open-source software, Linux and Mac OS X. I even wrote device drivers for Linux and ported the MySQL client tool running on desktops onto embedded Linux platforms.

I bear high interests in numerical modelling and would like to pursue a career in this field. If you have relevant opportunities, please drop me an email (salad00 at gmail dot com). I really appreciate your help very much.

Tuesday, 21 September 2010

MATLAB 2010b supports NVIDIA CUDA-capable GPUs

From MATLAB 2010b, GPU support is available in Parallel Computing Toolbox. Using MATLAB for GPU computing lets you take advantage of GPUs without low-level C or Fortran programming.

MATLAB CUDA support provides the base for GPU-accelerated MATLAB operations and lets integrate existing CUDA kernels into MATLAB applications. However, as a restriction, MATLAB only supports GPUs with CUDA compute capability version 1.3 or higher, such as Tesla 10-series and 20-series GPUs. This limitation is not from a light decision; it is actually due to the double precision support and the IEEE-compliant maths implementation of the CUDA capability version 1.3. Please see this thread for more discussion.

MATLAB GPU computing capabilities include:
  • Data manipulation on NVIDIA GPUs
  • GPU-accelerated MATLAB operations
  • Integration of CUDA kernels into MATLAB applications without low-level C or Fortran programming
  • Use of multiple GPUs on the desktop (via the toolbox) and a computer cluster (via MATLAB Distributed Computing Server)
Useful references

Introduction to MATLAB GPU Computing (Video)

MATLAB GPU Computing (Documentation)

Friday, 12 March 2010

MEI is easy to use and works like a charm!

The most expected feature coming from Code_Saturne 2.0-rc1 is the better supported MEI functions. With help of the small CFD calculation case, I tested the feature and have to say that MEI is truly easy to use and works like a charm. Before when I used COMSOL I defined the fluid properties by writting simple MATLAB expressions; (COMSOL is easy to be integrated into MATLAB because originally it is a third party toolbox for MATLAB). It is as easy as you can imagine, and now, within Code_Saturne we are also able to have the same fun.

I used two methods to define the fluid density and viscosity expressions: FORTRAN user routines and MEI expressions. By comparing the results, both methods actually have the same effect. Because I already talked about the first method in the previous tutorial post, I focus on the second one here. Before following, make sure you read "Installation of Code_Saturne 2.0-rc1 on Ubuntu 9.10" and installed 2.0-rc1 with MEI properly.

With the SaturneGUI program, when using 'Physical properties > Fluid properties' to define fluid properties, we have options 'constant', 'user law' and 'user subroutine(usphyv)'. If the property is a constant, fill a value below as a reference value. If select 'user law', MEI expressions can be inputted by clicking the following edit button. Finally, as mentioned previously, the option 'user subroutine' is for using FORTRAN routines to define the properties.


Click the edit button, and see a dialog as the figure below shows. I input a simple density expression as an illustration. Actually there are three tabpages here and the third one also contains an example. TempC is a pre-defined variable, which can be looked up from the second tabpage 'Predefined symbols'. Most operators like +, -, *, /, and ^ can be used, and even simple statements like if ... else can be applied.


Then we don't need to define the temperture dependent density in FORTRAN user routines any more. Obviously this MEI method is more straightforward. I don't say more about the viscosity part, because it is almost the same.

Re-use density value when calculating dynamic viscosity

Dynamic viscosity is the product of density and kinematic viscosity . Sometimes when only a kinematic viscosity expression is available, we need to calculate the dynamic viscosity value with the help of the correlation, .

When using FORTRAN user routines of Code_Saturne, it is possible to realise the correlation directly, which actually implies the previously calculated density value could be read for the viscosity calculating part to use. However, on the other hand, within MEI we don't have a pre-defined symbol, for example rho, to express density when defining a dynamic viscosity mu, and thus we have to expand the rho expression with its original and complicated form into the mu definition expression.

Fortunately, Alexandre gives a patch to implement the idea (see the conversation). After apply the patch accordingly, re-compile ncs, a pre-defined variable rho can then be used for the mu definition. I tested the patch and it works properly.

Post-processing with ParaView

In order to judge whether both methods yield the same effect, the calculation results are analysed. If select to export results into 'EnSight Gold' format, ParaView is going to be used.

ParaView is a cross-platform tool to perform post-processing of numerical simulations. For a beginner I guess it slightly confusing about the mouse controls to move its camera view; at least for me it was true. Actually, select the menu item 'Edit > Settings...' and in the 'Options' dialog ship into the category 'Render View > Camera', can find and modify the controls.


It is not difficult to use ParaView to see the surface plot of a specific parameter, for example, temperature. Select the cell data TempC from the toolbar and the view can then be like this:


From the picture we can see the development of the thermal boundary layer attched to the top and the bottom surfaces of the channel. From the legend the temperature range is found to be 50 to 91.7293 degree C (50 degree C is the inlet temperature), which actually implies the density and viscosity ranges. With MATLAB I estimated them.

>> TempC = [50, 91.7293];
>> rho = 895 ./ (1 + 6.5e-4 .* (TempC - 20))

rho =

  877.8813  855.1304

>> visc = rho .* (0.75857 * (1.8 .* TempC + 32).^-2.34)

visc =

    0.0087    0.0028

Select the data Density and LamVisc in ParaView and see their ranges are 855.12872 to 877.88129 and 0.0027963 to 0.0087367, respectively. They match the results given by MATLAB very well expect the density at 91.7293 degree C, for which there is a very small error, 0.0002%. Thereby, we are happy to see Code_Saturne correctly used the parameter expressions as we expected.

Meanwhile, I compared the results from MEI and FORTRAN user routines, and found their results match exactly, which could imply they have the same effect.

Velocity development along the centreline

Using the filter 'Plot Over Line' we can examine the fluid flow velocity along the centreline of the 2D channel.


Apparently, the velocity rises rapidly at the beginning stage of the channel flow, and then gradually falls. The rise stage is actually within the entrance distance for the flow to be fully developed. On the other hand, the gradual reduction is because of the temperature dependency of the fluid viscosity, as discussed in the previous post "CFD tutorial: laminar flow along a 2D channel - Part I".