﻿ Sample Problems > Usage > Variable_Types > complex_variables

# complex_variables

Navigation:  Sample Problems > Usage > Variable_Types >

# complex_variables   { COMPLEX_VARIABLES.PDE

This example demonstrates the use of complex variables in FlexPDE.

Declaring a variable COMPLEX causes the definition of two subsidiary variables,

either named by default or by use choice.  These variables represent the

real and imaginary parts of the complex variable.

}

title 'Complex variables test'

variables

U = complex (Ur,Ui)   { creates variables (Ur,Ui) }

definitions

u0 = 1-x^2-y^2

s = complex(4,x)

equations

{ create two coupled scalar equations, one for Ur and one for Ui }

U: del2(U) + conj(U) + s = 0

boundaries

Region 1

start(-1,-1)

value(Ur)=u0       { apply BC to Ur.  Ui defaults to natural(Ui)=0 }

line to (1,-1) to (1,1) to (-1,1) to close

plots

contour(Ur,Ui)         { plot both Ur and Ui overlaid }

contour(Real(U),Imag(U))       { an equivalent representation }

contour(U)             { another equivalent representation }

vector(U)               { plot vectors with Ur as X component and Ui as Y component }

elevation(U,s) from(-1,0) to (1,0)   { plot three traces: Ur, Ui and S }

vtk(U,s)               { test various export forms }

transfer(U,s)

end