View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
Curvilinear Coordinates

Be the first to rate this file! 12 Downloads (last 30 days) File Size: 160 KB File ID: #15903 Version: 1.2
image thumbnail

Curvilinear Coordinates



11 Aug 2007 (Updated )

Programs using curvilinear coordinates, and tensor concepts are given.

| Watch this File

File Information

Programs and utility functions employing the Symbolic Math Toolbox are provided to analyze vectors and tensors in general curvilinear coordinates. The programs perform the following functions:
1) runcoord plots intersecting coordinate surfaces for several typical coordinate systems
2) runmetric computes and prints metric tensor properties for a general curvilinear coordinate system specified in a user defined function such as sphr.m
3) rundivcrl verifies agreement of numerical values of divergence and curl of an arbitrary vector computed in both cartesian and curvilinear coordinates
4) runconic plots surfaces illustrating how intersections of a cone and a plane produce conic section curves.
5) Testmetric computes properties for nine different coordinate systems and places the output in runmetric.tst. The symbolic equations from some of the examples are fairly lengthy.
The programs employ a number of other functions to define several coordinate systems (such as cylindrical, spherical, toroidal, conical, parabolic, ellipsoidal, and oblate spheroidal) and to compute base vectors, metric tensors, Christoffel symbols, covariant derivatives, divergence, and curl.
Functions readme.m and listequations.m describe the workspace contents and governing equations. These files, consisting mainly of comments, can be examined by typing their names or using the editor. A longer pdf file, accessible with the command open('TensorNotes.pdf'), develops the classical ideas of curvilinear coordinates and tensor analysis.

Required Products Symbolic Math Toolbox
MATLAB release MATLAB 7.0.1 (R14SP1)
Other requirements These programs should run with Student MATLAB or Professional MATLAB and the Symbolic Toolbox. The software was developed on a computer having 4Gbyte of RAM. Users should remember that symbolic output in some instances can be quite lengthy.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (1)
28 Jul 2011 Theophanes Raptis

How is one supposed to use the curl function in numeric mode? Tried with
syms r t p cs2 real; names=[r t p];
X=[r*sin(t)*cos(p);r*sin(t)*sin(p);r*cos(t)];% Basis of Covariant Vectors

bcov = [[ cos(t), -r*sin(t), 0], [ sin(t), r*cos(t), 0], [ 0, 0, 1]];

% Christoffel Symbols of the Second Kind

cs2 = zeros(3,3,3);

cs2(:,:,1) = [[ 0, 0, 0], [ 0, -r, 0], [ 0, 0, 0]];

cs2(:,:,2) = [[ 0, 1/r, 0], [ 1/r, 0, 0], [ 0, 0, 0]];

cs2(:,:,3) = [[ 0, 0, 0], [ 0, 0, 0], [ 0, 0, 0]];

curls([1, 2 ,3],names,bcovar,cs2,tn)

and gives

>> curltst
??? The following error occurred converting from sym to double:
Error using ==> sym.double at 25
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.

Error in ==> curltst at 11
cs2(:,:,1) = [[ 0, 0, 0], [ 0, -r, 0], [ 0, 0, 0]];

Comment only
10 Feb 2011 1.1

Several code changes were made to improve compatibility with MATLAB 2011. A pdf document presenting tensor analysis concepts was also added.

15 Apr 2014 1.2

The code has been updated to run under MATLAB 8.3(R2014a) using the Symbolic Math Toolbox

Contact us