File Exchange

image thumbnail

Curvilinear Coordinates

version 1.2 (160 KB) by

Programs using curvilinear coordinates, and tensor concepts are given.

8 Downloads

Updated

View License

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.

Comments and Ratings (1)

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]];

Updates

1.2

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

1.1

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

MATLAB Release
MATLAB 7.0.1 (R14SP1)

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

» Watch video