Flex Pde
Flex Pde
Flex Pde
Version 7.18
12/15/2020
Comply ing with all copy right laws is the responsibility of the user. Without limiting the rights under
copy right, no part of this document may be reproduced, stored in or introduced into a retriev al
sy stem, or transmitted in any form or by any means (electronic, mechanical, photocopy ing, or
otherwise) without the ex press written permission of PDE Solutions Inc.
PDE Solutions Inc. may hav e patents, patent applications, trademarks, and copy rights or other
intellectual property rights cov ering subject matter in this document. Ex cept as prov ided in any
written license agreement from PDE Solutions Inc., the furnishing of this document does not giv e y ou
any license to these patents, trademarks, copy rights or other intellectual property .
PDE Solutions, and Flex PDE are either registered trademarks or trademarks of PDE Solutions Inc. in
the United States of America and/or other countries.
Products that are referred to in this document may be either trademarks and/or registered
trademarks of the respectiv e owners. The publisher and the author make no claim to these
trademarks.
While ev ery precaution has been taken in the preparation of this document, the publisher and the
author assume no responsibility for errors or omissions, or for damages resulting from the use of
information contained in this document or from the use of programs and source code that may
accompany it. In no ev ent shall the publisher and the author be liable for any loss of profit or any
other commercial damage caused or alleged to hav e been caused directly or indirectly by this
document.
Note :
This v ersion of this manual is current as of the indicated release date. Electronic v ersions of this manual
together with subsequent release notices in the Flex PDE documentation are av ailable online at
www.pdesolutions.com. Electronic v ersions are updated more frequently than printed v ersions, and may
reflect recent dev elopments in Flex PDE more accurately .
Table of C ontents I
Table of Contents
................................................................................................................................................
How Do I Set Up My Problem? 49
................................................................................................................................................
Problem Setup Guidelines 50
................................................................................................................................................
Notation 51
................................................................................................................................................
Variables and Equations 51
................................................................................................................................................
Mapping the Domain 52
................................................................................................................................................
An Example Problem 53
................................................................................................................................................
Generating A Mesh 54
................................................................................................................................................
Defining Material Parameters 55
................................................................................................................................................
Setting the Boundary Conditions 56
................................................................................................................................................
Requesting Graphical Output 57
................................................................................................................................................
Putting It All Together 58
................................................................................................................................................
Interpreting a Script 62
3 Some Common Variations
....................................................................................................................................... 63
................................................................................................................................................
Controlling Accuracy 63
................................................................................................................................................
Computing Integrals 64
................................................................................................................................................
Reporting Numerical Results 64
................................................................................................................................................
Summarizing Numerical Results 65
................................................................................................................................................
Parameter Studies Using STAGES 65
................................................................................................................................................
Cylindrical Geometry 67
.........................................................................................................................................
Integrals In Cy lindrical Geometry 68
.........................................................................................................................................
A Cy lindrical Ex ample 68
................................................................................................................................................
Time Dependence 71
.........................................................................................................................................
Bad Things To Do In Time Dependent Problems 74
................................................................................................................................................
Eigenvalues and Modal Analysis 75
.........................................................................................................................................
The Eigenv alue Summary 78
4 Addressing More Difficult Problems
....................................................................................................................................... 79
................................................................................................................................................
Nonlinear Coefficients and Equations 79
.........................................................................................................................................
Complications Associated with Nonlinear Problems 81
................................................................................................................................................
Natural Boundary Conditions 82
.........................................................................................................................................
Some Ty pical Cases 83
.........................................................................................................................................
An Ex ample of a Flux Boundary Condition 85
................................................................................................................................................
Discontinuous Variables 86
.........................................................................................................................................
Contact Resistance 87
.........................................................................................................................................
Decoupling 89
.........................................................................................................................................
Using JUMP in problems with many v ariables 89
5 Using FlexPDE in One-Dimensional Problems
....................................................................................................................................... 91
6 Using FlexPDE in Three-Dimensional Problems
....................................................................................................................................... 92
................................................................................................................................................
The Concept of Extrusion 93
................................................................................................................................................
Extrusion Notation in FlexPDE 93
Table of C ontents III
................................................................................................................................................
Layering 95
................................................................................................................................................
Setting Material Properties by Region and Layer 96
................................................................................................................................................
Void Compartments 97
................................................................................................................................................
Limited Regions 98
................................................................................................................................................
Specifying Plots on Cut Planes 99
................................................................................................................................................
The Complete 3D Canister 1 00
................................................................................................................................................
Setting Boundary Conditions in 3D 1 03
................................................................................................................................................
Shaped Layer Interfaces 1 06
................................................................................................................................................
Surface-Generating Functions 1 08
................................................................................................................................................
Integrals in Three Dimensions 1 09
................................................................................................................................................
More Advanced Plot Controls 113
7 Complex Variables
....................................................................................................................................... 114
................................................................................................................................................
The Time-Sinusoidal Heat 116
................................................................................................................................................
Interpreting Time-Sinusoidal Results 119
8 Vector Variables
....................................................................................................................................... 1 21
................................................................................................................................................
Curvilinear Coordinates 1 23
................................................................................................................................................
Magnetic Vector Potential 1 23
9 Variables Inactive in Some Regions
....................................................................................................................................... 1 26
................................................................................................................................................
A Chemical Beaker 1 26
10 Moving Meshes
....................................................................................................................................... 1 30
................................................................................................................................................
Mesh Balancing 1 31
................................................................................................................................................
The Pulsating Blob 1 32
11 Controlling Mesh Density
....................................................................................................................................... 1 34
12 Post-processing with FlexPDE
....................................................................................................................................... 1 36
................................................................................................................................................
Problem Descriptor Structure 1 51
................................................................................................................................................
Problem Descriptor Format 1 52
................................................................................................................................................
Case Sensitivity 1 52
................................................................................................................................................
"Include" Files 1 52
................................................................................................................................................
A Simple Example 1 53
2 The Elements of a Descriptor
....................................................................................................................................... 1 54
................................................................................................................................................
Comments 1 54
................................................................................................................................................
Reserved Words and Symbols 1 55
................................................................................................................................................
Separators 1 58
................................................................................................................................................
Literal Strings 1 58
................................................................................................................................................
Numeric Constants 1 59
................................................................................................................................................
Built-in Functions 1 59
.........................................................................................................................................
Analy tic Functions 1 60
.........................................................................................................................................
Non-Analy tic Functions 1 61
.........................................................................................................................................
Unit Functions 1 63
.........................................................................................................................................
String Functions 1 63
.........................................................................................................................................
The FIT Function 1 64
.........................................................................................................................................
The LUMP Function 1 65
.........................................................................................................................................
The RAMP Function 1 65
.........................................................................................................................................
The SAV E Function 1 66
.........................................................................................................................................
The SUM Function 1 67
.........................................................................................................................................
The SWAGE Function 1 67
.........................................................................................................................................
The V AL and EV AL functions 1 68
.........................................................................................................................................
Boundary Search Functions 1 69
................................................................................................................................................
Operators 1 69
.........................................................................................................................................
Arithmetic Operators 1 69
.........................................................................................................................................
Complex Operators 1 69
.........................................................................................................................................
Differential Operators 17 0
.........................................................................................................................................
Integral Operators 17 2
Tim e Integrals
...................................................................................................................................... 17 2
Line Integrals
...................................................................................................................................... 17 2
2 D Surface Integrals
...................................................................................................................................... 17 3
3 D Surface Integrals
...................................................................................................................................... 17 4
2 D Volum e Integrals
...................................................................................................................................... 17 5
3 D Volum e Integrals
...................................................................................................................................... 17 5
.........................................................................................................................................
Relational Operators 17 6
.........................................................................................................................................
String Operators 17 6
.........................................................................................................................................
V ector Operators 17 7
.........................................................................................................................................
Tensor Operators 17 9
................................................................................................................................................
Predefined Elements 1 80
................................................................................................................................................
Expressions 1 80
................................................................................................................................................
Repeated Text 1 81
Table of C ontents V
................................................................................................................................................
Boundaries 226
.........................................................................................................................................
Points 226
.........................................................................................................................................
Boundary Paths 227
.........................................................................................................................................
Regions 229
Reassigning Regional Param eters
...................................................................................................................................... 230
Regions in One Dim ension
...................................................................................................................................... 230
Regions in Three Dim ensions
...................................................................................................................................... 231
Regional Param eter Values in 3 D
...................................................................................................................................... 231
Lim ited Regions in 3 D
...................................................................................................................................... 232
Em pty Lay ers in 3 D
...................................................................................................................................... 233
.........................................................................................................................................
Ex cludes 233
.........................................................................................................................................
Features 233
.........................................................................................................................................
Node Points 234
.........................................................................................................................................
Ordering Regions 234
.........................................................................................................................................
Numbering Regions 235
.........................................................................................................................................
Fillets and Bev els 235
.........................................................................................................................................
Specify ing Boundary Conditions 236
Sy ntax of Boundary Condition Statem ents
...................................................................................................................................... 237
Point Boundary Conditions
...................................................................................................................................... 237
Boundary conditions in 1 D
...................................................................................................................................... 238
Boundary Conditions in 3 D
...................................................................................................................................... 238
Jum p Boundaries
...................................................................................................................................... 239
Periodic Boundaries
...................................................................................................................................... 240
Com plex and Vector Boundary Conditions
...................................................................................................................................... 242
................................................................................................................................................
Front 242
................................................................................................................................................
Maximize 242
................................................................................................................................................
Minimize 243
................................................................................................................................................
Resolve 243
................................................................................................................................................
Time 244
................................................................................................................................................
Monitors and Plots 245
.........................................................................................................................................
Graphics Display Specifications 246
.........................................................................................................................................
Graphic Display Modifiers 248
.........................................................................................................................................
Controlling the Plot Domain 254
.........................................................................................................................................
Reports 257
.........................................................................................................................................
The ERROR V ariable 258
.........................................................................................................................................
Window Tiling 258
.........................................................................................................................................
Monitors in Steady State Problems 258
.........................................................................................................................................
Monitors and Plots in Time Dependent Problems 258
.........................................................................................................................................
Hardcopy 259
.........................................................................................................................................
Graphics Ex port 259
.........................................................................................................................................
Data Ex port 260
Data Export Specifications
...................................................................................................................................... 260
TRANSFER File form at
...................................................................................................................................... 262
TRANSFER6 File form at
...................................................................................................................................... 266
.........................................................................................................................................
Ex amples 269
................................................................................................................................................
Histories 27 0
Table of C ontents VII
................................................................................................................................................
End 27 1
4 Batch Processing
....................................................................................................................................... 27 1
12 Coordinate Scaling
....................................................................................................................................... 354
13 Making Movies
....................................................................................................................................... 356
.........................................................................................................................................
lowv isc 404
.........................................................................................................................................
swirl 406
.........................................................................................................................................
v iscous 408
................................................................................................................................................
Groundwater 41 0
.........................................................................................................................................
porous 41 0
.........................................................................................................................................
richards 41 0
.........................................................................................................................................
water 41 1
................................................................................................................................................
Heatflow 41 2
.........................................................................................................................................
1 d_float_zone 41 2
.........................................................................................................................................
3d_bricks 41 4
.........................................................................................................................................
3d_bricks+time 41 5
.........................................................................................................................................
ax isy mmetric_heat 41 6
.........................................................................................................................................
float_zone 41 7
.........................................................................................................................................
heat_boundary 41 8
.........................................................................................................................................
radiation_flow 420
.........................................................................................................................................
radiativ e_boundary 421
.........................................................................................................................................
slider 422
................................................................................................................................................
Lasers 423
.........................................................................................................................................
laser_heatflow 423
.........................................................................................................................................
self_focus 425
................................................................................................................................................
Magnetism 426
.........................................................................................................................................
3d_helmholtz_coil 426
.........................................................................................................................................
3d_magnetron 428
.........................................................................................................................................
3d_v ector_magnetron 429
.........................................................................................................................................
magnet_coil 430
.........................................................................................................................................
permanent_magnet 432
.........................................................................................................................................
saturation 433
................................................................................................................................................
Misc 435
.........................................................................................................................................
diffusion 435
.........................................................................................................................................
minimal_surface 436
.........................................................................................................................................
surface_fit 437
................................................................................................................................................
Quantun_Mechanics 438
.........................................................................................................................................
1 d_finite_potential_well 438
.........................................................................................................................................
2d_finite_potential_well 439
.........................................................................................................................................
morse_potential 440
................................................................................................................................................
Stress 441
.........................................................................................................................................
3d_bimetal 441
.........................................................................................................................................
anisotropic_stress 444
.........................................................................................................................................
ax isy mmetric_stress 446
.........................................................................................................................................
bentbar 447
.........................................................................................................................................
bentbar_mov ing 449
.........................................................................................................................................
elasticity 450
.........................................................................................................................................
fix ed_plate 453
.........................................................................................................................................
free_plate 455
X FlexP DE 7
.........................................................................................................................................
harmonic 456
.........................................................................................................................................
prestube 458
.........................................................................................................................................
tension 459
.........................................................................................................................................
v ibrate 461
2 Usage
....................................................................................................................................... 464
................................................................................................................................................
1D 464
.........................................................................................................................................
1 d_cy linder 464
.........................................................................................................................................
1 d_cy linder_transient 464
.........................................................................................................................................
1 d_float_zone 465
.........................................................................................................................................
1 d_slab 466
.........................................................................................................................................
1 d_sphere 466
................................................................................................................................................
3D_domains 467
.........................................................................................................................................
2d_sphere_in_cy linder 467
.........................................................................................................................................
3d_box _in_sphere 467
.........................................................................................................................................
3d_cocktail 469
.........................................................................................................................................
3d_cy lspec 469
.........................................................................................................................................
3d_ellipsoid 47 0
.........................................................................................................................................
3d_ellipsoid_shell 47 1
.........................................................................................................................................
3d_ex trusion_spec 47 2
.........................................................................................................................................
3d_fillet 47 3
.........................................................................................................................................
3d_guitar 47 3
.........................................................................................................................................
3d_helix _lay ered 47 5
.........................................................................................................................................
3d_helix _wrapped 47 8
.........................................................................................................................................
3d_lenses 480
.........................................................................................................................................
3d_limited_region 480
.........................................................................................................................................
3d_pinchout 481
.........................................................................................................................................
3d_planespec 482
.........................................................................................................................................
3d_py ramid 483
.........................................................................................................................................
3d_shell 484
.........................................................................................................................................
3d_shells 485
.........................................................................................................................................
3d_sphere 487
.........................................................................................................................................
3d_spherebox 488
.........................................................................................................................................
3d_spherespec 489
.........................................................................................................................................
3d_spool 490
.........................................................................................................................................
3d_thermocouple 491
.........................................................................................................................................
3d_toggle 492
.........................................................................................................................................
3d_torus 493
.........................................................................................................................................
3d_torus_tube 494
.........................................................................................................................................
3d_twist 496
.........................................................................................................................................
3d_v oid 497
.........................................................................................................................................
regional_surfaces 499
.........................................................................................................................................
tabular_surfaces 500
.........................................................................................................................................
two_spheres 501
.........................................................................................................................................
twoz_direct 502
Table of C ontents XI
.........................................................................................................................................
twoz_import 503
.........................................................................................................................................
twoz_ex port 505
.........................................................................................................................................
twoz_planar 506
................................................................................................................................................
Accuracy 507
.........................................................................................................................................
forev er 507
.........................................................................................................................................
gaus1 d 508
.........................................................................................................................................
gaus2d 508
.........................................................................................................................................
gaus3d 509
.........................................................................................................................................
sine1 d 51 0
.........................................................................................................................................
sine2d 51 1
.........................................................................................................................................
sine3d 51 2
................................................................................................................................................
Arrays+Matrices 51 3
.........................................................................................................................................
array s 51 3
.........................................................................................................................................
array _boundary 51 3
.........................................................................................................................................
matrices 51 4
.........................................................................................................................................
matrix _boundary 51 5
.........................................................................................................................................
wav e_boundary 51 6
................................................................................................................................................
CAD_Import 51 6
.........................................................................................................................................
arrow_OBJimport 51 6
.........................................................................................................................................
box inbox _OBJimport 51 7
.........................................................................................................................................
canincan_OBJimport 51 7
.........................................................................................................................................
cube_OBJimport 51 8
.........................................................................................................................................
cube2_OBJimport 51 8
.........................................................................................................................................
cube2_v alidate 51 9
.........................................................................................................................................
cubes_bigsmall_OBJimport 520
.........................................................................................................................................
cubes_bigsmall_v alidate 520
.........................................................................................................................................
gourd_OBJimport 521
.........................................................................................................................................
helix _OBJimport 522
.........................................................................................................................................
horn_OBJimport 523
.........................................................................................................................................
torus_OBJimport 524
.........................................................................................................................................
tubefaces_OBJimport 524
.........................................................................................................................................
wineglass_OBJimport 525
................................................................................................................................................
Constraints 526
.........................................................................................................................................
3d_constraint 526
.........................................................................................................................................
3d_surf_constraint 527
.........................................................................................................................................
boundary _constraint 528
.........................................................................................................................................
constraint 529
................................................................................................................................................
Contact_Boundaries 529
.........................................................................................................................................
3d_contact 529
.........................................................................................................................................
3d_contact_region 531
.........................................................................................................................................
contact_resistance_heating 532
.........................................................................................................................................
thermal_contact_resistance 533
.........................................................................................................................................
transient_contact_resistance_heating 534
................................................................................................................................................
Coordinate_Scaling 535
XII FlexP DE 7
.........................................................................................................................................
scaled_z 535
.........................................................................................................................................
unscaled_z 537
................................................................................................................................................
Eigenvalues 538
.........................................................................................................................................
3d_oildrum 538
.........................................................................................................................................
3d_plate 539
.........................................................................................................................................
drumhead 541
.........................................................................................................................................
drumhole 542
.........................................................................................................................................
filledguide 542
.........................................................................................................................................
shiftguide 544
.........................................................................................................................................
v ibar 545
.........................................................................................................................................
wav eguide 547
.........................................................................................................................................
wav eguide20 548
................................................................................................................................................
Functions 549
.........................................................................................................................................
complex _functions 549
.........................................................................................................................................
function_definition 550
.........................................................................................................................................
error_reporting 550
.........................................................................................................................................
globalmax 552
.........................................................................................................................................
globalmax _3d 553
.........................................................................................................................................
standard_functions 554
.........................................................................................................................................
sum 555
.........................................................................................................................................
swage_pulse 556
.........................................................................................................................................
swage_test 557
.........................................................................................................................................
unit_functions 557
.........................................................................................................................................
v ector_functions 558
................................................................................................................................................
Implicit_Curves 559
.........................................................................................................................................
implicit_curv e_boundary 559
.........................................................................................................................................
implicit_curv e_surface 559
.........................................................................................................................................
sine_boundary 560
.........................................................................................................................................
sine_boundary _3d 561
................................................................................................................................................
Import_Export 561
.........................................................................................................................................
3d_mesh_ex port 561
.........................................................................................................................................
3d_mesh_import 562
.........................................................................................................................................
3d_post_processing 563
.........................................................................................................................................
3d_surf_ex port 564
.........................................................................................................................................
blocktable 565
.........................................................................................................................................
ex port 566
.........................................................................................................................................
ex port_format 566
.........................................................................................................................................
ex port_history 567
.........................................................................................................................................
mesh_ex port 568
.........................................................................................................................................
mesh_import 569
.........................................................................................................................................
post_processing 57 0
.........................................................................................................................................
smoothtable 57 1
.........................................................................................................................................
splinetable 57 1
.........................................................................................................................................
table 57 2
Table of C ontents XIII
.........................................................................................................................................
tabledef 57 3
.........................................................................................................................................
table_ex port 57 3
.........................................................................................................................................
table_import 57 4
.........................................................................................................................................
transfer_ex port 57 4
.........................................................................................................................................
transfer_import 57 5
................................................................................................................................................
Integrals 57 6
.........................................................................................................................................
2d_integrals 57 6
.........................................................................................................................................
3d_integrals 57 8
.........................................................................................................................................
time_integral 57 9
................................................................................................................................................
Mesh_Control 580
.........................................................................................................................................
3d_curv ature 580
.........................................................................................................................................
boundary _density 581
.........................................................................................................................................
boundary _spacing 582
.........................................................................................................................................
front 582
.........................................................................................................................................
mesh_density 584
.........................................................................................................................................
mesh_spacing 584
.........................................................................................................................................
resolv e 585
................................................................................................................................................
Misc 586
.........................................................................................................................................
askuser 586
.........................................................................................................................................
bc_sets 587
.........................................................................................................................................
bc_switching 588
.........................................................................................................................................
data_fitting 589
.........................................................................................................................................
fillet 590
.........................................................................................................................................
fit+weight 591
.........................................................................................................................................
ifthen 591
.........................................................................................................................................
lump 592
.........................................................................................................................................
material_sets 593
.........................................................................................................................................
point_load 593
.........................................................................................................................................
polar_coordinates 594
.........................................................................................................................................
repeat 594
.........................................................................................................................................
rotated_ellipse 595
.........................................................................................................................................
sav e 596
.........................................................................................................................................
spacetime1 597
.........................................................................................................................................
spacetime2 598
.........................................................................................................................................
spline_boundary 599
.........................................................................................................................................
staged_geometry 600
.........................................................................................................................................
stages 600
.........................................................................................................................................
tabulate 601
.........................................................................................................................................
tensors 602
.........................................................................................................................................
two_histories 603
................................................................................................................................................
Moving_Mesh 604
.........................................................................................................................................
1 d_stretch_x 604
.........................................................................................................................................
2d_blob_position 605
.........................................................................................................................................
2d_blob_v elocity 606
XIV FlexP DE 7
.........................................................................................................................................
2d_lagrangian_shock 607
.........................................................................................................................................
2d_mov epoint 608
.........................................................................................................................................
2d_stretch_x 609
.........................................................................................................................................
2d_stretch_x y 61 0
.........................................................................................................................................
3d_blob_position 61 2
.........................................................................................................................................
3d_blob_v elocity 61 3
................................................................................................................................................
ODE 61 4
.........................................................................................................................................
linearode 61 4
.........................................................................................................................................
nonlinode 61 5
.........................................................................................................................................
second_order_time 61 6
................................................................................................................................................
Optimization 61 7
.........................................................................................................................................
criticality 61 7
.........................................................................................................................................
criticality _size 61 8
.........................................................................................................................................
power_control 620
.........................................................................................................................................
size_control 621
................................................................................................................................................
Periodicity 622
.........................................................................................................................................
3d_antiperiodic 622
.........................................................................................................................................
3d_x periodic 623
.........................................................................................................................................
3d_zperiodic 624
.........................................................................................................................................
antiperiodic 625
.........................................................................................................................................
azimuthal_periodic 626
.........................................................................................................................................
periodic+time 627
.........................................................................................................................................
periodic 628
.........................................................................................................................................
periodic_map 629
.........................................................................................................................................
two-way _periodic 630
................................................................................................................................................
Plotting 630
.........................................................................................................................................
3d_ploton 630
.........................................................................................................................................
ex port_test 631
.........................................................................................................................................
plot_on_grid 632
.........................................................................................................................................
plot_test 633
................................................................................................................................................
Sequenced_Equations 634
.........................................................................................................................................
equation_iteration 634
.........................................................................................................................................
initialeq 636
.........................................................................................................................................
smoothing_discontinuities 637
.........................................................................................................................................
theneq+time 638
.........................................................................................................................................
theneq 639
................................................................................................................................................
Stop+Restart 640
.........................................................................................................................................
restart_ex port 640
.........................................................................................................................................
restart_import 641
................................................................................................................................................
Variable_Types 643
.........................................................................................................................................
array _v ariables 643
.........................................................................................................................................
complex _emw21 644
.........................................................................................................................................
complex _sinusoidal_heat 644
.........................................................................................................................................
complex _v ariables 645
Table of C ontents XV
.........................................................................................................................................
complex +time 646
.........................................................................................................................................
inactiv e_v ariables 646
.........................................................................................................................................
v ector_lowv isc 648
.........................................................................................................................................
v ector_v ariables 649
.........................................................................................................................................
v ector+time 649
Index 651
Part
I
Getting Started
G etting Started : 2
1 Getting Started
This section presents an overview of how to install and interact with FlexPDE on your computer. It does
not address the issues of how to pose a partial differential equations problem in the scripting language of
FlexPDE. These issues are addressed in the sections User Guide 44 and Problem Descriptor Reference
149 .
1.1 Installation
The general principles of installation for FlexPDE are the same across all platforms: the set of installation
files must be extracted from the compressed distribution archive and placed in the system file hierarchy.
The details of how this is done vary with computer platform.
There are two media options for FlexPDE installation:
Installation from Internet download
Browse www.pdesolutions.com to the download page. Click the file name of the desired version,
and store the downloaded file at a convenient place in your file system. For more information, click
the "Installation Guide" link next to the version download you have chosen.
The optional CDROM has an installation page that is organized in the same fashion as the website
download page. Open the main index page and browse to the "Installation" page. Click the file name
of the desired version, and run the file (or store the downloaded file at a convenient place in your file
system then run it). For more information, click the "Installation Guide" link next to the version
download you have chosen.
In addition to the "FlexPDE7" application folder, the installer will create a "FlexPDE7user" folder
containing a duplicate copy of the sample scripts and the FlexPDE user settings file ("flexpde7.ini"). On
Windows this will be in the user's "Documents" folder.
Windows
The FlexPDE installation program will place an icon on your desktop, as well as an entry in the Start
menu. You can start FlexPDE by double-clicking the desktop icon, or single-clicking the Start menu
entry. Alternatively, you can use the File Manager to navigate to the folder where FlexPDE was
installed, and then double-click on the file "FlexPDE7.exe" (the default installation location is "C:
\Program Files\FlexPDE7).
3 FlexP DE 7 : G etting Started
The installation program will also create associations of the ".pde" and ".pg7" extensions with the
installed FlexPDE executable, so that FlexPDE can be started by double-clicking any file of these
types in the File Manager.
Mac OS X
FlexPDE is installed in the "Applications/FlexPDE7" folder by default, but you can choose to install it
in any location you wish. Navigate to this folder and open the FlexPDE7 application.
The installation program will also create associations of the ".pde" and ".pg7" extensions with the
installed FlexPDE application, so that FlexPDE can be started by double-clicking any file of these
types in the Finder.
Linux
FlexPDE is installed in the directory you choose when extracting the archive. You can start
FlexPDE by typing a command line in a console window, or from the file manager by navigating to
the installation directory and opening the FlexPDE7 application.
Associations of the ".pde" and ".pg7" extensions with FlexPDE7 can be made manually using the
standard procedures of the operating system. You can also place a FlexPDE icon on your desktop
using the "fpde7icon.png" file included in the installation files.
When you start FlexPDE (or go to the "About FlexPDE" 6 menu), you will see a screen like this:
G etting Started : Starting FlexP DE 4
The About banner reports the version number, license class, OS platform, and date of creation of the
running version of FlexPDE.
The main window caption bar will also report the license class, version, OS platform, and license level
(1D, 2D, or 3D, depending on the current licensing level of the running program*). Temporary licenses
will display the time remaining in the license.
The main window presents a standard menu bar and a tool bar, most items of which at this point are
disabled, unless you have opened FlexPDE with a file-click.
* Note: Software and Internet keys are read at invocation of FlexPDE. Dongles are merely checked for
their presence but a license is not acquired until a problem is run. At that time a license of the required
level, 1D, 2D or 3D will be requested and displayed in FlexPDE's About banner and title bar.
FlexPDE reads a model description from a script file with the extension ".pde". This file is created by
the user and contains the full description of the model to be run. The name of this file establishes the
5 FlexP DE 7 : G etting Started
<problem name> used by the other files. This is a UTF-8 text file and can be opened with any text
editor. This file should not be modified by formatting editors like Word as they may insert illegal
characters. If using an alternate editor that supports unicode etc., be sure to save it in UTF-8 format
not one of the many other page codings.
Output
.PG7
FlexPDE writes primary graphical output into a file with the extension ".pg7". This file can be viewed
later and used to print or export graphical data to various other formats. The format of this file is
unique to FlexPDE and cannot be read by other programs.
_LOG.TXT
FlexPDE writes a summary of the progress of each run into a text file with the extension "_log.txt".
This file contains information about time steps, error estimates, memory use and other data. This is an
ordinary text file and can be opened with any text editor. In previous versions this file had the
extension ".log".
_DEBUG.TXT
FlexPDE writes a more elaborate summary of each run into a file with the extension "_debug.txt".
This file is sometimes useful in determining errors or locating trouble spots in the domain. This is an
ordinary text file and can be opened with any text editor. In previous versions this file had the
extension ".dbg".
_EIG.TXT
In eigenvalue problems, FlexPDE writes a summary of final system eigenvalues into a file with the
extension "_eig.txt". This is an ordinary text file and can be opened with any text editor. In previous
versions this file had the extension ".eig".
_INITIALMESH.XFR
If requested in the Preferences General Settings 29 tab, FlexPDE will automatically export a transfer
file of the initial mesh into a file with the extension "_initialmesh.xfr" and reload this file when possible
to save time creating the initial grid.
G etting Started : FlexP DE Working Files 6
_RESTART.XFR
If requested in the Preferences General Settings 29 tab, when FlexPDE completes a problem it will
automatically export a RESTART 213 transfer file with all variables into a file with the extension
"_restart.xfr". This file can be used for post-processing of the solution data when needed.
Note: By default Windows hides the file name extensions, relying on distinctive icons to indicate file
type. Windows can be configured to show file extensions and we encourage users to do this. FlexPDE
has unique icons for ".pde" and ".pg7" files, but not for the other files.
The items of the main menu present many of the conventional functions of graphical applications. The
availability and precise meaning of these menu items depends on the current state of processing of the
problem. We summarize the menu items here, and describe them in more detail in the following sections.
File
The "File" menu item allows you to begin operation by opening a problem descriptor file, importing a
DXF file, importing an OBJ file, or viewing previously stored graphical output from a FlexPDE run.
It also allows you to save your work or exit the application. These operations are performed using
standard dialogs of the computer operating system. (See "The File Menu" 7 )
Controls
This menu contains an assortment of functions that may be performed during the generation and
running of a problem descriptor, such as running the script or switching between edit and plot modes.
(See "The Controls Menu" 10 )
View
When a stored FlexPDE graphics file has been opened, the View menu item will present a menu of
options for controlling the display of the stored images. (See "Viewing Saved Graphic Files" 26 )
Stop
While a problem is being run, the Stop menu item will display a selection of termination strategies of
various levels of urgency. (See "The Stop Menu" 12 )
7 FlexP DE 7 : G etting Started
Edit
When a descriptor is being edited, this menu provides standard editing commands. (See "Editing
Descriptor Files" 14 )
Help
The Help menu contains five items as shown below:
On Windows, the "Help" sub-item will initiate the help system. On Mac and Linux, you must
manually initiate your browser and direct it to "Help | Html | Index.html" in the FlexPDE installation
directory.
The "Preferences" sub-item allows you to inspect or modify the various FlexPDE preferences.
(See "Preferences Window" 28 )
The "Register FlexPDE" sub-item brings you to the License Registration Preferences tab and
allows you to inspect or modify the FlexPDE license registration. (See "License Registration Tab"
32 )
The "Read License Agreement" sub-item displays the End-User License Agreement.
The "About FlexPDE" sub-item redisplays the About banner 2 . Note that on Mac this item
appears in the FlexPDE "Application" menu.
The File Menu allows the creation of new files, opening existing files, saving and closing active problems,
importing DXF and OBJ files, and viewing saved graphics:
G etting Started : The Main Menu Bar 8
Open File
This menu item can be used to open an existing descriptor file (either to modify it or to run the
problem), to open a stored graphics file for viewing, or to open a DXF or OBJ file for import. A
standard Open_File dialog will appear. Navigate to the folder which contains the descriptor you
wish to open. For example, navigating to the standard samples folder "Samples | Usage |
3D_domains" will display the following screen:
9 FlexP DE 7 : G etting Started
(If your system is configured to hide file extensions, you will not see the ".pde" part of the file names,
but you can still recognize the FlexPDE icon.)
The default display shows script files (.pde extension). You can select other file types using the
dropdown list. (On Macintosh or Linux, the selection of alternate file types is slightly different, but
follows the customary methods for the operating system.) Double-click on the file of your choice, or
single-click and click Open. A new tab will be displayed, showing the name of the selected problem
file. You can switch between tabs at will. You can open as many descriptors as you wish, and any
number of them can be running at the same time. Files can also be opened by drag-and-dropping
them onto the running FlexPDE application. See the following section "Editing Descriptor Files" 14
for more information on editing the open file.
Open Recent
This dynamically updated sub menu will present the last 20 files opened by FlexPDE. Selecting one
will cause that file to be opened as if it were selected in the open dialog or it was drag-and-dropped
onto the FlexPDE window.
Save Script
Use this menu item to save a descriptor which you have modified. The currently displayed file is
saved in place of the original file. This function is automatically activated when a problem is run.
G etting Started : The Main Menu Bar 10
Save As
Use this menu item to save to a descriptor to a new file name. If you have modified it, the original
source file will remain unchanged.
Close
Use this menu item to remove the currently displayed problem and disconnect from the associated
files.
Print Script
Use this menu item to print a copy of the current script.
Print Preview
Use this menu item to preview the printing of the current script.
Print Setup
Use this menu item to set page information for script printing.
Import
Use this menu item to import descriptors from other formats. The DXF option will import a
descriptor from AutoCad version R14. See the Technical Note "Importing DXF Files" 285 for more
information. The OBJ option will create a descriptor to load the selected OBJ mesh file. See the
Technical Note "Importing OBJ Files" 286 for more information. (These functions are the same as
"Open File" with the DXF or OBJ file type selected.)
View
Use this menu item to open a file of saved graphical output from a FlexPDE problem which was run
and completed at an earlier time. A standard Open_File dialog will appear. Navigate the folder
containing the desired ".pg7" file. Double-click on the file of your choice, or single-click and click
Open. See the following section "Viewing Saved Graphics Files" 26 for more information. You may
View more than one saved problem, and you may open files for viewing while other descriptors are
open, but you should not open the same problem for simultaneous viewing and running, since file
access conflicts may occur. (This function is the same as "Open File" with the "Graphics" file type
selected.)
Exit
Click here to terminate your FlexPDE session. All open descriptors and Views will be closed. If
changes have been made and not saved, you will be prompted.
The Controls menu presents several optional functions for processing descriptors.
11 FlexP DE 7 : G etting Started
FlexPDE has two different operating modes, Edit and Plot. When in edit mode, the text of the current
descriptor is displayed for editing. When in Plot mode, graphics are displayed, either the monitors and
plots being constructed as a problem runs, or the final state of plots when a run is completed.
Domain Review
This is a modified form of the "Run" item. When FlexPDE is in Edit mode, the Domain Review menu
item will begin processing the displayed problem descriptor, halting at various stages of the mesh
generation to display the current state of the mesh construction. This is an aid to constructing
problem domains. (See topic "Domain Review" 16 below.)
Run Script
When FlexPDE is in Edit mode, the Run Script menu item will begin processing of the displayed
problem descriptor. Execution will proceed without interruption through the mesh generation,
execution and graphic display phases. (See topic "While the Problem Runs" 19 below.)
Show Editor
When a problem is in Plot mode with graphics being displayed, the Show Editor menu item will enter
Edit mode and display the current problem text. (See topic "Editing Scripts" 14 below.) If the
problem is stopped or has not yet been run, the tab will show the icon. If the problem is running
while the editor is displayed, the icon will display on the problem tab.
Show Plots
When a problem is in the Edit mode, the Show Plots menu item will switch to Plot mode and display
the current state of the problem graphics. (See topic "While the Problem Runs" 19 below.)
Stop Batch
When a batch script is running, the Stop Batch menu item will stop the batch after the currently
running script finishes. This is particularly important when each individual problem in the batch runs
quickly and the user cannot intercept the Stop button of the currently running script. (See topic
"Batch Processing" 271 .)
G etting Started : The Main Menu Bar 12
When a problem is running, it is sometimes necessary to request an abnormal termination of the solution
process. This may be because the user has discovered an error in his problem setup and wishes to
modify it and restart, or because the solution is satisfactory for his needs and additional computation
would be unnecessary.
The Stop menu provides several ways to do this, with the most imperative controls at the top,
descending to less immediate terminations:
The contents of this menu will depend on the type of problem that is being run. Below are the most
common.
Stop Now!
This is a panic stop that causes processing to be interrupted as soon as possible. No attempt is
made to complete processing or write output. You will be given a chance to change your mind:
Stop Solver
The current iteration phase will be terminated, and the processing will be completed as if
convergence had been achieved. Final plots will be written, and FlexPDE will halt in Plot mode.
13 FlexP DE 7 : G etting Started
Finish Modes
Only available in eigenvalue 75 problems. Halt after the last eigenvalue for the current iteration has
been completed.
Finish Iteration
At the conclusion of the current iteration phase, the processing will be completed as if convergence
had been achieved. Final plots will be written, and FlexPDE will halt in Plot mode.
Finish Grid
Processing will continue until convergence requirements have been met for the current mesh. No
additional adaptive mesh refinement will be attempted, and the problem will terminate as if final
convergence had been achieved. Final plots will be written, and FlexPDE will halt in Plot mode.
Finish Stage
In a "Staged" 65 problem (q.v.), the current stage will be completed, including any necessary mesh
refinement. Final plots will be written for the current stage, but no more stages will be begun.
FlexPDE will halt in Plot mode.
Finish Timestep
Only available in time dependent 71 problems. Processing will continue for the current timestep, then
calculation will end as if the final time had been reached.
Pause
FlexPDE will stop processing and go into an idle state waiting for a mouse click response to the
displayed dialog:
"Continue" will resume processing at the point where it was interrupted. "Edit" will terminate
processing as if "Stop Now!" had been clicked. This function can be used to temporarily free
computer resources for a more important task without terminating the FlexPDE run.
G etting Started : The Tool Bar 14
The buttons in the tool bar replicate some of the common entries in the various menus:
The tool bar icons also appear on the menu bar entries with corresponding function.
A FlexPDE problem descriptor file is a complete description of the PDE modeling problem. It describes
the system of partial differential equations, the parameters and boundary conditions used in the solution,
the domain of the problem, and the graphical output to generate. See the section "User Guide 44 " for a
tutorial on the use of FlexPDE problem descriptors. See the section "Problem Descriptor Reference 149 "
for a complete description of the format and content of the descriptor file.
15 FlexP DE 7 : G etting Started
You can open a descriptor file in either of two ways: 1) by running FlexPDE from the desktop icon or
from your file manager program, and then following the "File|Open" menu sequence; or 2) if an
association of FlexPDE with the ".pde" extension has been made, either automatically in Windows or
manually in other operating systems, you can double-click on the .pde file in your file manager. In either
case, the descriptor file will be opened, a new tab will be created, and an edit window will appear.
For example, suppose we follow the "Open" sequence to the "Samples | Usage | 3D_domains" folder
and select "3d_void.pde". The newly opened problem file will be recorded in a tab along the top of the
window, allowing it to be selected if a number of scripts are open simultaneously.
This is a standard editing window, showing the contents of the selected descriptor. You can scroll and
edit in the usual way. FlexPDE keywords are highlighted in red, comments in green, and text strings in
blue.
The "Edit" item in the main menu contains the editing functions:
G etting Started : Editing Descriptor Files 16
The menu items have the conventional meanings, and the control key equivalents are shown.
The Find and Font items have the following use:
Find
This item allows you to search the file for occurrences of a string. The search will find imbedded
patterns, not just full words.
Font
This item will take you directly to the Font Settings Tab 30 of the Preferences Panel.
In addition to the main menu Edit item, you can right-click the text window to bring up the same editing
menu.
At any time, you can click "File | Save" or "File |Save_As..." in the main menu to save your work before
proceeding.
Now click "Domain Review" or "Run Script" in the Controls menu, and your problem will begin
execution.
The file will be automatically saved in the currently open file, so if you wish to retain the unedited file, you
must use "Save_As" before "Run".
Note: The FlexPDE script editor is a "programming" editor, not a word processor. There are
no sophisticated facilities for text manipulation.
2D Problems
When you click "Domain Review", the descriptor file will be saved to disk, and the domain construction
phase will begin. FlexPDE will halt with a display of the domain boundaries specified in the descriptor.
If these are as you intended, click "Continue". If they are not correct, click "Edit", and you will be
returned to the edit phase to correct the domain definition. If you continue, the mesh generation process
will be activated, and FlexPDE will halt again to display the final mesh. Again, you can continue or return
to the editor.
3D Problems
The 3D domain review is more extensive. Echoing the mesh generation process used in FlexPDE, the
review will halt after each of the following stages:
A domain plot showing the boundaries of each extrusion surface and layer in order from lower to
higher Z coordinate. The surface plots show the boundaries that exist in the surface. The layer plot
shows the boundaries that extend through the layer and therefore form material compartments. If at
any point you detect an error, you can click "Edit" to return to the editor and correct the error.
After the display of individual surfaces and layers, you will be presented a composite view of all the
boundaries of the domain, which might look like this:
G etting Started : Domain Review 18
Once the domain boundaries are correct, FlexPDE will proceed to the generation of the 2D finite
element mesh for each extrusion surface. These will be displayed in order from lower to upper
surfaces. You can return to "Edit" after any surface.
Once the surface meshes are correct, FlexPDE will proceed to the generation of the 3D finite element
mesh. Each subregion of the first layer will be displayed and meshed. When the layer is complete, the
full layer will be displayed. When all layers are complete, the full 3D mesh will be displayed. You can
return to "Edit" at any point.
Whether you click "Run" or proceed through the "Domain Review", once the problem begins running, the
icon on the problem tab will change from the Edit icon ( ) to the Run icon ( ). The screen will look
something like this:
G etting Started : While the P roblem Runs 20
On the left is the "Status Panel", which presents an active report of the state of the problem
execution. It contains a text based report, a progress bar for the current operation, several history
plots summarizing the activity, and a "Thumbnail" window of the current computational grid.
The history plots summarize the number of nodes/cells in the mesh, the convergence of the current
solver, the error estimates for the solution, and the current time step (in the case of time dependent
problems). Clicking on any plot will display a legend indicating meaning of the plot traces.
The format of the printed data will depend upon the kind of problem, but the common features will
be:
On the right side of the screen are separate "Thumbnail" windows for each of the PLOTS or
MONITORS requested by the descriptor.
In steady-state problems, only MONITORS will be displayed during the run. They will be replaced
by PLOTS when the solution is complete.
In time-dependent problems, all MONITORS and PLOTS will be displayed simultaneously, and
updated as the sequencing specifications of the descriptor dictate.
PLOTS will be sent to the ".pg7" graphic record on disk for later recovery. MONITORS will not.
In eigenvalue problems, there will be one set of MONITORS or PLOTS for each requested mode.
In other respects, eigenvalue problems behave as steady-state problems.
A right-click in any "thumbnail" plot brings up a menu from which several options can be selected:
G etting Started : While the P roblem Runs 22
Maximize
Causes the selected plot to be expanded to fill the display panel. You can also maximize a
thumbnail by double-clicking in the selected plot.
Restore
Causes a maximized plot to be returned to thumbnail size.
Print
Sends the window to the printer using a standard Print dialog.
Export
Invokes a dialog which allows the selection of a format for exporting the plot in standard format
to other processes. Currently, the options are BMP, EMF, EPS, PNG, PPG and XPG. For
bitmap formats (BMP, PNG, PPG and XPG) the dialog allows the selection of the drawing
23 FlexP DE 7 : G etting Started
linewidth and resolution of the bitmap, independent of the resolution of the screen. For vector
formats (EMF, EPS) no resolution is necessary (FlexPDE uses a fixed resolution of
7200x5400). EPS produces an 8.5x11 inch landscape mode PostScript file suitable for
printing.
Rotate
3D plots can be rotated in polar and azimuthal angle.
Zoom
The zoom level of a plot can be dynamically changed using "Zoom In", "Zoom Out", and
"Cancel Zoom". With the right-click, the zoom will be centered around the click-position. This
may also be done with the keyboard. Left-click once inside the plot first to ensure the plot has
focus (clicking and holding will report the plot coordinates of mouse position). Then Z will
zoom in, M will zoom out, and 0 will cancel the zoom and restore the zoom level to 100%. L,
R, U, and P or the arrow keys will pan left, right, up, and down. The zoom change is centered
around the most recent mouse position.
Plot Labeling
At the top of the display the "Title" field from the problem descriptor appears, with the time and date
of problem execution at the right corner, along with the version of FlexPDE which performed the
G etting Started : While the P roblem Runs 24
computation.
At the bottom of the page is a summary of the problem statistics, similar to that shown in the Status
Window:
The problem name
The number of gridding cycles performed so far
The polynomial order of the Finite-Element basis (p2 = quadratic, p3 = cubic)
The number of computation nodes (vertices)
The number of computation cells
The estimated RMS value of the relative error in the variables
By default, FlexPDE computes the integral under the displayed curve, and this value is reported as
"Integral".
Here all the labeling of the contour plot appears, as well as a thumbnail plot of the problem domain,
showing the position of the elevation in the figure. For boundary plots, the joints of the boundary are
25 FlexP DE 7 : G etting Started
numbered on the thumbnail. The numbers also appear along the baseline of the elevation plot for
positional reference.
While the problem is running, you can return the display panel to the editor mode by clicking the Edit
Script tool ( ) or the Show Editor item in the Controls menu. The Run icon ( ) will continue to be
displayed in the problem tab as long as the problem is running. When the problem terminates, the
problem tab will again display the Edit icon ( ).
You can return to the graphic display panel by clicking the Show Plots tool ( ) or the Show Plots item
in the Controls menu.
Whenever a problem is run by FlexPDE 7, the graphical output selected by the PLOTS section of the
descriptor is written to a file with the extension ".pg7". These files can later be viewed by FlexPDE
without re-running the job. (FlexPDE 7 can also open output files from versions 4, 5, and 6.) You can
open these files from the "File | View File" or the "View | View FIle" menu items on the main FlexPDE
menu, or from the "File | Open File" menu using suffix selection. A standard "Open_File" dialog will
appear, from which you may select from the available files on your system. Once a file is selected, the
first block of plots will be displayed.
On the left is a "Status" window, much like the one that appears during the run. Not all the runtime
information will appear here, but only those items necessary to identify the current group of plots.
In steady-state problems, all the PLOT windows will be displayed. If the problem is staged, then each
stage will appear in a separate group.
In time-dependent problems, each plot time group specified in the PLOTS section of the descriptor will
form a display group.
The Problem Tab shows the View icon ( ) to indicate that this is a "View" file, not a PDE problem.
You can use the "View" item in the main menu to control the viewing of these stored graphics:
27 FlexP DE 7 : G etting Started
In the normal thumbnail display, all the plots of a group are displayed simultaneously. In this case, the
"View" menu items have the following meanings:
Next
Use this item to advance to the next group of plots in the file. If there are no more groups, a
message box will appear.
Back
Causes FlexPDE to back up and redisplay the previous group. If there are no earlier groups, a
message box will appear.
Restart
Returns to the beginning of the file and displays the first group.
Last
Scans to the end of the file and displays the last group.
Select
Displays a list of plot times that can be viewed. Double-clicking an entry views the selected plot
group.
Movie
This item is active only for time-dependent or staged problems. It will cause all groups to be
displayed sequentially, with a default delay of 500 milliseconds between groups (plus the file
reading time).
Frame Delay
Allows redefining of the delay time between movie frames.
G etting Started : Viewing Saved G raphic Files 28
Stop
During the display of a movie, you can use Stop to halt the display.
View File
Selects a new graphics file to be opened in a new tab.
When a selected View plot is maximized, either by the right-click menu or by double-click, the
behavior of some of the View menu items is modified:
Next
Advances to the next instance of the currently maximized plot. If there are no more instances, a
message box will appear.
Back
Backs up and redisplays the previous instance of the currently maximized plot. If there are no
earlier instances, a message box will appear.
Movie
This item is active only for time-dependent or staged problems. It will cause all instances of the
current plot to be displayed sequentially, separated by the currently active Frame Delay time
(plus the file read time).
Export Movie
An export parameters dialog will appear, allowing you to select the file format and resolution. A
movie will then be displayed as with "Movie". Each frame of the movie will be exported to a file
of the selected type and resolution. The files will be numbered sequentially, and can be
subsequently imported into an animation program such as "Animation Shop" to create
animations.
Font Settings 30
License Registration 32
The settings of these tabs are saved and loaded from the "flexpde7.ini" file which is located in the
FlexPDE7user directory. (In MyDocuments on Windows, Home on Linux.)
29 FlexP DE 7 : G etting Started
immediately.
Consolidate FlexPDE output into subdirectory
Specifies whether or not FlexPDE should write all output files generated by a script into a sub-
directory named "<pdename>_output". For example, a script with the name "test.pde" would output
all files into the sub-directory "test_output". Changes made to this setting do not effect scripts that are
currently open. They must be closed and reopened for the setting to take effect.
Remember last window size and position
Specifies whether or not FlexPDE will remember the size and position of the main window when it
last closed, and use that size and position when it starts next. If turned off, FlexPDE will open at full
screen size.
Auto-load initial mesh file when possible
Specifies whether or not FlexPDE will automatically save the initial mesh and try to reload it on
subsequent runs. This can save significant time in gridding when a user is adjusting plots or other
settings not related to the grid. If the domain layout changes in any way, the previous grid will not be
used and a new grid will be generated. The output file name is "<pdename>_initialmesh.xfr". This
value can be overridden within the SELECT 183 section, using the selector AUTOMESH 184 . It may
also be turned off using the command-line switch -NM 145 .
Auto-save final transfer file
Specifies whether or not FlexPDE will automatically save the final grid and all of the primary
variables. This can simplify post-processing of primary variable data. The output file name is
"<pdename>_restart.xfr". This value can be overridden within the SELECT 183 section, using the
selector AUTOTRANSFER 184 .
Note : any changes made will not take place until the "Apply" button is clicked. Clicking "Cancel" will
discard any changes. Clicking "Close" will prompt the user if there are unsaved changes.
Note : any changes made will not take place until the "Apply" button is clicked. Clicking "Cancel" will
discard any changes. Clicking "Close" will prompt the user if there are unsaved changes.
This tab is only needed if the user's computer accesses the internet through a proxy web server. The user
may need to contact their system administrator to obtain the necessary information.
Note : any changes made will not take place until the "Apply" button is clicked. Clicking "Cancel" will
discard any changes. Clicking "Close" will prompt the user if there are unsaved changes.
Computer ID
This text is the unique identification of your computer. It may be used to request a software key or
trial license for FlexPDE Professional. It is also used automatically by the Internet Key 35 license to
identify the current computer. The ID is four groups of four hexadecimal numbers.
Current License
The current licensing information is displayed here. In the currently shown case, FlexPDE is
registered to a local dongle. The dongle's serial number is 2-2428246 and it contains three licenses;
1-1D, 1-2D, and 1-3D.
License Method
Changes to the licensing method can be made here. Additional windows will open to complete the
process. See note below and the section "Registering FlexPDE" 33 .
Note : any changes made will not take place until the "Apply" button is clicked. Clicking "Cancel" will
discard any changes. Clicking "Close" will prompt the user if there are unsaved changes.
Lite mode is restricted in the number of nodes and simultaneous equations a problem can have. In order
to enable Professional mode and create larger problems, FlexPDE will need to be registered to a
professional license. There are several forms for the license :
Internet Key
The standard method of licensing FlexPDE Professional is by internet activation. This mode of
licensing generates a text key that locks the execution of FlexPDE to a specific computer. Access to
the internet is required on a periodic basis to validate the key. The key can be released from one
machine and reactivated on another without difficulty. If you need to use a proxy server for internet
access, you can set this information on the Web Proxy Settings 31 preference tab. A serial number
will be sent via email. Use the serial number to configure the license in the License Registration 32
preference tab. See "Internet Key Registration" 35 for details.
Dongle
On request, Professional configurations can be licensed by use of a portable hardware license key
(dongle). The standard dongle for use with FlexPDE 7 is a Wibu USB Cm Stick. Unlike the dongle
used by previous versions, this dongle can be used in local or network mode. See "Dongle
Registration" 36 for details.
In order for FlexPDE to find the dongle, you must
1) Run the appropriate dongle driver install program to load it into your system.
2) Install the dongle in an appropriate USB connector or hub. (Note : On Windows, an autoplay
window may appear. Simply dismiss it.)
3) Register the dongle in the License Registration 32 preference tab.
The request for a dongle license will not be made until you actually "Run" a problem. At that time, a
license of the appropriate class, 1D, 2D or 3D will be requested from the dongle. If a license is
successfully acquired, the corresponding license class will be appended to the main window's title
bar. The acquired license will be held until the current invocation of FlexPDE is terminated or two
hours of idle time has elapsed. In this way, networks of FlexPDE users can get optimal use out of
the mix of 1D, 2D and 3D licenses that have been purchased.
Software Key
The primary use for the software key is for trial usage prior to purchasing a Professional license. On
request, Professional configurations can be licensed in the form of a text key that locks the execution
of FlexPDE to a specific computer. This license method has been superseded by the Internet Key
method and PDE Solutions strongly encourages users not to use this method for a permanent license.
If you prefer a software license key, you must first download and install the software and record the
computer ID from the License Registration 32 preference tab. Include the computer ID on the
license application form. Your software key will be sent to you by Email. Save the key and configure
the license in the License Registration 32 preference tab (you may need administrator privileges to do
this). See "Software Key Registration" 41 for details.
35 FlexP DE 7 : G etting Started
Activation
Enter your serial number into text field and click "Contact Web Server". If successful, FlexPDE will
be activated on the local machine. If not, it will report an error. (If this activation is performed in
public places, you can choose to "Hide" the Serial Number.)
Deactivation
Enter your serial number into the text field and click "Contact Web Server". If successful, FlexPDE
will release the license on the local machine. If not, it will report an error. (If this activation is
performed in public places, you can choose to "Hide" the Serial Number.)
Notes :
A computer's identification is constructed in part from it's MAC address and the operating system's
report of a unique identifier for that installation. Sometimes the MAC address can change (usually on
laptops connecting to different networks or when connected by Wi-Fi instead of a wired
connection). If this happens after the machine is licensed, FlexPDE will issue an error telling the user
that the license authorizes a different computer. When that happens, the user can simply release and
reacquire the license in order to resolve the issue.
G etting Started : Registering FlexP DE 36
If you need to use a proxy server for internet access, you can set this information in the Web Proxy
Settings 31 preference tab.
Click the "Find Dongles" button. FlexPDE will search the USB ports for all Wibu dongles and enter
their serial numbers into the popup menu. If no dongle is found, or if the dongle driver has not been
installed, the search will fail, and FlexPDE will report an error. If the dongle you wish to register to is on
another machine on the network, select the "Network Mode" checkbox and click "Find Dongles". The
machine with the dongle attached must be configured to allow network access to the dongle. See
"Network Dongle Registration" 39 for more details.
If there are multiple dongles installed, then they can be selected by clicking the popup menu and scrolling
to the desired dongle serial number. After choosing a dongle, the corresponding FlexPDE license
37 FlexP DE 7 : G etting Started
content of the selected dongle will be display to the right of the serial number. In the case displayed
above the license encodes three FlexPDE 7 Professional licenses; one for 1D, one for 1D+2D, and one
for 1D+2D+3D problems.
After selecting the desired dongle, click "Register" to install the dongle as the active license method.
Subsequently, every time you start FlexPDE it will search the USB ports for this specific dongle. If it is
found, FlexPDE will start up in Professional mode. If the dongle is unable to be found, FlexPDE will
report that and run in Lite mode. Once the dongle is reconnected, you will have to restart FlexPDE to
return to Professional mode, or go back to the registration dialog to search for the dongle.
Clicking "Cancel" will abort without changing the active license method.
Upgrading a Dongle
You can use the Register dialog to field-upgrade a dongle. Click on the "Upgrade >>>" button and the
dongle upgrade panel will be shown.
G etting Started : Registering FlexP DE 38
In order to upgrade the dongle, PDE Solutions will need a Remote Activation Content (RaC) file. When
requested, create this file by clicking the "Create RaC" button and send the resulting file to PDE
Solutions. The file name will be the dongle serial number and the extension will be "WibuCmRaC". In
the above example, the resulting file would be named "2-2428246.WibuCmRaC".
After receiving the RaC file, PDE Solutions will send you a Remote Activation Upgrade (RaU) file. Enter
the path to the upgrade file, or use the "Browse" button to find the location, and select "Upgrade". Your
dongle will be updated with the information encoded in the key. The upgrade file name will also be the
dongle serial number and the extension will be "WibuCmRaU". In the above example, the upgrade file
would be named "2-2428246.WibuCmRaU".
Note that the dongle upgrade facility will rewrite the dongle only if the serial number of the dongle
matches the serial number encoded in the upgrade key, and the state of the dongle must be exactly the
same as when the RaC file was created. Any changes to the dongle after creating the RaC for PDE
Solutions will invalidate the upgrade file they will send. This includes the creation of another RaC file, so
DO NOT create an RaC file if you have already sent one to PDE Solutions for an upgrade.
Dongles cannot be upgraded over the network. The upgrade must be performed from the computer to
which the dongle is physically connected.
39 FlexP DE 7 : G etting Started
Clicking on the "Hide <<<" button will hide the upgrade panel.
Note : Dongles issued with FlexPDE versions 4, 5 or 6 cannot be upgraded to newer versions
since they are from a different manufacturer. They will need to be replaced.
Select the dongle to be configured and click "WebAdmin" in the lower right corner to open the
administration panel.
G etting Started : Registering FlexP DE 40
Select the 'Configuration' tab and then the 'Server' subtab. Check the box next to 'Run Network Server'
and click 'Apply'. This will make the dongle accessible over the network.
If the server and client are on different networks or different subnets, it may be necessary to specify the
server address to the CodeMeter WebAdmin on the client machine. This means the dongle driver will
need to be installed on the client as well as the server machine. The server address can be specified on
the 'Network' subtab of the 'Configuration' tab on the client.
41 FlexP DE 7 : G etting Started
Enter the path to your license key file, or use the "Browse" button to find the location of the software key
file, and select "Validate Key". This button will read the contents of the license file without installing it as
the selected license method. FlexPDE will validate the license file entered and display the contents in the
text field. This step is optional, but always a good idea to ensure that the key file is valid. Click
"Register" to install this key file as the active license, or click "Cancel" to abort without changing the
active license method.
Part
II
User Guide
User G uide : 44
2 User Guide
This section introduces the reader gradually to the use of FlexPDE in the solution of systems of partial
differential equations.
We begin with a discussion of the basic character of FlexPDE. We then construct a simple model
problem and proceed to add features to the model.
The result is a description of the most common features of FlexPDE in what we hope is a meaningful and
understandable evolution that will allow users to very quickly become accustomed to the use of FlexPDE
and to use it in their own work.
No attempt is made in this manual to present a complete description of each command or circumstance
which can arise. Detailed descriptions of each command are presented in the Problem Descriptor
Reference 149 section.
2.1 Overview
2.1.1 What Is FlexPDE?
FlexPDE is a "scripted finite element model builder and numerical solver".
By this we mean that from a script written by the user, FlexPDE performs the operations necessary
to turn a description of a partial differential equations system into a finite element model, solve the
system, and present graphical and tabular output of the results.
FlexPDE is also a "problem solving environment".
It performs the entire range of functions necessary to solve partial differential equation systems: an
editor for preparing scripts, a mesh generator for building finite element meshes, a finite element
solver to find solutions, and a graphics system to plot results. The user can edit the script, run the
problem and observe the output, then re-edit and re-run repeatedly without leaving the FlexPDE
application environment.
FlexPDE has no pre-defined problem domain or equation list.
The choice of partial differential equations is totally up to the user.
The FlexPDE scripting language is a "natural" language.
It allows the user to describe the mathematics of his partial differential equations system and the
geometry of his problem domain in a format similar to the way he might describe it to a co-worker.
For instance, there is an EQUATIONS section in the script, in which Laplace's equation would be
presented as
Div(grad(u)) = 0.
Similarly, there is a BOUNDARIES section in the script, where the geometric boundaries of a two-
45 FlexP DE 7 : User G uide
dimensional problem domain are presented merely by walking around the perimeter:
Start(x1,y1) line to (x2,y1) to (x2,y2) to (x1,y2) to close
In an educational environment, this is good. It's what the student wants to learn.
In an industrial environment, a single knowledgeable user can prepare scripts which can be used and
modified by less skilled workers. And a library of application scripts can show how it is done.
The system may be steady-state or time-dependent, or alternatively FlexPDE can solve eigenvalue
problems. Steady-state and time-dependent equations can be mixed in a single problem.
Any number of simultaneous equations can be solved, subject to the limitations of the computer on
which FlexPDE is run.
The equations can be linear or nonlinear. (FlexPDE automatically applies a modified Newton-
Raphson iteration process in nonlinear systems.)
Modeled variables are assumed to be continuous across material interfaces. Jump conditions on
derivatives follow from the statement of the PDE system. (CONTACT boundary conditions can
handle discontinuous variables.)
User G uide : Overview 46
FlexPDE can be extremely easy to use, and this feature recommends it for use in education. But
FlexPDE is not a toy. By full use of its power, it can be applied successfully to extremely difficult
problems.
A script editing facility with syntax highlighting provides a full text editing facility and a graphical
domain preview.
A symbolic equation analyzer expands defined parameters and equations, performs spatial
differentiation, and symbolically applies integration by parts to reduce second order terms to create
symbolic Galerkin equations. It then symbolically differentiates these equations to form the Jacobian
coupling matrix.
A mesh generation facility constructs a triangular or tetrahedral finite element mesh over a two or
three-dimensional problem domain. In two dimensions, an arbitrary domain is filled with an
unstructured triangular mesh. In three-dimensional problems, an arbitrary two-dimensional domain is
extruded into a the third dimension and cut by arbitrary dividing surfaces. The resulting three-
dimensional figure is filled with an unstructured tetrahedral mesh.
A Finite Element numerical analysis facility selects an appropriate solution scheme for steady-
state, time-dependent or eigenvalue problems, with separate procedures for linear and nonlinear
systems. The finite element basis may be linear, quadratic or cubic.
An adaptive mesh refinement procedure measures the adequacy of the mesh and refines the mesh
wherever the error is large. The system iterates the mesh refinement and solution until a user-defined
error tolerance is achieved.
A dynamic timestep control procedure measures the curvature of the solution in time and adapts
the time integration step to maintain accuracy.
A graphical output facility accepts arbitrary algebraic functions of the solution and plots contour,
surface, vector or elevation plots.
A data export facility can write text reports in many formats, including simple tables, full finite
element mesh data, CDF, VTK or TecPlot compatible files.
47 FlexP DE 7 : User G uide
Researchers in many fields can use FlexPDE to model their experiments or apparatus, make
predictions or test the importance of various effects. Parameter variations or dependencies are not
limited by a library of forms, but can be programmed at will.
Engineers can use FlexPDE to do design optimization studies, feasibility studies and conceptual
analyses. The same software can be used to model all aspects of a design -- no need for a separate
tool for each effect.
Application developers can use FlexPDE as the core of a special-purpose applications that need
finite element modeling of partial differential equation systems.
Educators can use FlexPDE to teach physics or engineering. A single software tool can be used to
examine the full range of systems of interest in a discipline.
Students see the actual equations, and can experiment interactively with the effects of modifying
terms or domains.
Note: There are several other optional sections for describing special aspects of the problem.
Some of these will be introduced later in this document. Detailed rules for all sections are
presented in the FlexPDE Problem Descriptor Reference chapter "The Sections of a Descriptor
183 ".
COMMENTS can be placed anywhere in a script to describe or clarify the work. Two forms of
comment are available:
{ Anything inside curly brackets is a comment. }
! from an exclamation to the end of the line is a comment.
Example:
Later on, we will show detailed examples of the development of a problem script.
The VALUE (or Dirichlet) boundary condition specifies the value that a variable must take on at the
boundary of the domain.
The NATURAL boundary condition specifies a flux at the boundary of the domain. (The precise meaning
of the NATURAL boundary condition depends on the PDE for which the boundary condition is being
specified. Details are discussed in the Chapter "Natural Boundary Conditions 82 ")
In the diffusion problem presented above, for example, we may add fixed values on the bottom and top
edges, and zero-flux conditions on the sides as follows:
…
BOUNDARIES
REGION 1
START(0,0)
VALUE(u) = 0 LINE TO (1,0) { fixed value on bottom }
NATURAL(u)=0 LINE TO (1,1) { insulated right side }
VALUE(u)=1 LINE TO (0,1) { fixed value on top }
NATURAL(u)=0 LINE TO CLOSE { insulated left side }
…
Notice that a VALUE or NATURAL statement declares a condition which will apply to the subsequent
boundary segments until the declaration is changed.
These steps will be described in the following sections. We will use a simple 2D heatflow problem as an
example, and start by building the script from the most basic elements of FlexPDE. In later sections, we
will elaborate the script, and address the more advanced capabilities of FlexPDE in an evolutionary
manner. 3D applications rely heavily on 2D concepts, and will be discussed in a separate chapter.
Note: We will make no attempt in the following to describe all the options that are available
to the user at any point, but try to keep the concept clear by illustrating the most common
forms. The full range of options is detailed in the FlexPDE Problem Descriptor Reference 149 .
Many will also be addressed in subsequent topics.
Start with a simple model, preferably one for which you know the answer. This allows you
both to validate your presentation of the problem, and to increase your confidence in the reliability of
FlexPDE. (One useful technique is to assume an analytic answer and plug it into the PDE to generate
the source terms necessary to produce that solution. Be sure to take into account the appropriate
boundary conditions.)
Use simple material parameters at first. Don't worry about the exact form of nonlinear
coefficients or material properties at first. Try to get a simple problem to work, and add the
complexities later.
Map out the domain. Draw the outer boundary first, placing boundary conditions as you go. Then
overlay the other material regions. Later regions will overlay and replace anything under them, so you
don't have to replicate a lot of complicated interfaces.
Use MONITORS of anything that might help you see what is happening in the solution. Don't just
plot the final value you want to see and then wonder why it's wrong. Get feedback! That's what the
MONITORS section is there for.
Annotate your script with frequent comments. Later you will want to know just what it was you
were thinking when you wrote the script. Include references to sources of the equations or notes on
the derivation.
Save your work. FlexPDE will write the script to disk whenever you click "Domain Review" or
"Run Script". But if you are doing a lot of typing, use "Save" or "Save_as" to protect your work from
unforeseen interruptions.
51 FlexP DE 7 : User G uide
2.2.3 Notation
In most cases, FlexPDE notation is simple text as in a programming language.
Differentiation, such as du/dx, is denoted by the form dx(u). All active coordinate names are
recognized, as are second derivatives like dxx(u) and differential operators Div, Grad and Curl.
Names are NOT case sensitive. "F" is the same as "f".
Comments can be placed liberally in the text. Use { } to enclose comments or ! to ignore the
remainder of the line.
Note: See the Problem Descriptor Reference chapter on Elements 154 for a full description of
FlexPDE notation.
The VARIABLES 195 and EQUATIONS 217 sections of a problem script supply this information. The two
are closely linked, since you must have one equation for each variable in a properly posed system.
In a simple problem, you may have only a single variable, like voltage or temperature. In this case, you
can simply state the variable and equation:
VARIABLES
Phi
EQUATIONS
Div(grad(Phi)) = 0
In a more complex case, there may be many variables and many equations. FlexPDE will want to know
how to associate equations with variables, because some of the details of constructing the model will
depend on this association.
Each equation must be labeled with the variable to which it is associated (name and colon), as indicated
below:
VARIABLES
A,B
EQUATIONS
User G uide : Basic Usage 52
A: Div(grad(A)) = 0
B: Div(grad(B)) = 0
Later, when we specify boundary conditions, these labels will be used to associate boundary conditions
with the appropriate equation.
REGIONs occurring later in the script overlay and cover up parts of earlier REGIONs.
The first REGION should contain the entire domain. This is an unenforced convention that makes the
attachment of boundary conditions easier.
Region shapes are described by walking the perimeter, stepping from one joint to another with LINE,
SPLINE, ARC or CURVE segments. Each segment assumes that it will continue from the end of the
previous segment, and the START clause gets things rolling. You can make a segment return to the
beginning with the word CLOSE (or TO CLOSE).
A rectangular region, for example, is made up of four line segments:
START(x1,y1)
LINE TO(x2,y1)
TO (x2,y2)
TO (x1,y2)
TO CLOSE
(Of course, any quadrilateral figure can be made with the same structure, merely by changing the
coordinates. And any polygonal figure can be constructed by adding more points.)
Arcs can be built in several ways, the simplest of which is by specifying a center and an angle:
START(r,0)
ARC(CENTER=0,0) ANGLE=360
START(r,0)
ARC(CENTER=0,0) TO (0,r) { a 90 degree arc }
53 FlexP DE 7 : User G uide
An elliptical arc will be built if the distance from the center to the endpoint is different than the
distance from the center to the beginning point. The axes of the ellipse will extend along the
horizontal and vertical coordinate axes. The axes can be rotated with the ROTATE=degrees
command.
Curves can be built by specifying a start point and an expression for the curve:
START(r,0)
CURVE(x^2+y^2=r^2) BY (+X) TO (0,r) { a 90 degree arc }
A curve.
You can build your domain a little at a time, using the "domain review" menu button to preview a drawing
of what you have created so far.
The "Save" and "Save_As" menu buttons allow you to frequently save your work, just in case.
Note: The detailed Rules for constructing domain boundaries is included in the Reference
chapter "Sections | Boundaries 226 ".
Notice that the circular boundary of region 2 is mapped onto cell legs.
There are several controls that the user can apply to change the behavior of the automatic mesh. These
are described in detail in the chapter "Controlling Mesh Density" 134 below.
As an example, we can cause the circular boundary of region 2 to be gridded more densely by using the
modifier MESH_SPACING:
REGION 2 'blob' { the embedded 'blob' }
START(1/2,0)
MESH_SPACING = 0.05
ARC(CENTER=0,0) ANGLE=360
In most cases, it is not necessary to intervene in the mesh generation, because as we will see later,
FlexPDE will adaptively refine the mesh wherever it detects that there are strong curvatures in the
solution.
First, we define the name of the constant and give it a default value in the definitions section:
DEFINITIONS
k=1
This default value will be used as the value of "k" in every REGION of the problem, unless specifically
redefined in a region.
Now we introduce the constant into the equation:
EQUATIONS
Div(-k*grad(phi)) = 0
We could also define the parameter k=1 for the conductor in REGION 1, if it seemed useful for clarity.
...
REGION 1 'box' { the bounding box }
START(-1,-1)
{ Phi=0 on base line: }
VALUE(Phi)=0 LINE TO(1,-1)
{ normal derivative =0 on right side: }
NATURAL(Phi)=0 LINE TO (1,1)
{ Phi = 1 on top: }
VALUE(Phi)=1 LINE TO (-1,1)
{ normal derivative =0 on left side: }
NATURAL(Phi)=0 LINE TO CLOSE
Notice that a VALUE or NATURAL statement declares a condition which will apply to the subsequent
boundary segments until the declaration is changed.
Notice also that the segment shape (Line or Arc) must be restated after a change of boundary condition.
Note: Other boundary condition forms are allowed. See the Reference chapter "Sections |
Boundaries 226 ".
Any number of plots may be requested, and the values plotted may be any consistent algebraic
combination of variables, coordinates and defined parameters.
In our example, we will request a contour of the temperature, a vector map of the heat flux, k*grad(Phi),
an elevation of temperature along the center line, and an elevation of the normal heat flux on the surface
of the blob:
PLOTS
CONTOUR(Phi)
VECTOR(-k*grad(Phi))
ELEVATION(Phi) FROM (0,-1) TO (0,1)
ELEVATION(Normal(-k*grad(Phi))) ON 'ring'
User G uide : Basic Usage 58
Output requested in the PLOTS section is produced when FlexPDE has finished the process of solving
and regridding, and is satisfied that all cells are within tolerance. An alternative section, identical in form
to the PLOTS section but named MONITORS, will produce transitory output at more frequent intervals,
as an ongoing report of the progress of the solution.
A record of all PLOTS is written in a file with suffix .PG7 and the name of the .PDE script file. These
recorded plots may be viewed at a later time by invoking the VIEW item in the FlexPDE main menu.
MONITORS are not recorded in the .PG7 file. It is strongly recommended that MONITORS be used
liberally during script development to determine that the problem has been properly set up and that the
solution is proceeding as expected.
Note: FlexPDE accepts other forms of plot command, including GRID plots and HISTORIES.
See the Reference chapter "Sections | Monitors and Plots 245 ".
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 LINE TO (1,-1)
NATURAL(Phi)=0 LINE TO (1,1)
VALUE(Phi)=1 LINE TO (-1,1)
NATURAL(Phi)=0 LINE TO CLOSE
REGION 2 'blob' { the embedded blob }
k = 0.001
START 'ring' (R,0)
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
PLOTS
CONTOUR(Phi)
VECTOR(-k*grad(Phi))
ELEVATION(Phi) FROM (0,-1) to (0,1)
ELEVATION(Normal(-k*grad(Phi))) ON 'ring'
END
as a new section. This tells FlexPDE to split any cell in which the consistency check implies an error of
more than 0.001% over the cell.
FlexPDE refines the mesh twice, and completes with a mesh that looks like this:
In this particular case, the result plots are not noticeably different from the default case.
Note: In time-dependent problems, spatial and temporal errors are both set by ERRLIM, but
they can also be independently controlled by XERRLIM and TERRLIM. See the Problem
Descriptor Reference 186 .
User G uide : Some C ommon Variations 64
In the case of internal boundaries, there is sometimes a different value of the integral on the two sides of
the boundary. The two values can be distinguished by further specifying the region in which the integral is
to be evaluated:
{ the total flux across 'ring': }
Tflux = LINE_INTEGRAL(NORMAL(-k*grad(Phi)), 'ring', 'box')
{ evaluated on the 'box' side of the boundary }
Note: Three-dimensional integral forms will be addressed in a later section. A full description
of integral operators is presented in the Problem Descriptor Reference section "Elements |
Operators | Integral Operators 172 ".
REPORT value
Any number of REPORT s can be requested following any plot, subject to the constraint that the values
are printed on a single line at the bottom of the plot, and too many reports will run off and be lost.
For instance, we might modify the contour plot of our example plot to say
CONTOUR(Phi) REPORT(k) REPORT(INTEGRAL(Phi, 'blob'))
On running the problem, we might see something like this at the bottom of the plot:
In our sample, we will see a separate report page with the following instead of a graphic:
The problem will be re-run as many times as there are values in the value list, with "Name" taking on
consecutive values from the list in successive runs.
User G uide : Some C ommon Variations 66
If the STAGED parameter does not affect the domain dimensions, then each successive run will use the
result and mesh from the previous run as a starting condition.
Note: This technique can also be used to approach the solution of a strongly nonlinear
problem, by starting with a linear system and gradually increasing the weight on a nonlinear
component.
If the STAGED parameter is used as a dimension in the domain definition, then each successive run will
be restarted from the domain definition, and there will be no carry-over of solutions from one run to the
next.
As for time-dependent problems (which we will discuss later), variation of arbitrary quantities across the
stages of a problem can be displayed by HISTORY plots. In staged runs the history is plotted against
stage number.
As an example, let us run our sample heat flow problem for a range of conductivities and plot a history of
the top edge temperature.
We will modify the definition of K in the insulator as follows:
DEFINITIONS
Kins = STAGED(0.01, 0.1, 1, 10)
{ Notice that the STAGED specification must appear at the initial declaration of a
name. It cannot be used in a regional redefinition. }
…
REGION 2 'blob' { the embedded blob }
K = Kins
START(R,0) ARC(CENTER=0,0) ANGLE=360
…
HISTORY(Phi) AT (0,-R)
When this modified descriptor is run, the history plot produces the following:
67 FlexP DE 7 : User G uide
In a staged run, all PLOTS and MONITORS requested will be presented for each stage of the run.
Other Staging Controls
The global selector STAGES can be used to control the number of stages to run. If this selector
appears, it overrides any STAGED lists in the DEFINITIONS section (lists shorter than STAGES will
report an error). It also defines the global name STAGE, which can be used subsequently in arithmetic
expressions. See the Problem Descriptor Reference 207 for details.
The default action is to proceed at once from one stage to the next, but you can cause FlexPDE to
pause while you examine the plots by placing the command AUTOSTAGE=OFF in the SELECT section
of the script.
Note: The STAGE facility can only be used on steady-state problems. It cannot be used w ith time
dependent problems.
Either form may optionally be followed by a parenthesized renaming of the coordinates. Renaming
cannot be used to change the geometric character of the coordinate. Radius remains radius, even if you
rename it "Z".
The default names are
XCYLINDER implies XCYLINDER('Z','R').
YCYLINDER implies YCYLINDER('R','Z').
2.3.6.1 Integrals In Cy lindrical Geom etry
Similarly, the operator SURF_INTEGRAL will form the integral over a boundary, analogous to the
LINE_INTEGRAL operator, but with an area weight of 2*PI*R.
Let us now convert our Cartesian test problem into a cylindrical one. If we rotate the box and blob
around the left boundary, we will form a torus between two circular plates (like a donut in a round box).
These changes will be required:
We must offset the coordinates, so the left boundary becomes R=0.
Since we want the rotation axis in the Y-direction, we must use YCYLINDER coordinates.
Since 'R' is now a coordinate name, we must rename the 'R' used for the blob radius.
DEFINITIONS
K=1 { default conductivity }
Rad = 0.5 { blob radius (renamed)}
EQUATIONS
Div(-k*grad(phi)) = 0
BOUNDARIES
REGION 1 'box'
START(0,-1)
VALUE(Phi)=0 LINE TO (2,-1)
NATURAL(Phi)=0 LINE TO (2,1)
VALUE(Phi)=1 LINE TO (0,1)
NATURAL(Phi)=0 LINE TO CLOSE
REGION 2 'blob' { the embedded blob }
k = 0.001
START 'ring' (1,Rad)
ARC(CENTER=1,0) ANGLE=360 TO CLOSE
PLOTS
CONTOUR(Phi)
VECTOR(-k*grad(Phi))
ELEVATION(Phi) FROM (1,-1) to (1,1)
ELEVATION(Normal(-k*grad(Phi))) ON 'ring'
END
Note: FlexPDE can treat only first derivatives in time. Equations that are second-order in
User G uide : Some C ommon Variations 72
Plot times are specified by preceding any block of plot commands by a time control, in which specific
times may be listed, or intervals and end times, or a mixture of both:
FOR T = t1, t2 BY step TO t3 ….
We can convert our heat flow problem to a time dependent one by including a time term in the heat
equation:
Div(k*grad(Phi)) = c*dt(Phi)
To make things interesting, we will impose a sinusoidal driving temperature at the top plate, and present a
history plot of the temperature at several internal points.
The whole script with pertinent modifications now looks like this:
TITLE 'Transient Heat flow around an Insulating blob'
VARIABLES
Phi (threshold=0.01) { the temperature }
DEFINITIONS
K=1 { default conductivity }
C=1 { default heat capacity }
R = 1/2
EQUATIONS
Div(-K*grad(phi)) + C*dt(Phi) = 0
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 LINE TO (1,-1)
NATURAL(Phi)=0 LINE TO (1,1)
VALUE(Phi)=sin(t) LINE TO (-1,1)
NATURAL(Phi)=0 LINE TO CLOSE
REGION 2 'blob' { the embedded blob }
K = 0.001
C = 0.1
START(R,0)
ARC(CENTER=0,0) ANGLE=360
TIME 0 TO 2*pi
PLOTS
FOR T = pi/2 BY pi/2 TO 2*pi
CONTOUR(Phi)
VECTOR(-K*grad(Phi))
ELEVATION(Phi) FROM (0,-1) to (0,1)
HISTORIES
HISTORY(Phi) AT (0,r/2) (0,r) (0,3*r/2)
END
73 FlexP DE 7 : User G uide
At the end of the run (t=2*pi), the contour and history look like this:
User G uide : Some C ommon Variations 74
C K 0
t
together with homogeneous boundary conditions
0
and/or
0
n
on the boundary.
If we wish to solve for steady oscillatory solutions to this equation, we may assert
( x, y , t ) ( x, y ) exp( t)
VARIABLES
Phi { the temperature }
DEFINITIONS
K=1 { default conductivity }
R = 0.5 { blob radius }
EQUATIONS
Div(k*grad(Phi)) + LAMBDA*Phi = 0
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 LINE TO (1,-1)
NATURAL(Phi)=0 LINE TO (1,1)
VALUE(Phi)=0 LINE TO (-1,1)
NATURAL(Phi)=0 LINE TO CLOSE
REGION 2 'blob' { the embedded blob }
k = 0.2 { This value makes more interesting pictures }
START 'ring' (R,0)
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
PLOTS
CONTOUR(Phi)
VECTOR(-k*grad(Phi))
ELEVATION(Phi) FROM (0,-1) to (0,1)
ELEVATION(Normal(-k*grad(Phi))) ON 'ring'
END
When running an Eigenvalue problem, FlexPDE automatically produces an additional plot displaying a
summary of the computed eigenvalues.
If the user specifies a SUMMARY plot, then this plot will supplant the automatic summary, allowing the
user to add reports to the eigenvalue listing.
For example, we can add to our previous descriptor the plot specification:
SUMMARY
REPORT(lambda)
REPORT(integral(phi))
The appearance of a nonlinear dependence will automatically activate the nonlinear solver, and all the
dependency details will be handled by FlexPDE.
The modified result appears immediately:
User G uide : Addressing More Difficult P roblems 80
Nonlinear terms in the equation are just as easy. If our system has a nonlinear sinusoidal source, for
example, we may type:
EQUATIONS
Div(k*grad(phi)) + 0.01*phi*sin(phi) = 0
Actually, nonlinear problems are frequently more difficult than we have implied above, for several
reasons.
Nonlinear problems can have more than one solution.
A nonlinear problem may not, in fact, have a solution at all.
FlexPDE uses a Newton-Raphson iteration process to solve nonlinear systems. This technique can be
very sensitive to the initial estimate of the solution. If the starting conditions are too far from the actual
solution, it may be impossible to find the answer, even though it might be quite simple from a different
starting value.
There are several things that can be done to help a nonlinear problem find a solution:
Provide as good an initial value as you can, using the INITIAL VALUES section of the script.
Ensure that the boundary conditions are consistent.
Use STAGES to progress from a linear to a nonlinear system, allowing the linear solution to provide
initial conditions for the nonlinear one.
User G uide : Addressing More Difficult P roblems 82
Pose the problem as a time-dependent one, with time as an artificial relaxation dimension.
Use SELECT CHANGELIM to limit the excursion at each step and force FlexPDE to creep toward a
solution.
Use MONITORS to display useful aspects of the solution, to help identify troublesome terms.
We will return in a later section 142 to the question of intransigent nonlinear problems.
The Divergence Theorem says that the integral of this equation over all space is equal merely to the
integral over the bounding surface of the normal component of the flux,
A
div( grad (u ))dA Ñ S
n grad (u )dl
(we have presented the equation in two dimensions, but it is valid in three dimensions as well).
The surface value of n grad (u ) is in fact the "natural boundary condition" for the Laplace (and
Poisson) equation. It is the way in which the system inside interacts with the system outside. It is the
(negative of the) flux of the quantity u that crosses the system boundary.
The Divergence Theorem is a particular manifestation of the more general process of Integration by
Parts. You will remember the basic rule,
b b
b
udv uv a vdu
a a
The term uv is evaluated at the ends of the integration interval and gives rise to surface terms. Applied
to the integration of a divergence, integration by parts produces the Divergence Theorem.
FlexPDE applies integration by parts to all terms of the partial differential equations that contain second-
order derivatives of the system variables. In the Laplace equation, of course, this means the only term
that appears.
In order for a solution of the Laplace equation (for example) to be achieved, one must specify at all
points of the boundary either the value of the variable (in this case, u ) or the value of n grad (u ) .
In the notation of FlexPDE,
83 FlexP DE 7 : User G uide
In other words,
The NATURAL boundary condition statement in FlexPDE supplies the value of the surface
flux, as that flux is defined by the integration of the second-order terms of the PDE by parts.
The default boundary condition for FlexPDE is NATURAL(VARIABLE)=0.
Note: On an internal boundary the NATURAL defines the difference in flux between the two adjacent
regions, producing a source or sink at that boundary.
Consistent with our discussion of nonlinear equations, the value given for the surface flux may be a
nonlinear value.
The radiation loss from a hot body, for example, is proportional to the fourth power of temperature, and
the statement
NATURAL(u) = -k*u^4
is a perfectly legal boundary condition for the Laplace equation in FlexPDE.
Since integration by parts is a fundamental mathematical operation, it will come as no surprise that its
application can lead to many of the fundamental rules of physics, such as Ampere's Law.
For this reason, the Natural boundary condition is frequently a statement of very fundamental
conservation laws in many applications.
But it is not always obvious at first what its meaning might be in equations which are more elaborate than
the Laplace equation.
So let us first list some basic terms and their associated natural boundary condition contributions (we
present these rules for two-dimensional geometry, but the three-dimensional extensions are readily seen).
Applied to the term f (u ) / x , integration by parts yields
f (u )
dxdy Ñ f (u )dy Ñ f (u ) dl
x
Here is the x-direction cosine of the surface normal and dl is the differential path length. Since
FlexPDE applies integration by parts only to second order terms, this rule is applied only if the
function f (u ) contains further derivatives of u . Similar rules apply to derivatives with respect to
other coordinates.
2
Applied to the term f (u ) / x 2 , integration by parts yields
User G uide : Addressing More Difficult P roblems 84
2
f (u ) f (u ) f (u )
2
dxdy Ñ dy Ñ dl
x x x
Since this term is second order, it will always result in a contribution to the natural boundary
condition.
r
Applied to the term F (u ) , integration by parts yields the Divergence Theorem
r r
F (u )dxdy Ñ ˆ
F (u ) ndl
Using these formulas, we can examine what the natural boundary condition means in several common
cases:
The Heat Equation
Div(-k*grad(Temp)) + Source = 0
Natural(Temp) = normal(-k*grad(Temp)) { outward surface-normal flux }
(Notice that we have written the PDE in terms of heat flux with the negative sign imbedded in the
equation. If the sign is left out, the sign of the Natural is reversed as well.)
One-dimensional heat equation
dx(-k*dx(Temp)) + Source = 0
Natural(Temp) = outward surface-normal component of flux = (-k*dx(temp)*nx),
where nx is the x-direction cosine of the surface normal.
Similar forms apply for other coordinates.
Magnetic Field Equation
curl(curl(A)/mu) = J
Natural(A) = tangential component of H = tangential(curl(A)/mu)
Convection Equation
dx(u)-dy(u)=0
Natural(u) is undefined, because there are no second-order terms.
See the example "Samples | Applications | Fluids | Hyperbolic.pde" 399 .
85 FlexP DE 7 : User G uide
Let us return again to our heat flow test problem and investigate the effect of the Natural boundary
condition. As originally posed, we specified Natural(Phi)=0 on both sidewalls. This corresponds to
zero flux at the boundary. Alternatively, a convective cooling loss at the boundary would correspond to
a flux
Flux = -K*grad(Phi) = Phi – Phi0
where Phi0 is a reference cooling temperature. With convectively cooled sides, our boundary
specification looks like this (assuming Phi0=0):
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 LINE TO (1,-1)
NATURAL(Phi)=Phi LINE TO (1,1)
VALUE(Phi)=1 LINE TO (-1,1)
NATURAL(Phi)=Phi LINE TO CLOSE
CONTACT(V) is a special form of NATURAL boundary condition which also causes the affected variable
to be stored in duplicate nodes at the interface, capable of representing a double value.
JUMP(v) means the instantaneous change in the value of variable "v" when moving outward across an
interface from inside a given material. At an interface between materials '1' and '2', JUMP(V) means
(V2-V1) in material '1', and (V1-V2) in material '2'.
The expected use of JUMP is in a CONTACT Boundary Condition statement on an interior boundary.
The combination of CONTACT and JUMP causes a line or surface source to be generated proportional to
the difference between the two values.
JUMP may also be used in other boundary condition statements, but it is assumed that the argument of
the JUMP is a variable for which a CONTACT boundary condition has been specified. See the example
87 FlexP DE 7 : User G uide
The problem of contact resistance between two conductors is a typical one requiring discontinuity of the
modeled variable.
In this problem, a very thin resistive layer causes a jump in the temperature or voltage on the two sides of
an interface. The magnitude of the jump is proportional to the heat flux or electric current flowing across
the resistive film. In microscopic analysis, of course, there is a physical extent to the resistive material.
But its dimensions are such as to make true modelling of the thickness inconvenient in a finite element
simulation.
In the contact resistance case, the heat flux across a resistive interface between materials '1' and '2' as
seen from side '1' is given by
F1 = -K1*dn(T) = -(T2-T1)/R
where F1 is the value of the outward heat flux, K1 is the heat conductivity, dn(T) is the outward normal
derivative of T , R is the resistance of the interface film, and T1 and T2 are the two values of the
temperature at the interface.
As seen from material '2',
F2 = -K2*dn(T) = -(T1-T2)/R = -F1
Here the normal has reversed sign, so that the outflow from '2' is the negative of the outflow from '1',
imposing energy conservation.
The Natural Boundary Condition for the heat equation
div(-K*grad(T)) = H
This statement means the same thing in both of the materials sharing the interface. [Notice that the sign
applied to the JUMP reflects the sign of the divergence term.]
We can modify our previous example problem to demonstrate this, by adding a heat source to drive the
jump, and cooling the sidewalls. The restated script is:
TITLE 'Contact Resistance on a heated blob'
VARIABLES
Phi { the temperature }
DEFINITIONS
K=1 { default conductivity }
R = 0.5 { blob radius }
H=0 { internal heat source }
Res = 0.5 { contact resistance }
EQUATIONS
Div(-k*grad(phi)) = H
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 { cold outer walls }
LINE TO (1,-1) TO (1,1) TO (-1,1) TO CLOSE
REGION 2 'blob' { the embedded blob }
H=1 { heat generation in the blob }
START 'ring' (R,0)
CONTACT(phi) = -JUMP(phi)/Res
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
PLOTS
CONTOUR(Phi)
SURFACE(Phi)
VECTOR(-k*grad(Phi))
ELEVATION(Phi) FROM (0,-1) to (0,1)
ELEVATION(Normal(-k*grad(Phi))) ON 'ring'
END
The surface plot generated by running this problem shows the discontinuity in temperature:
89 FlexP DE 7 : User G uide
2.4.3.2 Decoupling
Using the Contact Resistance model, one can effectively decouple the values of a given variable in two
adjacent regions. In the previous example, if we replace the jump boundary condition with the statement
CONTACT(phi) = 0*JUMP(phi)
the contact resistance is infinite, and no flux can pass between the regions.
Note: The JUMP statement is recognized as a special form. Even though the apparent value of
the right hand side here is zero, it is not removed by the arithmetic expression simplifier.
An expression JUMP(V) may appear in any boundary condition statement on a boundary for which the
argument variable V has been given a CONTACT boundary condition.
In an electrical resistance case, for example, the voltage undergoes a jump across a contact resistance,
and the current through this contact is a source of heat for a heatflow equation. The following example,
though not strictly realizable physically, diagrams the technique. Notice that the JUMP of Phi appears as
a source term in the Natural boundary condition for Temp. Phi, having appeared in a CONTACT
boundary condition definition, is stored as a double-valued quantity, whose JUMP is available to the
User G uide : Addressing More Difficult P roblems 90
boundary condition for Temp. Temp, which does not appear in a CONTACT boundary condition
statement, is a single-valued variable at the interface.
TITLE 'Contact Resistance as a heat source'
VARIABLES
Phi { the voltage }
Temp { the temperature }
DEFINITIONS
Kd = 1 { dielectric constant }
Kt = 1 { thermal conductivity }
R = 0.5 { blob radius }
Q =0 { space charge density }
Res = 0.5 { contact resistance }
EQUATIONS
Phi: Div(-kd*grad(phi)) = Q
Temp: Div(-kt*grad(temp) = 0
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 { grounded outer walls }
VALUE(Temp)=0 { cold outer walls }
LINE TO (1,-1) TO (1,1) TO (-1,1) TO CLOSE
REGION 2 'blob' { the embedded blob }
Q =1 { space charge in the blob }
START 'ring' (R,0)
CONTACT(phi) = -JUMP(phi)/Res
{ the heat source is the voltage difference times the current }
NATURAL(temp) = -JUMP(Phi)^2/Res
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
PLOTS
CONTOUR(Phi)SURFACE(Phi)
CONTOUR(temp) SURFACE(temp)
END
The boundary path is in fact the domain, so the boundary must not CLOSE on itself.
Since the boundary path is the domain, boundary conditions are not specified along the path. Instead
we use the existing syntax of POINT VALUE and POINT LOAD to specify boundary conditions at the
end points of the domain:
START(0) POINT VALUE(u)=0 LINE TO (5) POINT LOAD(u)=1
Our basic example problem does not have a one-dimensional analog, but we can adapt it to an insulating
spherical shell between two spherical reservoirs as follows:
There are two forms for the EXTRUSION section, the elaborate form and the shorthand form. In both
cases, the layers of the model are built up in order from small to large Z.
In the elaborate form, the dividing SURFACES and the intervening LAYERS are each named explicitly,
with algebraic formulas given for each dividing surface.
Note: With this usage, we have overloaded the word SURFACE. As a plot command, it can
mean a form of graphic output in which the data are presented as a three-dimensional surface;
or, in this new case, it can mean a dividing surface between extrusion layers. The distinction
between the two uses should be clear from the context.
In the simple case of our extruded cylinder in a square, it looks like this:
EXTRUSION
SURFACE 'Bottom' z=0
LAYER 'Everything'
SURFACE 'Top' z=1
The bottom and top surfaces are named, and given simple planar shapes.
The layer between these two surfaces comprises everything in the domain, so we can name it
'Everything'.
In the shorthand form, we merely state the Z-formulas:
EXTRUSION z = 0, 1
In this case, the layers and surfaces must later be referred to by number. The first surface, z=0, is
identified as surface 1. The second surface, z=1, as surface 2.
Notice that there is no distinction, as far as the layer definition is concerned, between the parts of the
layer which are in the cylinder and the parts of the layer which are outside the cylinder. This distinction is
made by combining the LAYER concept with the REGION concept of the 2D base plane representation.
In a vertical cross-section we can label the parts as follows:
Notice that the cylinder can be uniquely identified as the intersection of the 'blob' region of the base plane
with the 'Everything' layer of the extrusion.
95 FlexP DE 7 : User G uide
2.6.3 Layering
Now suppose that we wish to model a canister rather than a full length cylinder. This requires that we
break up the material stack above region 2 into three parts, the canister and the continuation of the box
material above and below it.
We do this by specifying three layers (and four interface surfaces):
EXTRUSION
SURFACE "Bottom" z=-1/2
LAYER "Underneath"
SURFACE "Can Bottom" z=-1/4
LAYER "Can"
SURFACE "Can Top" z=1/4
LAYER "Above"
SURFACE "Top" z=1/2
We have now divided the 3D figure into six logical compartments: three layers above each of two base
regions.
Each of these compartments can be assigned unique material properties, and if necessary, unique
boundary conditions.
The cross section now looks like this:
User G uide : Using FlexP DE in Three-Dimensional P roblems 96
It would seem that we have nine compartments, but recall that region 1 completely surrounds the
cylinder, so the left and right parts of region 1 above are joined above and below the plane of the paper.
This results in six 3D volumes, denoted by the six colors in the figure.
We stress at this point that it is neither necessary nor correct to try to specify each compartment as a
separate entity. You do not need a separate layer and region specification for each material
compartment, and repetition of identical regions in the base plane or layers in the extrusion will cause
confusion.
The compartment structure is fully specified by the two coordinates REGION and LAYER, and any
compartment is identified by the intersection of the REGION in the base plane with the LAYER in the
extrusion.
Without the LAYER qualification clause, the definition would apply to all layers lying above region 2 of the
base plane. Here, the presence of the parameter definition inside a REGION and qualified by a LAYER
selects a specific 3D compartment to which the specification applies.
In the following diagram, we have labeled each of the six distinct compartments with a (region,layer)
coordinate.
97 FlexP DE 7 : User G uide
The comprehensive logical structure of parameter redefinitions in the BOUNDARIES section with the
location of parameter redefinition specifications in this grid can be described for the general case as
follows:
BOUNDARIES
REGION 1
params(1,all) { parameter redefinitions for all layers of region 1 }
LAYER 1
params(1,1){ parameter redefinitions restricted to layer 1 of region 1 }
LAYER 2
params(1,2){ parameter redefinitions restricted to layer 2 of region 1 }
LAYER 3
params(1,3){ parameter redefinitions restricted to layer 3 of region 1 }
START(,) .... TO CLOSE { trace the perimeter }
REGION 2
params(2,all) { parameter redefinitions for all layers of region 2 }
LAYER 1
params(2,1) { parameter redefinitions restricted to layer 1 of region 2 }
LAYER 2
params(2,2) { parameter redefinitions restricted to layer 2 of region 2 }
LAYER 3
params(2,3) { parameter redefinitions restricted to layer 3 of region 2 }
START(,) .... TO CLOSE { trace the perimeter }
The example problem "Samples | Usage | 3D_Domains | 3D_Void.pde 497 " demonstrates this usage.
Instead of propagating throughout the extrusion dimension, a LIMITED REGION exists only in the layers
and surfaces explicitly referenced in the declarations within the region. Mention of a layer causes the
LIMITED REGION to exist in the specified layer and in its bounding surfaces. Mention of a surface
causes the LIMITED REGION to exist in the specified surface.
In our ongoing example problem, we can specify:
LIMITED REGION 2 'blob' { the embedded blob }
LAYER 'Can' K = 0.001
99 FlexP DE 7 : User G uide
In this form, the canister is not propagated through the "Above" and "Underneath" layers:
Note: More uses of the ON clause, including plots on extrusion surfaces, will be discussed
later 113 .
We can also request plots of the computation grid (and by implication the domain structure) with the
User G uide : Using FlexP DE in Three-Dimensional P roblems 100
GRID command:
GRID(x,z) ON y=0
This command will draw a picture of the intersection of the plot plane with the tetrahedral mesh structure
currently being used by FlexPDE. The plot will be painted with colors representing the distinct material
properties present in the cross-section. 3D compartments with identical properties will appear in the
same color. The arguments of the GRID plot are the values to be displayed as the abscissa and ordinate
positions. Deformed grids can be displayed merely by modifying the arguments.
Since we have specified no boundary conditions on the top and bottom extrusion surfaces, they default
to zero flux. This is the standard default, for reasons explained in an earlier section.
The first three of the requested PLOTS are:
User G uide : Using FlexP DE in Three-Dimensional P roblems 102
103 FlexP DE 7 : User G uide
Boundary condition specifications that in 2D applied to a bounding curve are applied in 3D to the
extruded sidewalls generated by that curve.
The qualifier LAYER number or LAYER "name" may be applied to such a sidewall boundary
condition to restrict its application to a specific layer of the sidewall.
Boundary conditions for extrusion surfaces are constructed as if they were parameter redefinitions
over a REGION or over the entire 2D domain. In these cases, the qualifier SURFACE number or
SURFACE "name" must precede the boundary condition definition.
In the following figure, we have labeled the various surfaces which can be assigned distinct boundary
conditions. Layer interface surfaces have been labeled with an "s", while sidewall surfaces have been
labeled with "w". We have shown only a single sidewall intersection in our cross-sectional picture, but in
fact each segment of the bounding trace in the base plane can specify a distinct "w" type wall boundary
condition.
User G uide : Using FlexP DE in Three-Dimensional P roblems 104
The comprehensive logical structure of the BOUNDARIES section with the locations of the boundary
condition specifications in 3D can be diagrammed as follows:
BOUNDARIES
SURFACE 1
s(all, 1) { BC's on surface 1 over full domain }
SURFACE 2
s(all, 2) { BC's on surface 2 over full domain }
{…other surfaces }
REGION 1
SURFACE 1
s(1,1) { BC's on surface 1, restricted to region 1 }
SURFACE 2
s(1,2) { BC's on surface 2, restricted to region 1 }
...
START(,) { -- begin the perimeter of region m }
w(1,..) { BC's on following segments of sidewall of region 1 on all layers }
LAYER 1
w(1,1) { BC's on following segments of sidewall of region 1, restricted to layer 1
}
LAYER 2
w(1,2) { BC's on following segments of sidewall of region 1, restricted to layer 2
}
...
LINE TO ....
{ segments of the base plane boundary with above BC's }
LAYER 1
w(1,1) { new BC's on following segments of sidewall of region 1, restricted to
layer 1 }
...
LINE TO ....
{ continue the perimeter of region 1 with modified boundary conditions }
TO CLOSE
REGION 2
105 FlexP DE 7 : User G uide
SURFACE 1
s(2,1) { BC's on surface 1, restricted to region 2 }
SURFACE 2
s(2,2) { BC's on surface 2, restricted to region 2 }
...
START(,) { -- begin the perimeter of region m }
w(2,..) { BC's on following segments of sidewall of region 2 on all layers }
LAYER 1
w(2,1){ BC's on following segments of sidewall of region 2, restricted to layer
1}
LAYER 2
w(2,2){ BC's on following segments of sidewall of region 2, restricted to layer
2}
...
LINE TO ....
{ segments of the base plane boundary with above BC's }
LAYER 1
w(2,1) { new BC's on following segments of sidewall of region 2, restricted
to layer 1 }
...
LINE TO ...
{ continue the perimeter of region 2 with modified boundary conditions }
TO CLOSE
Remember that, as in 2D, REGIONS appearing later in the script will overlay and cover up portions of
earlier regions in the base plane. So the real extent of REGION 1 is that part of the base plane within the
perimeter of REGION 1 which is not contained in any later REGION.
For an example of how this works, suppose we want to apply a fixed temperature "Tcan" to the surface
of the canister of our previous example. The canister portion of the domain has three surfaces, the
bottom, the top, and the sidewall.
The layer dividing SURFACES that define the bottom and top of the canister are named 'Can Bottom' and
'Can Top'. The part we want to assign is that part of the surfaces which lies above region 2 of the base
plane. We therefore put a boundary condition statement inside of the region 2 definition, together with a
SURFACE qualifier.
The sidewall of the canister is the extrusion of the bounding line of REGION 2, restricted to that part
contained in the layer named 'Can'. So we add a boundary condition to the bounding curve of REGION
2, with a LAYER qualifier.
Figures must maintain an extruded shape, with sidewalls and layer interfaces (the sidewalls cannot
grow or shrink)
Layer interface surfaces must be continuous across region boundaries. If a surface has a vertical
jump, it must be divided into layers, with a region interface at the jump boundary and a layer spanning
the jump. (Not this: but this: )
Layer interface surfaces may merge, but may not invert. Use a MAX or MIN function in the surface
definition to block inversion.
Using these rules, we can convert the canister of our example into a sphere by placing spherical caps
on the cylinder.
The equation of a spherical end cap is
Z = Zcenter + sqrt( R^2 – x^2 – y^2)
Or,
Z = Ztop – R + sqrt(R^2 – x^2 – y^2)
To avoid grazing contact of this new sphere with the top and bottom of our former box, we will
extend the extrusion from –1 to 1.
To avoid arithmetic errors, we will prevent negative arguments of the sqrt.
LAYER 'Can'
SURFACE 'Sphere Top' z = max(Zsphere,0)
LAYER 'above'
SURFACE 'Top' z=1
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 LINE TO (1,-1)
NATURAL(Phi)=0 LINE TO (1,1)
VALUE(Phi)=1 LINE TO (-1,1)
NATURAL(Phi)=0 LINE TO CLOSE
LIMITED REGION 2 'blob' { the embedded blob }
LAYER 2 K = 0.001
START 'ring' (RSphere,0)
ARC(CENTER=0,0) ANGLE=360
TO CLOSE
PLOTS
GRID(y,z) on x=0
CONTOUR(Phi) on x=0
VECTOR(-k*grad(Phi)) on x=0
ELEVATION(Phi) FROM (0,-1,0) to (0,1,0)
END
Cut-away and cross-section images of the LAYER x REGION compartment structure of this layout
looks like this:
Notice that because of the symmetry of the 3D figure, this plot looks like a rotation of the 2D contour
plot in "Putting It All Together".
We can also build a duct with cylindrical top and bottom surfaces using the following script fragments:
DEFINITIONS
R0 = 1 { cylinder radius }
Len = 3 { cylinder length }
theta = 45 { axis direction in degrees }
c = cos(theta degrees) { direction cosines of the axis direction }
109 FlexP DE 7 : User G uide
s = sin(theta degrees)
x0 = -(len/2)*c { beginning point of the cylinder axis }
y0 = -(len/2)*s
zoff = 10 { a z-direction offset for the entire figure }
{ The cylinder function constructs the top surface of a cylinder with azis along z=0.5. The
positive and negative values of this surface will be separated by a distance of one unit at
the diameter. }
zs = CYLINDER((x0,y0,0.5), (x0+Len*c,y0+Len*s, 0.5), R0)
EXTRUSION
SURFACE z = zoff-zs { the bottom half-surface }
SURFACE z = zoff+zs { the top half-surface }
BOUNDARIES
REGION 1
START (x0,y0)
LINE TO (x0+R0*c,y0-R0*s)
TO (x0+Len*c+R0*c,y0+Len*s-R0*s)
TO (x0+Len*c-R0*c,y0+Len*s+R0*s)
TO (x0-R0*c,y0+R0*s)
TO CLOSE
See the example problem "Samples | Usage | 3D_Domains | 3D_Cylspec.pde" for the complete cylinder
script.
2.6.12 Integrals in Three Dimensions
In three-dimensional problems, volume integrals may be computed over volume compartments selected
User G uide : Using FlexP DE in Three-Dimensional P roblems 110
Result = VOL_INTEGRAL(<integrand>)
Computes the integral of the integrand over the entire domain.
Surface integrals may be computed over selected surfaces. From the classification of various qualifying
names, FlexPDE tries to infer what surfaces are implied in a surface integral statement. In the case of
non-planar surfaces, integrals are weighted by the actual surface area.
Result = SURF_INTEGRAL(<integrand>)
Computes the integral of the integrand over the outer bounding surface of the total domain.
Note: The example problem "Samples | Usage | 3D_Integrals.pde 578 " demonstrates several
forms of integral in a three-dimensional problem.
Let us modify our Canister problem to contain a heat source, and compare the volume integral of the
source with the surface integral of the flux, as checks on the accuracy of the solution:
TITLE 'Heat flow from an Insulating Canister'
COORDINATES
Cartesian3
VARIABLES
Phi { the temperature }
DEFINITIONS
K=1 { default conductivity }
R = 0.5 { blob radius }
S= 0
EQUATIONS
Div(-k*grad(phi)) = S
EXTRUSION
SURFACE 'Bottom' z=-1/2
LAYER 'underneath'
SURFACE 'Can Bottom' z=-1/4
LAYER 'Can'
SURFACE 'Can Top' z=1/4
LAYER 'above'
SURFACE 'Top' z=1/2
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 LINE TO (1,-1)
NATURAL(Phi)=0 LINE TO (1,1)
VALUE(Phi)=1 LINE TO (-1,1)
NATURAL(Phi)=0 LINE TO CLOSE
REGION 2 'blob' { option: could be LIMITED }
LAYER 2 k = 0.001 { the canister only }
S= 1 { still the canister }
START 'ring' (R,0)
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
PLOTS
GRID(y,z) on x=0
CONTOUR(Phi) on x=0
VECTOR(-k*grad(Phi)) on x=0
ELEVATION(Phi) FROM (0,-1,0) to (0,1,0)
SUMMARY
User G uide : Using FlexP DE in Three-Dimensional P roblems 112
Note: The "Integral" reported at the bottom of the contour plot is the default
Area_Integral(Phi) reported by the plot processor.
requests a contour plot of the potential Phi on the extrusion surface named 'Sphere Top', restricted to the
region 'Blob'.
CONTOUR(NORMAL(-K*GRAD(Phi))) ON 'Sphere Top' ON 'Blob' ON 'Can'
requests a contour plot of the normal component of the heat flux on the top part of the sphere, with
evaluation to be made within layer 'Can', i.e., inside the sphere.
In general, the qualifier ON <name> will request a localization of the plot, depending on the type of
object named by <name>.
The qualifier ON REGION <number> selects a region by number, rather than by name.
The qualifier ON SURFACE <number> selects a layer interface surface by number, rather than by
name.
The qualifier ON LAYER <number> selects a layer by number, rather than by name.
As an example, let us request a plot of the heat flux on the top of the sphere, as shown above. We will
add this command to the PLOTS section, and also request an integral over the same surface, as a cross
check. The plot generator will automatically compute the integral over the plot grid. This computation
should give the same result as the SURF_INTEGRAL, which uses a quadrature on the computation mesh.
CONTOUR(NORMAL(-K*GRAD(Phi))) ON 'Sphere Top' ON 'Blob' ON 'Can'
REPORT(SURF_INTEGRAL(NORMAL(-k*GRAD(Phi)),'Sphere Top','Blob','Can'))
AS 'Surface Flux'
Since in this case the integral is a cancellation of values as large as 7e-4, the reported "Surface Flux"
value of -5.2e-8 is well within the default error target of ERRLIM=0.002. The automatically generated
plot grid integral, "Surf_Integral", shows greater error at -6.49e-5, due to poorer resolution of integrating
the area-weighted function in the plot plane.
Subsequently, the complex variable C can be referenced by name, or its components can be accessed
independently by their names.
115 FlexP DE 7 : User G uide
In the EQUATIONS section, each complex variable can be given an equation, which will be interpreted as
dealing with complex quantities. The complex equation will be processed by FlexPDE and reduced to
two real component equations, by taking the real and imaginary parts of the resulting complex equation.
For example, the time-harmonic representation of the heat equation can be presented as
EQUATIONS
C: DIV(k*GRAD(C)) - COMPLEX(0,1)*C = 0
In a similar way, boundary conditions may be assigned either to the complex equation or to each
component equation individually:
VALUE(C) = COMPLEX(1,0) assigns 1 to the real part and 0 to the imaginary part of C
or
VALUE(Cr) = 0 NATURAL(Ci) = 0
Any parameter definition in the DEFINITIONS section may be declared COMPLEX as well:
DEFINITIONS
complexname = COMPLEX(realpart, imaginarypart)
COMPLEX quantities can be the arguments of PLOT commands, as well. Occurrence of a complex
quantity in a PLOT statement will be interpreted as if the real and imaginary parts had been entered
separately in the PLOT command.
ELEVATION(C) FROM A TO B
will produce a plot with two traces, the real and imaginary parts of C.
User G uide : C omplex Variables 116
Substituting in the heat equation and dividing out the exponential term, we are left with a complex
equation
Div(K*Grad(Cphi)) - Complex(0,1)*Cphi = 0
The time-varying temperature Phi can be recovered from the complex Cphi simply by multiplying by the
appropriate time exponential and taking the real part of the result.
The modified script becomes:
TITLE 'Heat flow around an Insulating blob'
VARIABLES
Phi = Complex(Phir,Phii) { the complex temperature amplitude }
DEFINITIONS
K=1 { default conductivity }
R = 0.5 { blob radius }
EQUATIONS
Phi: Div(-k*grad(phi)) - Complex(0,1)*Phi = 0
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=Complex(0,0) LINE TO (1,-1)
NATURAL(Phi)=Complex(0,0) LINE TO (1,1)
VALUE(Phi)=Complex(1,0) LINE TO (-1,1)
NATURAL(Phi)=Complex(0,0) LINE TO CLOSE
REGION 2 'blob' { the embedded blob }
k = 0.01 { change K for prettier pictures }
START 'ring' (R,0)
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
PLOTS
CONTOUR(Phir) CONTOUR(Phii)
VECTOR(-k*grad(Phir))
ELEVATION(Phi) FROM (0,-1) to (0,1)
ELEVATION(Normal(-k*grad(Phir))) ON 'ring'
END
Running this script produces the following results for the real and imaginary components:
117 FlexP DE 7 : User G uide
User G uide : C omplex Variables 118
We can also reconstruct the time history at selected positions using ARRAYS 201 . The ARRAY facility
allows us to declare arbitrary arrays of values, manipulate them and plot them.
We will declare an array of time points at which we wish to evaluate the temperature, and compute the
sin and cos factors at those times. We also define an ARRAY -valued function to return the time history at
a point:
DEFINITIONS
User G uide : C omplex Variables 120
Two of the plots produced by the addition of these script lines are:
121 FlexP DE 7 : User G uide
The component directions are associated by position with the directions implicit in the selected
COORDINATES. In YCYLINDER (R,Z,Phi) coordinates, the vector components will be (Vr,Vz,Vphi).
Components may be omitted from the right, in which case the missing components will be assumed to
have zero value.
User G uide : Vector Variables 122
A component may be explicitly declared to have zero value, by writing a 0 in its component position, as
in
V = VECTOR(0,0,Vphi)
This will construct a one-variable model, in which the variable is the azimuthal vector component.
Subsequently, the vector variable V can be referenced by name, or its components can be accessed
independently by their names.
In the EQUATIONS section, each vector variable can be given an equation, which will be interpreted as
dealing with vector quantities. The vector equation will be processed by FlexPDE and reduced to as
many real component equations as are named in the declaration, by taking the corresponding parts of the
resulting vector equation.
For example, the three dimensional cartesian representation of the Navier-Stokes equations can be
presented as
EQUATIONS
V: dens*DOT(V,GRAD(V)) + GRAD(p) - visc*DIV(GRAD(V)) = 0
In a similar way, boundary conditions may be assigned either to the complex equation or to each
component equation individually:
VALUE(V) = VECTOR(1,0,0)
or
VALUE(Vx) = 0 NATURAL(Vy) = 0
Any parameter definition in the DEFINITIONS section may be declared VECTOR as well:
DEFINITIONS
vectorname = VECTOR(xpart,ypart,zpart)
VECTOR quantities can be the arguments of PLOT commands, as well. Occurrence of a vector quantity
in a PLOT statement will be interpreted as if the component parts had been entered separately in the
PLOT command.
ELEVATION(V) FROM A TO B
will produce a plot with as many traces as are active in the COORDINATES definition.
Examples:
Samples | Usage | Vector_Variables | Vector_Variables.pde 649
123 FlexP DE 7 : User G uide
The extra 1/R^2 terms have arisen from the differentiation of the unit vectors.
FlexPDE performs the correct expansion of the differential operators in all supported coordinate
systems.
In solving the EQUATIONS for these variables, it will be as if the INACTIVE regions had not been
included in the domain definition. Boundaries between regions in which the variables are active and
those in which they are inactive will be treated as exterior boundaries for these variables. Boundary
conditions may be placed on these boundaries as if they were the exterior boundary of the system.
This plot of temperature shows diffusion beyond the boundaries of the beaker.
129 FlexP DE 7 : User G uide
This plot of concentration A shows depression in the center where higher temperature increases the
reaction rate. No chemical diffuses beyond the beaker boundary.
User G uide : Variables Inactive in Some Regions 130
This plot of temperature history shows an average value of 0.196348. This agrees favorably with the
energy conservation value of H*pi*Rad^2/(Cp*Box^2) = 0.196350. The residual quantity of B is
correct at 1.0.
BOUNDARIES
START (0,0) VELOCITY(xm) = umesh
The specification of ordinary equations is unaffected by the motion of the boundaries or mesh.
EQUATIONS are assumed to be presented in Eulerian (Laboratory) form. FlexPDE symbolically
applies motion correction terms to the equations. The result of this approach is an Arbitrary Lagrange/
Eulerian (ALE) model, in which user has the choice of mesh velocities:
Locking the mesh velocity to a fluid velocity results in a Lagrangian model. (FlexPDE has no
mechanism for reconnecting twisted meshes, so this model is discouraged in cases of violent motion).
Specifying a mesh velocity different from the fluid velocity preserves mesh integrity while still allowing
deformation of the bounding surfaces or following bulk motion of a fluid.
If no mesh motion is specified, the result is an Eulerian model, which has been the default in previous
versions of FlexPDE.
The EQUATIONS section is assumed to present equations in the Eulerian (Laboratory) frame.
The EQUATIONS section can optionally labeled LAGRANGIAN EQUATIONS, in which case
FlexPDE will apply no motion corrections to the equations. The user must then provide equations that
are appropriate to the moving nodes.
For clarity, the section label EULERIAN EQUATIONS can be used to specify that the equations are
appropriate to the laboratory reference frame. This is the default interpretation.
For the EQUATIONS of the mesh coordinates, we will use simple diffusion equations to distribute the
positions smoothly in the interior, expecting the actual motions to be driven by boundary conditions:
User G uide : Moving Meshes 132
Div(Grad(Xm)) = 0
Div(Grad(Ym)) = 0
We can apply the boundary velocities directly to the mesh coordinates on the blob surface using the time
derivative of R and geometric rules:
VELOCITY(Xm) = -0.25*sin(t)*x/r
VELOCITY(Ym) = -0.25*sin(t)*y/r
Alternatively, we can define mesh velocity variables as well as the surrogate coordinates for X and Y:
VARIABLES
Phi
Xm = MOVE(x)
Ym = MOVE(y)
Um
Vm
The EQUATIONS for the mesh coordinates are simply the velocity relations:
dt(Xm) = Um
dt(Ym) = Vm
For the mesh velocities we will use a diffusion equation to distribute the velocities smoothly in the interior:
div(grad(Um)) = 0
div(grad(Vm)) = 0
The boundary conditions for mesh velocity on the blob are as above:
VALUE(Um) = -0.25*sin(t)*x/r
VALUE(Vm) = -0.25*sin(t)*y/r
Since the finite element equations applied at the boundary nodes are averages over the cells, we must
also apply the hard equivalence of velocity to the mesh coordinates on the blob boundary
VELOCITY(Xm) = Um
VELOCITY(Ym) = Vm
VARIABLES
Phi { the temperature }
Xm = MOVE(x) { surrogate X }
Ym = MOVE(y) { surrogate Y }
DEFINITIONS
K=1 { default conductivity }
R0 = 0.75 { initial blob radius }
EQUATIONS
Phi: Div(-k*grad(phi)) = 0
Xm: div(grad(Xm)) = 0
Ym: div(grad(Ym)) = 0
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0 VELOCITY(Xm)=0 VELOCITY(Ym)=0
LINE TO (1,-1)
NATURAL(Phi)=0 LINE TO (1,1)
VALUE(Phi)=1 LINE TO (-1,1)
NATURAL(Phi)=0 LINE TO CLOSE
REGION 2 'blob' { the embedded blob }
k = 0.001
START 'ring' (R,0)
VELOCITY(Xm) = -0.25*sin(t)*x/r
VELOCITY(Ym) = -0.25*sin(t)*y/r
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
TIME 0 TO 2*pi
PLOTS
FOR T = pi/2 BY pi/2 TO 2*pi
GRID(x,y)
CONTOUR(Phi)
VECTOR(-k*grad(Phi))
ELEVATION(Phi) FROM (0,-1) to (0,1)
ELEVATION(Normal(-k*grad(Phi))) ON 'ring'
END
The extremes of motion of this problem are shown below. See Help system or online documentation for
an animation.
User G uide : Moving Meshes 134
The position and velocity forms of this problem can be seen in the following examples:
Samples | Usage | Moving_Mesh | 2D_Blob_Position.pde 605
controls the maximum cell size. The mesh will be generated with approximately NGRID cells in the
largest dimension, and corresponding size in the smaller dimension, subject to smaller size requirements
from other criteria.
Explicit Density Control
Cell density in the initial mesh may be controlled with the parameters MESH_SPACING 214 and
MESH_DENSITY 214 . MESH_SPACING controls the maximum cell dimension, while MESH_DENSITY is
its inverse, controlling the minimum number of cells per unit distance. The mesh generator examines
135 FlexP DE 7 : User G uide
many competing effects controlling cell size, and accepts the smallest of these effects as the size of a cell.
The MESH_SPACING and MESH_DENSITY controls therefore have effect only if they are the smallest of
the competing influences, and a large spacing request is effectively ignored.
The MESH_SPACING and MESH_DENSITY controls can be used with the syntax of either defined
parameters or boundary conditions.
Used as defined parameters, these controls may appear in the DEFINITONS section or may be redefined
in subsequent regional redefinition sections. In this use, the controls specify the volume or area mesh
density over a region or over the entire domain.
For controlling the cell density along boundary segments, the controls MESH_SPACING and
MESH_DENSITY may be used with the syntax of boundary conditions, and may appear wherever a
boundary condition statement may appear. In this usage, the controls specify the cell spacing on the
boundary curve or surface.
The value assigned to MESH_SPACING or MESH_DENSITY controls may be functions of spatial
coordinate. In the example of the chapter "Generating a Mesh" 54 , we could write:
REGION 2 'blob' { the embedded 'blob' }
MESH_DENSITY = 50*EXP(-50*(x^2+y^2))
START(1/2,0)
ARC(CENTER=0,0) ANGLE=360
Once the initial mesh is constructed, FlexPDE will continue to estimate the solution error, and will refine
the mesh as necessary to meet the target accuracy. In time dependent problems, an adaptive refinement
process will also be applied to the initial values of the variables, to refine the mesh where the variables
undergo rapid change. Whereas cells created by this adaptive refinement process can later be re-
merged, cells created by the initial explicit density controls are permanent, and cannot be un-refined.
Note: The adaptive refinement process relies on evaluation of the various sources and
derivatives at discrete points within the existing mesh. Sources or other effects which are of
extremely small extent, such as thin bands or point-like functions, may not be discernible in
this discrete model. Any effects of small extent should be brought to the attention of the
gridder by explicitly placing gridding features at these locations. Use REGIONS or FEATURES
233 wherever something interesting is known to take place in the problem.
See also the FRONT 242 and RESOLVE 243 statements for additional controls.
Note: The domain structure must exactly match that of the exporting problem.
Examples:
"Samples | Usage | Import-Export | Post_Processing.pde" 570
"Samples | Usage | Import-Export | 3D_Post_Processing.pde" 563
137 FlexP DE 7 : User G uide
In all cases of FORMATTED export, a header will be written containing descriptive information about the
origin of the file. This header will be delimited by "{" and "}". In 2D grids, table points which are outside
the problem domain will also be bracketed by "{" and "}" and marked as "exterior". If these commenting
forms are unacceptable to the importing application, then the data files must be manually edited before
import.
TABLE Output
The TABLE 209 plot command may also be used to generate tabular export. This command is identical to
a CONTOUR command with an EXPORT qualifier, except that no graphical output is generated. The
FORMAT "string" qualifier may also be used with TABLE output.
FlexPDE supports the capability of direct transfer of data defined on the Finite Element mesh. The
TRANSFER output function writes the current mesh structure and the requested data values to an ASCII
text file. Another FlexPDE problem can read this file with the TRANSFER input function. The
transferred data will be interpolated on the output mesh with the Finite Element basis of the creating
problem. The TRANSFER input mesh need not be the same as the computation mesh, as long as it spans
the necessary area.
The data format of the TRANSFER file is similar to the TECPLOT file described below. The TRANSFER
file, however, maintains the quadratic or cubic basis of the computation, while the TECPLOT format is
converted to linear basis. Since this is an ASCII text file, it can also be used for data transfer to user-
written applications. The format of the TRANSFER file is described in the Problem Descriptor Reference
chapter "Transfer File Format 262 "
CDF
CDF(arg1 [,arg2,…] ) selects output in netCDF version 3 format. CDF stands for "common data
format", and is supported by several software products including SlicerDicer (www.visualogic.com ).
Information about CDF , including a list of software packages supporting it, can be viewed at the website
www.unidata.ucar.edu/packages/netcdf .
CDF data are constrained to be on a regular rectangular mesh, but in the case of irregular domains, parts
of the rectangle can be absent. This regularity implies some loss of definition of material interfaces, so
consider using a ZOOMed domain to resolve small features.
The CDF "plot" statement can be qualified by ZOOM or "ON SURFACE" modifiers, and its density can be
controlled by the POINTS modifier. For global control of the grid size, use the statement "SELECT
CDFGRID=n", which sets all dimensions to n. The default gridsize is 50.
Any number of arguments can be given, and all will be exported in the same file. The output file is by
default "<problem>_<sequence>.cdf", but specific filenames can be selected with the FILE modifier.
TECPLOT
TECPLOT(arg1 [,arg2,…] ) selects output in TecPlot format. TecPlot is a visualization package which
supports finite element data format, and so preserves the material interfaces as defined in FlexPDE. No
ZOOM or POINTS control can be imposed. The full computation mesh is exported, grouped by material
number. TecPlot can selectively enable or disable these groups. Any number of arguments can be
given, and all will be exported in the same file. The output file is by default
"<problem>_<sequence>.dat", but specific filenames can be selected with the FILE modifier.
139 FlexP DE 7 : User G uide
VTK
VTK(arg1 [,arg2,…] ) selects output in Visual Tool Kit format. VTK is a freely available library of
visualization software, which is beginning to be used as the basis of many visualization packages. The file
format can also be read by some visualization packages that are not based on VTK, such as VisIt
(www.llnl.gov/visit). The format preserves the mesh structure of the finite element method, and so
preserves the material interfaces as defined in FlexPDE. No ZOOM or POINTS control can be imposed.
The full computation mesh is exported. Particular characteristics of the visualization system are outside
the control of FlexPE. Any number of arguments can be given, and all will be exported in the same file.
The output file is by default "<problem>_<sequence>.vtk", but specific filenames can be selected with
the FILE modifier.
The VTK format supports quadratic finite element basis directly, but not cubic. To export from cubic-
basis computations, use VTKLIN.
VTKLIN(arg1 [,arg2,…] ) produces a VTK format file in which the native cells of the FlexPDE
computation have been converted to a set of linear-basis finite element cells.
Information about VTK can be viewed at public.kitware.com/VTK/.
Examples:
Samples | Usage | Import-Export | Export.pde 566
Note:
Reference to products from other suppliers does not constitute an endorsement by PDE Solutions Inc.
Suppose that in our example problem 58 we wish to define a thermal conductivity that varies with
temperature (called "Phi" in the example script). We could simply define a temperature-dependent
function for the conductivity. But if the dependency is derived from observation, there may be no simple
analytic relationship. In this case, we can use a TABLE to describe the dependency.
A table file describing conductivity vs temperature might look like this:
{ Conductivity vs temperature }
Phi 6
1 2 10 22 67 101
Data
0.01 0.02 0.05 0.11 0.26 3.8
Supposing that we have named this file "conductivity.tbl", our script will simply include the following
definition:
K = TABLE("conductivity.tbl")
Notice that within the table file, the name Phi is declared as the table coordinate. When FlexPDE reads
the table file, this name is compared to the names of defined quantities in the script, and the connection is
made between the data in the table and the value of "Phi" at any point in the computation where a value
of "K" is required.
If the table file had defined the table coordinate as, say, "Temp", we could still use the table in our
example by over-riding the table file definition with a new dependency coordinate:
K = TABLE("conductivity.tbl", Phi)
This statement would cause FlexPDE to ignore the name given in the file itself and associate the table
coordinate with the local script value "Phi".
Other forms of TABLE command are available. See the Problem Descriptor Reference chapter "Table
Import Definitions" 208 for more information.
Similarly, MATRICES can be created and filled with data using one of the available declaration
statements, e.g.,
M = MATRIX((1,2,3),(4,5,6),(7,8,9))
N = MATRIX FOR x(0 BY 0.1 TO 10)
FOR y(0 BY 0.1 TO 10) : sin(x)*sin(y)+1.1
The special operators ** and // are defined for specifying conventional matrix-array arithmetic:
R = N**B { R is an ARRAY representing the conventional matrix-array multiplication of B
by N }
S = B//N { S is the solution of the equation N**S=B (i.e., S is the result of multiplying B
by the inverse of N) }
ARRAYS and MATRICES may also be used to define domain boundaries. See "Boundary Paths" 229 in
the Problem Descriptor Reference.
All operations on ARRAYS and MATRICES are checked for compatible sizes, and incompatibilities will
be reported as errors.
Note: You must remember that the FlexPDE script is not a procedural program. Objects in
the script describe the dependencies of quantities, and are not "current state" records of
values that can be explicitly modified by subsequent redefinition or looping.
Examples:
See the example folder "Samples | Usage | Arrays+Matrices" 513
User G uide : Solving Nonlinear P roblems 142
Time-Dependent Problems
In nonlinear time-dependent problems, the default behavior is to take a single Newton step at each
timestep, on the assumption that any nonlinearities will be sensed by the timestep controller, and that
timestep adjustments will guarantee an accurate evolution of the system from the given initial conditions.
In this mode, the derivatives of the solution with respect to the variables is computed once at the
beginning of the timestep, and are not updated.
Steady-State Problems
In the case of nonlinear steady-state problems, the situation is somewhat more complicated. We are not
guaranteed that the system will have a unique solution, and even if it does, we are not guaranteed that
FlexPDE will be able to find it.
brief, you can use a term eps*Div(Grad(u)) in a PDE to smooth oscillations of spatial extent D by
setting eps=D^2/pi^2 in steady state or eps=2*D*c/pi in time dependence (where c is the signal
propagation velocity). The term should also be scaled as necessary to provide dimensional
consistency with the rest of the terms of the equation. Use of such a term merely limits the spatial
frequency components of the solution to those which can be adequately resolved by the finite
element mesh.
Matrix construction, residual calculations, linear system solvers and plot mesh generation are all multi-
threaded. Computation mesh generation and plot display functions are not, although graphics load is
shared between the problem thread and the main graphics thread.
requests that <number> worker threads be used, in addition to the main graphics thread and the
individual problem thread.
Command-Line Control
If you run FlexPDE from a command line and include the switch -T<number>, the default thread count
will be set to <number>. For example, the command line
flexpde7 -T4 problem
will set the default to 4 threads and load the script file "problem.pde". The selected thread count will be
written to the .ini file on conclusion of the flexpde session and become the default next time FlexPDE is
run.
Black_Oil.pde 3D_FlowBox.pde
Version Threads CPU time timesteps CPU time
5 1 14:37 534 8:15
5 2 12:17 540 6:09
-R Run the file which is named on the command line. Do not enter edit mode.
-V View the file which is named on the command line. Do not enter edit mode.
-X Exit FlexPDE when the problem completes.
-M Run in "minimized" mode (reduced to an icon).
-Q Run "quietly". Combines -R -X -M.
-S Run "silently". -Q with all error reports suppressed. Also, no icon should appear in the
system taskbar.
-T Set the default thread count. Append the number : -T6 will use six threads.
-L License FlexPDE. For Internet Key, append A for activate, R for release, then serial
number : -LA668668886. For local or network dongle, append D or N followed by
dongle ID : -LD2-2428250.
-I Report the computer specific ID for FlexPDE.
-NC Turn off consolidation of output.
-NM Turn off automatic import of previous mesh.
-NI Turn off loading and saving of preferences from .ini file.
User G uide : Running FlexP DE from the C ommand Line 146
Note : On the Mac, the actual executable code is located inside of an application "bundle",
which is simply a directory hierarchy that is hidden from the user in graphics mode. The
complete path to the executable would be "FlexPDE7.app/Contents/MacOS/flexpde7". See the
Apple developer website for more information about application bundles.
The graphics-less FlexPDE must be run from a command line. For example, the command line
flexpde7n problem
The run can be interrupted by typing 'Q'. The user is then prompted whether to interrupt or not. Type 'Y'
to complete the interrupt.
Send your enquiry to [email protected] and we will answer as soon as we can, usually within a
day or two.
Part
III
Problem
Descriptor
Reference
149 FlexP DE 7 : P roblem Descriptor Reference
3.1 Introduction
FlexPDE is a script-driven system. It reads a description of the equations, domain, auxiliary definitions
and graphical output requests from a text file referred to as a "problem descriptor" or "script".
The problem descriptor file can be created either with the editor facility in FlexPDE, or with any other
ASCII text editor. A word processor can be used only if there is an optional "pure text" output, in which
formatting codes have been stripped from the file.
Problem descriptors use an easy to learn natural language originally developed by Robert G. Nelson for
use in the PDS2 system at Lawrence Livermore National Lab and later in the PDEase2 system from
Macsyma, Inc. The language is also described in Dr. Gunnar Backstrom's book, "Simple Fields of
Physics by Finite Element Analysis".
As FlexPDE has evolved, a number of extensions have been added to extend its processing capabilities.
The language as currently implemented in FlexPDE is described in this document.
While similar in some ways to a computer programming language, FlexPDE scripting language is more
natural, and is oriented to the description of PDE systems. Most intermediate level college students,
engineers, and scientists who have had at least an introductory course in partial differential equations can
quickly master the language well enough to prepare simple problem descriptor files and begin solving
problems of their own devising.
The FlexPDE problem descriptor language can be viewed as a shorthand language for creating Finite
Element models. The statements of the descriptor provide the information necessary for FlexPDE to
assemble a numerical process to solve the problem.
It is important to understand that the language of FlexPDE problem descriptors is not a procedural one.
The user describes how the various components of the system relate to one another. He does not
describe a sequence of steps to be followed in forming the solution, as would be done in a procedural
programming language such as C or FORTRAN. Based on the relations between problem elements,
FlexPDE decides on the sequence of steps needed in finding the solution.
FlexPDE makes various assumptions about the elements of the problem descriptor.
it will be approximated by a finite element interpolation between the nodes of a computation mesh,
the values of the variable are continuous over the domain, and
a partial differential equation will be defined describing the behavior of the variable.
If a definition appears in the DEFINITIONS section, it is assumed that the named quantity
is ancillary to the PDE system,
may be discontinuous over the domain,
does not (necessarily) obey any PDE.
In the chapters that follow, we describe in detail the rules for constructing problem descriptors.
To begin a new descriptor file, simply click "File | New Script" from the FlexPDE main menu bar.
A convenient way to create a new descriptor is to start with a copy of an existing descriptor for a similar
problem and to modify it to suit the new problem conditions.
FlexPDE's built-in editor is similar to the Windows Notepad editor and produces a pure ASCII text file
without any imbedded formatting characters. Descriptor files can also be prepared using any ASCII text
editor or any editor capable of exporting a pure ASCII text file. Descriptor files prepared with word
processors that embed formatting characters in the text will cause FlexPDE to report parsing errors.
Problem descriptor files must have the extension '.pde'. When saving a file using the built-in editor,
FlexPDE will automatically add the extension '.pde'. When using a separate or off-line editor, be sure to
give the file a '.pde' extension instead of the default extension.
Windows operating systems by default hide the file name extension. FlexPDE script files can still be
recognized by the icon. Alternatively, Windows can be configured to display file extensions.
Each section is headed by a proper name followed by one or more statements which define the problem.
The number of sections used in a particular problem descriptor can vary, subject only to the requirement
that all files must contain a BOUNDARIES section and an END section.
While some flexibility exists in the placement of these sections, it is suggested that the user adhere to the
ordering described above.
Because descriptors are dynamically processed from top to bottom, they cannot contain forward
references. Definitions may refer to variables and other defined names, provided these variables and
names have been defined in a preceding section or previously in the same section.
For detailed description of these sections, see "The Sections of a Descriptor" 183 .
P roblem Descriptor Reference : Introduction 152
section 1
statement
section 2
statement 1
statement 2
*
*
section 3
statement 1
statement 2
*
*
This format is easy for both the person preparing the file and for others to read and understand.
The text items variables, VARIABLES, Variables and mixed case text like VaRiAbles are all
equivalent.
Judicious use of capitalization can improve the readability of the script.
#INCLUDE "filename"
will cause the named file to be included bodily in the descriptor in place of the #INCLUDE "filename"
statement.
153 FlexP DE 7 : P roblem Descriptor Reference
If the file does not reside in the same folder as the descriptor, the full path to the file must be given.
An include statement can be placed anywhere in the descriptor, but for readability it should be placed on
its own line.
This facility can be used to insert common definition groups in several descriptors.
Note: Although FlexPDE is not case sensitive, the operating system which is being asked for
the included file may be case sensitive. The quoted file name must conform to the usage of the
operating system.
If K is constant and Source = 4*K, the heat equation will be satisfied by the function
Temp = Const - x^2 - y^2 .
We define a square region of material of conductivity K = 1, with a uniform heat source of 4 heat units
per unit area.
We further specify the boundary value
Temp = 1 - x^2 - y^2
Since we know the analytic solution, we can compare the accuracy of the FlexPDE solution.
VARIABLES
temp { Identify "Temp" as the system variable }
P roblem Descriptor Reference : Introduction 154
DEFINITIONS
k=1 { declare and define the conductivity }
source = 4 { declare and define the source }
texact = 1-x^2-y^2 { exact solution for reference }
INITIAL VALUES
temp = 0 { unimportant in linear steady-state problems,
but necessary for time-dependent or nonlinear
systems }
MONITORS
CONTOUR(temp) { show the Temperature during solution }
3.2.1 Comments
Problem descriptors can be annotated by adding comments.
Multi-line comments can be placed anywhere in the file. Multi-line comments are formed by enclosing
the desired comments in either curly brackets { and } or the paired symbols /* and */. Comments can be
155 FlexP DE 7 : P roblem Descriptor Reference
nested, but comments that begin with a curly bracket must end with a curly bracket and comments that
begin with '/*' must end with '*/'.
Example:
{ this is a comment
so is this.
}
End-of-line comments are introduced by the exclamation mark !. End-of-line comments extend from
the ! to the end of the line on which they occur. Placing the line comment symbol ! at the beginning of a
line effectively removes the whole line from the active portion of the problem descriptor, in a manner
similar to 'rem' at the beginning of a line in a DOS batch file or "//" in C++.
Example:
! this is a comment
this is not
Comments can be used liberally during script development to temporarily remove lines from a problem
descriptor. This aids in localizing errors or focusing on specific aspects of a problem.
3.2.2 Reserved Words and Symbols
FlexPDE assigns specific meanings and uses to a number of predefined 'reserved' words and symbols in
descriptors.
Except when they are included as part of a comment or a literal string, these words may only be used for
their assigned purpose.
BATCH BC BEVEL
BLOCK BOUNDARIES BOUNDARY
BY BYLAYER BYSURFACE
IF INACTIVE INITIAL
JUMP
OBJ OFF ON
ONLY OR
UNORMAL USE
WINDOW
ZOOM
The following names of built-in functions and identifiers are not recognized by the FlexPDE editor's syntax
highlighter, but may be used only for their assigned purpose:
ABS AINTEGRAL ARCCOS
ARCSIN ARCTAN AREA_INTEGRAL
ATAN2 ATAN2V6
FEATURE_INDUCTION FIT
JACOBIAN
LINE_INTEGRAL LN LOG10
LUMP
NORMAL
PARTS PASSIVE PI
P roblem Descriptor Reference : The Elements of a Descriptor 158
VINTEGRAL VOL_INTEGRAL
3.2.3 Separators
White Space
Spaces, tabs, and new lines, frequently referred to as "white space", are treated as separators and may
be used freely in problem descriptors to increase readability. Multiple white spaces are treated by
FlexPDE as a single white space.
Commas
Commas are used to separate items in a list, and should be used only where explicitly required by the
descriptor syntax.
Semicolons
Semicolons are not significant in the FlexPDE grammar. They are treated as equivalent to commas.
The label that results from a literal string is reproduced on the output exactly (including case) as entered
in the corresponding literal string.
Literal strings are formed by enclosing the desired label in either single or double quote marks . Literal
strings that begin with a double quote mark must end in a double quote mark, and literal strings that begin
159 FlexP DE 7 : P roblem Descriptor Reference
A literal string may consist of any combination of alphanumeric characters, separators, reserved words,
and/or symbols including quote marks, provided only that strings that begin with a double quote mark
may contain only single quote marks and strings that begin with a single quote mark may contain only
double quote marks.
Example:
TITLE "This is a literal 'string' used as a problem title"
Decimal Numbers
Decimal numbers must be of the form XXXXX.XXX where X is any decimal digit from 0 to 9 and '.' is the
decimal separator. Decimal numbers must not include commas ','. Using the European convention of a
comma ',' as a decimal separator will result in an error. Commas are reserved as item separators.
Decimal numbers may include zero to nine digits to the left of the decimal separator and up to a total of
308 digits total. FlexPDE considers only the first fifteen digits as significant.
Function Comments
ABS(x) Absolute value
ARCCOS(x) Inverse cosine (returns radians)
ARCSIN(x) Inverse sine (returns radians)
ARCTAN(x) Inverse tangent (returns radians)
ATAN2(y,x) Arctan(y/x) with numerically safe implementation*
ATAN2V6(y,x) Arctan(y/x) with numerically safe implementation*
BESSI(order,x) Modified Bessel function I for real x
BESSJ(order,x) Bessel Function J
BESSK(order,x) Modified Bessel function K for real x
BESSY(order,x) Bessel Function Y
COS(x) cosine of x (angle in radians)**
COSH(x) Hyperbolic cosine
ERF(x) Error Function
ERFC(x) Complementary Error Function
EXP(x) Exponential function
EXPINT(x) Exponential Integral Ei(x) for real x>0 ***
EXPINT(n,x) Exponential Integral En(x) for n>=0, real x>0 ***
GAMMAF(x) Gamma function for real x>0
GAMMAF(a,x) Incomplete gamma function for real a>0, x>0
LOG10(x) Base-10 logarithm
LN(x) Natural logarithm
SIN(x) sine of x (angle in radians)**
SINH(x) Hyperbolic sine
SQRT(x) Square Root
TAN(x) tangent of x (angle in radians)**
TANH(x) Hyperbolic tangent
* Note that in version 7 the definition has changed to use the standard range of -π to π.
ATAN2V6 is provided for compatibility with old behavior.
** Use for example COS(x DEGREES) to convert arguments to radians.
*** as defined in Abramowitz & Stegun, "Handbook of Mathematical Functions".
Examples:
Samples | Usage | Functions | Standard_Functions.pde 554
161 FlexP DE 7 : P roblem Descriptor Reference
MAX(arg1,arg2)
The maximum function requires two arguments. MAX is evaluated on a point by point basis and is
equal to the larger of the two arguments at each point.
MIN(arg1,arg2)
The minimum function requires two arguments. MIN is evaluated on a point by point basis and is equal
to the lessor of the two arguments at each point.
MOD(arg1,arg2)
The modulo function requires two arguments. MOD is evaluated on a point by point basis and is equal
to the remainder of (arg1/arg2) at each point. This is a direct implementation of the C function
fmod(arg1,arg2) : "Computes the floating-point remainder of the division operation arg1/arg2. The
floating-point remainder of the division operation arg1/arg2 calculated by this function is exactly the
value arg1 - n*arg2, where n is arg1/arg2 with its fractional part truncated. The returned value has the
same sign as arg1 and is less or equal to arg2 in magnitude."
GLOBALMAX(arg)
GLOBALMAX(arg, region_name)
GLOBALMAX(arg, region_name, layer_name)
With one argument GLOBALMAX is equal to the largest value of the argument over the problem
domain. The search can be restricted to a specific region and layer using the second two arguments.
GLOBALMAX is tabulated, and is re-evaluated only when components of the argument change.
GLOBALMAX_X(arg)
GLOBALMAX_Y(arg)
GLOBALMAX_Z(arg)
Returns the specified coordinate of the associated GLOBALMAX. Global searches are tabulated by
argument expression, and repeated calls to GLOBALMAX and its related coordinates do not cause
repeated evaluation.
GLOBALMIN(arg)
GLOBALMIN(arg, region_name)
GLOBALMIN(arg, region_name, layer_name)
With one argument GLOBALMIN is equal to the smallest value of the argument over the problem
domain. The search can be restricted to a specific region and layer using the second two arguments.
GLOBALMIN is tabulated, and is re-evaluated only when components of the argument change.
GLOBALMIN_X(arg)
GLOBALMIN_Y(arg)
GLOBALMIN_Z(arg)
Returns the specified coordinate of the associated GLOBALMIN. Global searches are tabulated by
P roblem Descriptor Reference : The Elements of a Descriptor 162
argument expression, and repeated calls to GLOBALMIN and its related coordinates do not cause
repeated evaluation.
RANDOM(arg)
The random function requires one argument. The result is a pseudo-random number uniformly
distributed in (0,arg). The only reasonable application of the RANDOM function is in initial values.
Use in other contexts will probably result in convergence failure.
ROUND(arg)
The round function requires one argument. The result is an integer following standard rounding
behavior : e.g. 1.49 rounds down to 1, 1.5 rounds up to 2.
SPACE_ERROR()
SPACE_ERROR(variable)
The space error function returns the average spatial error over all variables. If a variable name is
given, it returns the spatial error for the named variable only. The return is a field value.
TIME_ERROR()
TIME_ERROR(variable)
The time error function returns the average time error over all variables. If a variable name is given, it
returns the time error for the named variable only. The return is a scalar value.
SIGN(arg)
The sign function requires one argument. SIGN is equal to 1 if the argument is positive and -1 if the
argument is negative.
TIMEMAX(arg)
The time maximum function requires one argument. TIMEMAX is equal to the largest value of the
argument over the time span of the problem. TIMEMAX is tabulated, and is re-evaluated only when
components of the argument change.
TIMEMAX_T(arg)
Returns the time at which the associated TIMEMAX of the argument occurs. Time searches are
tabulated by argument expression, and repeated calls to TIMEMAX and its related times do not cause
repeated evaluation.
TIMEMIN(arg)
The time minimum function requires one argument. TIMEMIN is equal to the smallest value of the
argument over the time span of the problem. TIMEMIN is tabulated, and is re-evaluated only when
components of the argument change.
TIMEMIN_T(arg)
Returns the time at which the associated TIMEMIN of the argument occurs. Time searches are
163 FlexP DE 7 : P roblem Descriptor Reference
tabulated by argument expression, and repeated calls to TIMEMIN and its related times do not cause
repeated evaluation.
USTEP(arg)
The unit step function requires one argument. USTEP is 1 where the argument is positive and 0 where
the argument is negative. For example, USTEP(x-x0) is a step function at x=x0.
UPULSE(arg1,arg2)
The unit pulse function requires two arguments. UPULSE is 1 where arg1 is positive and arg2 is
negative and 0 everywhere else. UPULSE(t-t0, t-t1) is a pulse from t0 to t1 if t1>t0. [Note:
because instantaneous switches cause serious trouble in time dependent problems, the UPULSE
function automatically ramps the rise and fall over 1% of the total pulse width.]
URAMP(arg1,arg2)
The unit ramp function requires two arguments. URAMP is like UPULSE, except it builds a ramp
instead of a rectangle. URAMP is 1 where arg1 and arg2 are both positive, linearly interpolated
between 0 and 1 when arg1 is positive and arg2 is negative, and 0 everywhere else.
Examples:
Samples | Usage | Unit_Functions.pde 557
This function returns a text string representing the integer value of number. number may be a literal
value, a name or a parenthesized expression. If number has integral value, the string will have
integer format. Otherwise, the string will be formatted as a real number with a default length of 6
characters.
$[width]number
This form acts as the form above, except that the string size will be width.
These functions may be used in conjunction with the concatenation operator "+" 176 to build boundary or
P roblem Descriptor Reference : The Elements of a Descriptor 164
REPEAT i=1 to 4
START "LOOP"+$i (x,y)
{ path_info ... }
ENDREPEAT
This is equivalent to
Example:
See "Samples | Usage | Misc | Repeat.pde" 594
3.2.6.5 T he FIT Function
The following two forms may be used to compute a finite-element interpolation of an arbitrary argument:
result = FIT(expression)
computes a Finite Element fit of the given expression using the current computational mesh and basis.
Nodal values are computed to return the correct integral over each mesh cell.
as with FIT(expression), but with a smoothing diffusion with coefficient equal to weight (try 0.1 or
1.0, and modify to suit).
weight may be an arbitrary expression, involving spatial coordinates, time, or variables of the
computation. In this way it can be used to selectively smooth portions of the mesh. The value of
weight has a well-defined meaning: it is the spatial wavelength over which variations are damped:
spatial variations with wavelength much smaller than weight will be smoothed, while spatial variations
with wavelength much greater than weight will be relatively unmodified.
Note: FIT() builds a continuous representation of the data across the entire domain, and
connot preserve discontinuities in the fitted data. In some cases, multiplying the data by an
appropriate material parameter can result in a continuous function appropriate for fitting. An
exception to this rule is in the case of CONTACT boundaries, where the mesh nodes are
duplicated, and discontinuities can be preserved in FIT functions.
FIT() may be used to smooth noisy data, to block ill-behaved functions from differentiation in the
derivative computation for Newton's method, or to avoid expensive re-computation of complex
165 FlexP DE 7 : P roblem Descriptor Reference
functions.
See also the SAVE 166 function, in which nodal values are directly computed.
Example:
Samples | Usage | fit+weight.pde 591
The LUMP function creates a field on the finite element mesh, and saves a single value of the argument
expression in each cell of the finite element mesh. The value stored for each cell is the average value of
the argument expression over the cell, and is treated as a constant over the cell.
The LUMP function may be used to block ill-behaved functions from differentiation in the derivative
computation for Newton's method, or to avoid expensive re-computation of complex functions.
The normal use for LUMP is in the DEFINITIONS section, as in
name = LUMP ( expression )
Note: This definition of LUMP(F) is NOT the same as the "lumped parameters" frequently
referred to in finite element literature.
Example:
Samples | Usage | Lump.pde 592
The RAMP function is a modification of the URAMP 163 function, intended to make the usage more
nearly like an IF..THEN 180 statement.
It has been introduced to provide an alternative to discontinuous functions like USTEP 163 and the
discontinuous IF..THEN 180 construct.
Discontinuous switching can cause serious difficulties, especially in time dependent problems, and is
strongly discouraged. FlexPDE is an adaptive system. Its procedures are based on the assumption that
by making timesteps and/or cell sizes smaller, a scale can be found at which the behavior of the solution
is representable by polynomials. Discontinuities do not satisfy this assumption. A discontinuity is a
discontinuity, no matter how close you look. Instantaneous turn-on or turn-off introduces high-frequency
spatial or temporal components into the solution, including those which are far beyond the physical limits
of real systems to respond. This makes the computation slow and possibly physically meaningless.
The RAMP function generates a smooth transition from one value to another, with the transition taking
place as "expression" changes by and amount "width". It can be thought of as a "fuzzy IF", and has a
usage very similar to an IF.. THEN, but without the harsh switching characteristics.
P roblem Descriptor Reference : The Elements of a Descriptor 166
except that the transition will be linear over width. If the left and right values are functions, then you may
not get a straight line as the ramp. The result will be a linear combination of the two functions.
See the SWAGE 167 function for a similar function with both smooth value and derivative.
Example:
see "Samples | Usage | Swage_test.pde" 557 for a picture of the SWAGE and RAMP transitions and
their derivatives.
The SAVE function creates a field on the finite element mesh, and saves the values of the argument
expression at the nodal points for subsequent interpolation. SAVE builds a continuous representation of
the data within each material region, and can preserve discontinuities in the saved data.
The SAVE function may be used to block ill-behaved functions from differentiation in the derivative
computation for Newton's method, or to avoid expensive re-computation of complex functions.
The normal use for SAVE is in the DEFINITIONS section, as in
name = SAVE ( expression )
Note: SAVE() builds a continuous representation of the data across the entire domain, and
cannot preserve discontinuities in the fitted data. In some cases, multiplying the data by an
appropriate material parameter can result in a continuous function appropriate for saving. An
exception to this rule is in the case of CONTACT boundaries, where the mesh nodes are
duplicated, and discontinuities can be preserved in SAVE functions.
Example:
"Samples | Usage | Save.pde" 596
See the FIT() 164 function for a similar function with integral conservation and variable smoothing
capabilities.
167 FlexP DE 7 : P roblem Descriptor Reference
The SUM function produces the sum of repetitive terms. The form is:
The expression argument is evaluated and summed for name = initial, initial+1, initial+2,...final.
source = SUM(i,1,10,exp(-i))
DEFINITIONS
A = ARRAY(1,2,3,4,5,6,7,8,9,10)
source = SUM(i,1,10,A[i])
Example:
Samples | Usage | Sum.pde 555
The SWAGE function has been introduced to provide an alternative to discontinuous functions like
USTEP 163 and the discontinuous IF..THEN 180 construct. Discontinuous switching can cause serious
difficulties, especially in time dependent problems, and is strongly discouraged.
FlexPDE is an adaptive system. Its procedures are based on the assumption that by making timesteps
and/or cell sizes smaller, a scale can be found at which the behavior of the solution is representable by
polynomials. Discontinuities do not satisfy this assumption. A discontinuity is a discontinuity, no matter
how close you look. Instantaneous turn-on or turn-off introduces high frequency spatial or temporal
components into the solution, including those which are far beyond the physical limits of real systems to
respond. This makes the computation slow and possibly physically meaningless.
The SWAGE function generates a smooth transition from one value to another. The slope at the center of
the transition is the same as a RAMP 165 of the given width, but the curve extends to five times the given
width on each side, reaching the end values exactly. It also has smooth derivatives, except for a one
percent jump at the cutoff points. It can be thought of as a "fuzzy IF", and has a usage very similar to an
IF.. THEN, but without the harsh switching characteristics.
See the RAMP 165 function for a similar function which is smooth in value, but not in derivative.
Example:
see "Samples | Usage | Swage_test.pde" 557 for a picture of the SWAGE and RAMP transitions and
their derivatives.
-------------------------------------------------------------------------------------------------------
Wiktionary:
swage 1.(noun) A tool, variously shaped or grooved on the end or face, used by blacksmiths and other workers in
metals, for shaping their work. 2.(verb)To bend or shape using a swage.
There are two ways to evaluate an arbitrary expression at selected coordinates, VAL and EVAL.
value = VAL(expression, x, y )
value = VAL(expression, x, y, z )
The value of expression is computed at the specified coordinates. The coordinates must be constants.
The value is computed and stored at each phase of the solution process, allowing efficient reference in
many computations.
FlexPDE maintains a "scoreboard" of dependencies and re-evaluates the expression whenever the
dependency changes. If the expression depends on a variable, it will also create an implicit coupling
between the expression and its point of use, causing the value to be solved simultaneously during the
solution phase.
Expression can include derivative terms, but the VAL itself cannot be differentiated.
value = EVAL(expression, x, y )
value = EVAL(expression, x, y, z )
The value of expression is computed at the specified coordinates. The coordinates may be dynamically
variable. The value is recomputed at each reference, possibly leading to increased run time.
This form does NOT allow FlexPDE to compute implicit couplings between computation nodes
referencing and evaluating the value.
Derivative operators applied to EVAL will be passed through and applied to expression.
169 FlexP DE 7 : P roblem Descriptor Reference
The functions XBOUNDARY , YBOUNDARY and ZBOUNDARY allow the user to search for the position of a
system boundary from an evaluation point:
XBOUNDARY("boundary name")
YBOUNDARY("boundary name")
ZBOUNDARY("surface name")
ZBOUNDARY(surface_number)
In each case, the function returns the X,Y or Z coordinate of the named boundary at the (Y,Z), (X,Z) or
(X,Y) coordinates of the current evaluation.
3.2.7 Operators
3.2.7.1 Arithm etic Operators
Operator Action
- Unary negate, Forms the negative of a single operand
+ Binary add, Forms the sum of two operands
- Binary subtract, Forms the difference of two operands
* Binary multiply, Forms the product of two operands
/ Binary divide, Divides the first operand by the second
^ Binary power, Raises the first operand to the power of the second
These operators can be applied to scalars, arrays or matrices. When used with arrays or
matrices, the operations are applied element-by-element.
Special operators are defined to designate conventional matrix and array operations.
Operator Action
** Binary MATRIX multiply. Forms the product of two matrices or the product
of a MATRIX and an ARRAY. Applied to tensors, the result is the same as
the DOT operator.
// Matrix "division". A1 = A2 // M produces the ARRAY A1 satisfying the
equation A2 = M**A1.
3.2.7.2 Com plex Operators
REAL ( complex )
P roblem Descriptor Reference : The Elements of a Descriptor 170
IMAG ( complex )
CABS ( complex )
CARG ( complex )
Computes the Argument (or angular component) of the complex number, implemented as
CARG(complex(x,y)) = Atan2(y,x).
CEXP ( complex )
CLOG ( complex )
CONJ ( complex )
CSQRT ( complex )
Differential operator names are constructed from the coordinate names for the problem, either as defined
by the user, or as default names.
First derivative operators are of the form "D<name>", where <name> is the name of the coordinate.
Second-derivative operators are of the form "D<name1><name2>".
In the default 2D Cartesian case, the defined operators are "DX", "DY", "DXX", "DXY", and "DYY".
All differential operators are expanded internally into the proper forms for the active coordinate system
of the problem.
D<n> ( arg )
171 FlexP DE 7 : P roblem Descriptor Reference
First order partial derivative of arg with respect to coordinate <n>, eg. DX(arg).
D<n><m> ( arg )
Second order partial derivative of arg with respect to coordinates <n> and <m>, eg. DXY(arg).
DIV ( vector_arg )
Divergence of the vector whose components are argx and argy (and possibly argz in 3D). This is
the same as DIV(vector(argx,argy,argz), and is provided for convenience.
DIV ( tensor_arg )
GRAD ( scalar_arg )
GRAD ( vector_arg )
Gradient of vector argument. This operation produces a tensor result. In curvilinear geometry, this
creates additional terms due to the differentiation of the unit vectors. It is NOT equivalent to the
gradient of the vector components except in Cartesian geometry. FlexPDE handles these expansions
correctly in all supported geometries.
CURL ( vector_arg )
CURL ( scalar_arg )
Curl of a scalar_arg (2D only). Assumes arg to be the magnitude of a vector normal to the
computation plane, and returns a vector result in the computation plane.
Curl of a vector whose components in the computation plane are argx and argy (and possibly argz in
3D). This is the same as CURL(vector(argx,argy,argz)), and is provided for convenience.
DEL2 ( scalar_arg )
DEL2 ( vector_arg )
P roblem Descriptor Reference : The Elements of a Descriptor 172
Integrals may be formed over volumes, surfaces or lines. The specific interpretation of the integral
operators depends on the coordinate system of the current problem. Integral operators can treat only
scalar functions as arguments. You cannot integrate a vector field.
Examples
3.2.7.4.1 T i m e In t egr a l s
The operators TINTEGRAL and TIME_INTEGRAL are synonymous, and perform explicit time integration
of arbitrary scalar values from the problem start time to the current time:
TINTEGRAL ( integrand )
TIME_INTEGRAL ( integrand )
Note: This operator cannot be used to create implicit linkage between variables. Use a
GLOBAL VARIABLE instead.
3.2.7.4.2 Li n e In t egr a l s
The operators BINTEGRAL and LINE_INTEGRAL are synonymous, and perform line integrations of
scalar integrands.
The integral is always taken with respect to distance along the declared line or curve path (positive in the
path direction).
The boundary specification may be omitted, in which case the entire outer boundary is implied.
2D Line Integrals
173 FlexP DE 7 : P roblem Descriptor Reference
In 2D cylindrical geometry, SURF_INTEGRAL will contain the 2*pi*r weighting, while LINE_INTEGRAL
will not.
2D Line integrals may be further qualified by specifying the region in which the evaluation is to be made:
3D Line Integrals
The named_boundary must exist in the named_surface (ie, it must not have been excluded by
LIMITED REGION commands).
3.2.7.4.3 2D Su r fa ce In t egr a l s
Here named_boundary may be specified by name, or it can be omitted, in which case the entire outer
boundary of the domain is implied.
In two-dimensional Cartesian problems, the surface element is formed by extending the two-dimensional
line element a single unit in the Z-direction, so that the surface element is dl*1. In this case, the surface
integral is the same as the line integral.
In two-dimensional cylindrical problems, the surface element is formed as 2*pi*r*dl, so the surface
integral is NOT the same as the line integral.
The region in which the evaluation is made can be controlled by providing a third argument, as in
3.2.7.4.4 3D Su r fa ce In t egr a l s
In three-dimensional problems, there are several forms for the surface integral:
1. Integrals over extrusion surfaces are selected by surface name or number and qualifying region name
or number:
If region is omitted, the integral is taken over all regions of the specified surface.
If both surface and region are omitted, the integral is taken over the entire outer surface of the
domain.
Integrals of this type may be further qualified by selecting the layer in which the evaluation is to be
made:
2. Integrals over "sidewall" surfaces are selected by boundary name and qualifying layer name:
If layer is omitted, the integral is taken over all layers of the specified surface.
Integrals of this type may be further qualified by selecting the region in which the evaluation is to be
made:
3. Integrals over entire bounding surfaces of selected subregions are selected by region name and layer
name, as with volume integrals:
If named_layer is omitted, the integral is taken over all layers of the specified surface.
175 FlexP DE 7 : P roblem Descriptor Reference
3.2.7.4.5 2D V ol u m e In t egr a l s
Here region can be specified by number or name, or it can be omitted, in which case the entire domain is
implied.
In two-dimensional Cartesian problems, the volume element is formed by extending the two-dimensional
cell a single unit in the Z-direction, so that the volume integral is the same as the area integral in the
coordinate plane.
In two-dimensional cylindrical problems, the volume element is formed as 2*pi*r*dr*dz, so that the
volume integral is NOT the same as the area integral in the coordinate plane. For the special case of 2D
cylindrical geometry, the additional operator
computes the area integral of the integrand over the indicated region (or the entire domain) without the
2*pi*r weighting.
3.2.7.4.6 3D V ol u m e In t egr a l s
Here layer can be specified by number or name, or it can be omitted, in which case the entire layer stack
is implied.
region can also be specified by number or name, or it can be omitted, in which case the entire projection
plane is implied.
If region is omitted, then layer must be specified by name or omitted. If both region and layer are
omitted, the entire domain is implied.
For example,
INTEGRAL(integrand, region, layer) means the integral over the subregion contained in the selected
region and layer.
INTEGRAL(integrand, named_layer) means the integral over all regions of the named layer.
INTEGRAL(integrand, region) means the integral over all layers of the selected region.
INTEGRAL(integrand) means the integral over the entire domain.
P roblem Descriptor Reference : The Elements of a Descriptor 176
Relational Operators
Operator Definition
= Equal to
< Less than
> Greater than
<= Less than or equal to
>= Greater than or equal to
<> Not equal to
Relational Combinations
Operator Definition
Assignment Operator
In addition to its use as an equal operator, problem descriptors use the '=' symbol to assign (associate)
values functions and expressions with defined names.
The following operators can be used in expressions that construct string constants:
Operator Action
+ Binary add, Forms the concatenation of two text-string operands
When used in the DEFINITIONS section, The strings to be concatenated must be parenthesized as a
group.
Example:
DEFINITIONS
str1 = "The beginning "
str2 = " the end"
str3 = (str1 + "and" + str2)
The above would produce str3 as "The beginning and the end".
177 FlexP DE 7 : P roblem Descriptor Reference
Vector quantities are assumed to have one component in each of the three coordinate directions implied
by the COORDINATES selection, whether the selected model geometry is one, two or three dimensional.
For example, a Vector can have a Z-component in a two-dimensional X,Y geometry. The restricted
geometry simply means that there is no computable variation of the solution in the missing directions. In
the explicit construction of Vectors, the third component may be omitted, in which case it is assigned a
value of zero.
Forms the cross product of two vectors and returns the resulting vector. In 2D geometries, the
CROSS product of two vectors lying in the computation plane returns a vector with a nonzero
component only in the direction normal to the problem plane. Where appropriate, FlexPDE will
interpret this vector as a scalar, suitable for arithmetic combination with other scalars.
Forms the dot product of two vectors and returns a scalar value equal to the magnitude of the vector
dot product.
MAGNITUDE ( vector )
Returns a scalar equal to the magnitude of a vector whose components are argx and argy (and
possibly argz).
NORMAL ( vector )
NORMAL ( argx, argy {, argz} )*
Returns a scalar equal to the component of a vector argument normal to a boundary. This operator
may be used only in boundary condition definitions or in boundary plots or integrals, where the
reference surface is clear from the context of the statement. (See also UNORMAL below).
TANGENTIAL(vector)
TANGENTIAL ( argx, argy {, argz } )*
Returns a scalar equal to the component of a vector argument tangential to a boundary. This
operator may be used only in boundary condition definitions or in boundary plots or integrals, where
the reference surface is clear from the context of the statement.
P roblem Descriptor Reference : The Elements of a Descriptor 178
Constructs a vector whose components are the scalar arguments. Omitted arguments are assumed
zero.
In a standard cartesian coordinate system, the operators XCOMP, YCOMP, and ZCOMP provide access
to the components of a vector :
XCOMP ( vector )
<coord1>COMP ( vector )
Returns a scalar whose value is the first component of the vector argument.
YCOMP ( vector )
<coord2>COMP ( vector )
Returns a scalar whose value is the second component of the vector argument.
ZCOMP ( vector )
<coord3>COMP ( vector )
Returns a scalar whose value is the third component of the vector argument.
Beginning in version 7, in non-cartesian coordinate systems and cartesian systems where the coordinates
have been renamed (aliased), the coordinate name will be used instead of X, Y , or Z. E.g. in the
CYLINDER1 coordinate system, the first component would be accessed with RCOMP; in a CARTESIAN2
coordinate system with coordinates aliased to "A" and "B", the first and second components would be
accessed using ACOMP and BCOMP.
In an attempt to support backward compatibility, the XCOMP, YCOMP, and ZCOMP operators are
defined as the first, second, and third components whenever possible. If the coordinate system defines X,
Y , or Z, the coordinate defined order takes precedence.
UNORMAL is a built-in function which returns the unit-normal vector at the location of evaluation. It's use
is valid only in expressions computed on a system boundary. UNORMAL takes no arguments, as it's
arguments are implicitly the coordinates at the point of evaluation.
---------------------------------------------------------------------
* Note: arguments in brackets {} are optional.
179 FlexP DE 7 : P roblem Descriptor Reference
FlexPDE supports limited use of TENSOR quantities, to parallel the results of GRAD(vector).
A TENSOR is a vector of vectors, potentially 3 x 3 components.
TENSOR( ( T11, T12, T13) , (T21, T22, T23) , (T31, T32, T33))
This operator returns a TENSOR object with the indicated components. Each of the Tij may be any
scalar expression.
DOT(vector, tensor)
This operator returns a TENSOR representing the matrix product of the tensors. The operator **
can be used to produce the same result (i.e. tensor**tensor).
DIV(tensor)
This operator returns a VECTOR value whose components depend on the metric coefficients of the
selected problem geometry. In Cartesian geometry, the result is a VECTOR made up of the
divergences of the tensor columns.
TRANSPOSE(tensor)
This operator returns a TENSOR which is the transpose of the argument tensor.
vector * vector
These operators returns a scalar whose value is the indicated component of the tensor argument ( X
indicates the first coordinate component, Y the second and Z the third, regardless of the actual
assigned names of the coordinates).
P roblem Descriptor Reference : The Elements of a Descriptor 180
PI 3.14159265358979
For Cartesian coordinates in which 'R' is not specified as a coordinate name or a defined name, the
problem descriptor language predefines the following elements:
Note: If "R" or "Theta" appear on the left side of a definition before any use in an expression,
then the new definition will become the meaning of the name, and the predefined meaning will
be hidden.
In all problems,
CELL_SIZE an internally declared value representing the size of the current evaluation
cell.
In staged problems where " STAGES = integer" is declared in the SELECT section,
In modal analysis (eigenvalue and eigenfunction) problems where "MODES = integer" is declared in
the SELECT section,
DELTAT an internally declared name which returns the size of the current timestep.
3.2.9 Expressions
Value Expressions
Problem descriptors are composed predominantly of arithmetic expressions made of one or more
operators, variables, defined values and pairs of parentheses that evaluate to numerical values. In
evaluating value expressions, FlexPDE follows the algebraic rules of precedence in which unary
operators are evaluated first, followed by binary operators in the following order:
181 FlexP DE 7 : P roblem Descriptor Reference
power
multiplication and division
addition and subtraction
relational operators (<, <=, =, <>, >=, >)
relational combinations (AND, OR)
When included in expressions, subexpressions enclosed in pairs of parentheses are evaluated first,
without regard to the precedence of any operators which precede or follow them. Parentheses may be
nested to any level, with inner subexpressions being evaluated first and proceeding outward.
Parentheses must always be used in pairs.
Examples:
a = b*(c+d)
div(k*grad(u))
Conditional-Value Expressions
Problem descriptors can contain conditional expressions of the form
This form selects one of the two alternative values as the value of the expression. It is used in
expressions like
y = IF a THEN b ELSE c
analogous to the expression "y = a ? b : c" in the C programming language.
The THEN or ELSE subexpressions my contain nested IF...THEN...ELSE expressions. Each ELSE will
bind to the nearest previous IF .
Conditional expressions used in material parameters can cause numerical trouble in the solution of a PDE
system, because they imply an instantaneous change in the result value. This instantaneous change
violates assumptions of continuity upon which the solver algorithms are based.
See URAMP 163 , RAMP 165 and SWAGE 167 for switching functions that transition smoothly between
alternative values.
These statements specify that the following lines of descriptor text should be repeated a number of times.
The given name is defined as if it had appeared in the DEFINITIONS section, and is given the value
specified by initial.
The repeated section of text is terminated by the statement
ENDREPEAT
At this point, the value of name is incremented by delta (or by one, if no delta is given). If the new value is
not greater than final, the repeated text is scanned again with the new value in place of name. If delta is
negative, the value of name is decremented and the termination test is modified accordingly.
Use of ARRAYS and the $integer string function can extend the power of the REPEAT loop.
Examples:
REPEAT xc=1/4 by 1/4 to 7/4
REPEAT yc=1/4 by 1/4 to 7/4
START (xc+rad,yc) ARC( CENTER=xc,yc) ANGLE=360 CLOSE
ENDREPEAT
ENDREPEAT
This double loop constructs a 7 x 7 array of circles, all part of the same REGION.
Note: REPEAT..ENDREPEAT replaces the older FOR..ENDFOR facility used in earlier versions of
FlexPDE. The older facility is no longer supported, and will produce parsing errors.
183 FlexP DE 7 : P roblem Descriptor Reference
When a TITLE is used, the literal string it contains is used as a title label for all MONITORS and PLOTS.
If TITLE is not specified, the plots will not have a title label.
Example:
TITLE "this is my first model"
3.3.2 Select
The SELECT section, which is optional, is used when it is necessary to override some of the default
selectors internal to the program.
Selectors are used to control the flow of the process used to solve a problem.
The SELECT section may contain one or more selectors and their associated values. The default
selectors have been chosen to optimize how FlexPDE handles the widest range of problems.
The SELECT section should be used only when the default behavior of FlexPDE is somehow inadequate.
Unlike the other elements used in program descriptors, the proper names used for the selectors are not
part of the standard language, are not reserved words, and are not meaningful in other descriptor
sections.
The selectors implemented in FlexPDE are specific to a version of FlexPDE, and may not correspond to
those available in previous versions of FlexPDE or in other applications using the FlexPDE descriptor
language.
The following controls can be used in the SELECT section to modify the behavior of the mesh generator.
Logical selectors can be turned on by selector = ON, or merely mentioning the selector
Logical selectors can be turned off by selector = OFF .
Numeric selectors are set by selector = number.
Some selectors can be STAGED 207 .
Note: See the "Mesh Control Parameters 214 " section in this manual and the "Controlling
Mesh Density 134 " section in the User Guide for more discussion of mesh control.
P roblem Descriptor Reference : The Sections of a Descriptor 186
The following controls can be used in the SELECT section to modify the solution methods of FlexPDE.
Logical selectors can be turned on by selector = ON, or merely mentioning the selector.
Logical selectors can be turned off by selector = OFF .
Numeric selectors are set by selector = number.
seconds before proceeding to the next stage. This allows for casual examination of the results at each
stage without needing to click the continue button. In BATCH 271 scripts, this selector causes each
problem to pause before running the next problem.
Sets the internal limit to the size of the matrix that FlexPDE will allow when using the DIRECT 186 matrix
solver.
Selects the nonsymmetric Lanczos conjugate gradient solver, even if the automatic detection process
does not require it.
Specifies the seed for random number generation. May be used to create repeatable solution of
problems using random numbers.
The following controls can be used in the SELECT section to modify the behavior of the graphics
subsystem.
Logical selectors can be turned on by selector = ON, or merely mentioning the selector.
Logical selectors can be turned off by selector = OFF .
Numeric selectors are set by selector = number.
In the usual case, these selectors can be over-ridden by specific controls in individual plot commands
(see Graphic Display Modifiers 248 ).
3.3.3 Coordinates
The optional COORDINATES section defines the coordinate geometry of the problem.
Each geometry selection has an implied three-dimensional coordinate structure. In 2D and 1D
geometries, the solution if the PDE system is assumed to have no variation in one or two of the
coordinate directions. The finite element mesh is therefore constructed in the remaining space, and
P roblem Descriptor Reference : The Sections of a Descriptor 194
Renaming Coordinates
A second form of the COORDINATES section allows renaming (aliasing) of the coordinates:
COORDINATES geometry ( 'Xname' [,'Yname' [,'Zname'] ])
In this case, the 'Xname' argument renames the coordinate lying along the horizontal plot axis,
and 'Yname' renames the coordinate lying along the vertical plot axis. 'Zname' renames the
extrusion coordinate. Names may be quoted strings or unquoted names. Renaming
coordinates does not change the fundamental nature of the coordinate system. In cylindrical
geometries, for example, the radial coordinate will continue to be the radial coordinate, even if
you name it "Z".
In time-dependent problems, the time coordinate may be renamed using TIME ('Tname') in the
COORDINATES section :
Differential Operators
Renaming coordinates causes a redefinition of the differential operators. DX becomes D<Xname>, etc.
The DIV, GRAD, and CURL operators are expanded correctly for the designated geometry. Use of these
operators in the EQUATIONS section can considerably simplify problem specification.
Other Geometries
Since FlexPDE accepts arbitrary mathematical forms for equations, it is always possible to construct
equations appropriate to an arbitrary geometry.
For example, using the CARTESIAN2 coordinate system and renaming coordinates, one can write the
heat equation for cylindrical geometry as
COORDINATES cartesian2("R","Z")
VARIABLES u
...
EQUATIONS
u: dr(k*r*dr(u)) + r*dz(k*dz(u)) + r*source = 0
This equation derives from expanding the DIV and GRAD operators in cylindrical coordinates and
multiplying by the volume weighting factor "r", and is the same as the equation that FlexPDE itself will
construct in XCYLINDER geometry.
Coordinate Transformations
The function definition facility of FlexPDE can be used to simplify the transformation of arbitrary
coordinates to Cartesian (X,Y,Z) coordinates.
The example problem "Samples | Usage | polar_coordinates.pde" 594 uses this facility to pose equations
in polar coordinates:
DEFINITIONS
dr(f) = (x/r)*dx(f) + (y/r)*dy(f) { functional definition of polar derivatives... }
dphi(f) = (-y)*dx(f) + x*dy(f) {... in cartesian coordinates }
Graphic output using this procedure is always mapped to the fundamental Cartesian coordinate system.
3.3.4 Variables
The VARIABLES section is used to define and assign names to all the primary dependent variables used in
a problem descriptor. The form of this section is
P roblem Descriptor Reference : The Sections of a Descriptor 196
All names appearing in the VARIABLES section will be represented by a finite element approximation
over the problem mesh. Each variable is assumed to define a continuous field over the problem domain.
It is further assumed that each variable will be accompanied by a partial differential equation listed in the
EQUATIONS section.
Each variable_name may be followed by various qualifiers, which will be described in subsequent
sections. These qualifiers allow you to control mesh motion, declare complex and vector variables,
declare arrays of variables, and control some of the ways FlexPDE treats the variable.
In assigning names to the dependent variables, the following rules apply:
Variable names must begin with an alphabetic character. They may not begin with a number or
symbol.
Variable names may be a single character other than the single character "t", which is reserved for the
time variable.
Variable names may be of any length and any combination of characters, numbers and/or symbols
other than reserved words.
Variable names may not contain any separators. Compound names can be formed with the '_' symbol
(e.g. temperature_celsius).
Variable names may not contain the character '-' which is reserved for the minus sign.
Example:
VARIABLES
U,V
The THRESHOLD value determines the minimum range of values of the variable for which FlexPDE must
try to maintain the requested ERRLIM accuracy. In other words, THRESHOLD defines the level of
variation at which the user begins to lose interest in the details of the solution.
Error estimates are scaled to the greater of the THRESHOLD value or the observed range of the variable,
so the THRESHOLD value becomes meaningless once the observed variation of a variable in the problem
domain exceeds the stated THRESHOLD. If you make the THRESHOLD too large, the accuracy of the
solution will be degraded. If you make it too small, you will waste a lot of time computing precision you
don't need. So if you provide a THRESHOLD, make it a modest fraction of the expected range (max
minus min) of the variable.
variable_name ( number )
Note: In most cases, the use of THRESHOLD is meaningful only in time-dependent or nonlinear
steady-state problems with uniform initial values, or that ultimately reach a solution of
uniform value.
The ORDER value determines the interpolation order 188 for a given variable. It may be used in
conjunction with THRESHOLD.
You may declare that a VARIABLE name represents a complex quantity. The format of a complex
declaration is:
variable_name = COMPLEX ( real_name , imaginary_name )
This declaration tells FlexPDE that variable_name represents a complex quantity, and assigns the
real_name and imaginary_name to the real and imaginary parts of variable_name. You may
subsequently assign EQUATIONS and boundary conditions either to the variable_name, or to its
components individually. Similarly, you can perform arithmetic operations or request graphical output of
either the variable_name itself, or its components individually.
Example:
VARIABLES
U,V
C = COMPLEX(Cr,Ci)
FlexPDE can be configured to move the finite element mesh in time-dependent problems.
In order to do this, you must assign a VARIABLE as a surrogate for each coordinate you wish to modify.
This specification uses the form
This declaration assigns variable_name as a surrogate variable for the coordinate_name. You may
subsequently assign EQUATIONS and boundary conditions to the surrogate variable in the normal way,
P roblem Descriptor Reference : The Sections of a Descriptor 198
and these equations and boundary conditions will be imposed on the values of the selected mesh
coordinate at the computation nodes.
Example:
VARIABLES
U,V
Xm = MOVE(X)
See Moving Meshes 221 later in this document and the Moving Meshes chapter in the User Guide 130 .
3.3.4.5 Variable Array s
You may declare that a VARIABLE name represents an array of variables. The format of a variable array
declaration is:
variable_name = ARRAY [ number ]
This declaration tells FlexPDE that variable_name represents an array of variable quantities, each one
a scalar field on the problem domain. FlexPDE creates internal names for the elements of the array by
subscripting variable_name with "_" and the element number (e.g. U_7). You can access the
components either by this internal name or by an indexed reference variable_name[index].
You may subsequently assign EQUATIONS and boundary conditions either to the individual
components, or in a REPEAT loop by indexed reference. Similarly, you can perform arithmetic
operations or request graphical output of either the indexed array name, or by the individual component
names.
Example:
VARIABLES
A = ARRAY[10] { declares ten variables A_1 through A_10 }
{ also accessible as A[1] through A[10] }
You may declare that a VARIABLE name represents a vector quantity. The format of a vector
declaration is:
variable_name = VECTOR ( component1 )
variable_name = VECTOR ( component1 , component2 )
variable_name = VECTOR ( component1 , component2 ,component3 )
This declaration tells FlexPDE that variable_name represents a vector quantity, and assigns the
component names to the geometric components of variable_name. You may subsequently assign
EQUATIONS and boundary conditions either to the variable_name, or to its components individually.
Similarly, you can perform arithmetic operations or request graphical output of either the
variable_name itself, or its components individually.
199 FlexP DE 7 : P roblem Descriptor Reference
The three component names correspond to the coordinate directions as implied in the COORDINATES
section of the problem descriptor. You can declare any or all of the three component directions, even if
the model domain treats only one or two.
Any of the component names can be replace by "0" to indicate that this component of the vector is not
to be modeled by FlexPDE, but is to be assumed zero. Similarly, omitted names cause the
corresponding vector components to be assumed zero.
Example:
In XCYLINDER geometry, which has coordinates (Z,R,Phi), you can tell FlexPDE to model only the
Phi component of a vector quantity as follows:
VARIABLES
A = Vector(0,0,Aphi)
Each GLOBAL VARIABLE takes on a single value over the entire domain, as opposed to the nodal finite
element field representing a VARIABLE.
GLOBAL VARIABLES differ from simple DEFINITIONS in that DEFINITIONS are algebraically substituted
in place of their references, while GLOBAL VARIABLES represent stored values which are assigned a row
and column in the master coupling matrix and are solved simultaneously with the finite element equations.
The GLOBAL VARIABLES section must follow immediately after the VARIABLES section.
Rules for declaring GLOBAL VARIABLES are the same as for VARIABLES, and a GLOBAL VARIABLE may
have a THRESHOLD, and may be declared to be COMPLEX, VECTOR or ARRAY , as with VARIABLES.
Each GLOBAL VARIABLE will be associated with an entry in the EQUATIONS section, with rules identical
to those for VARIABLES.
GLOBAL VARIABLES do not have boundary conditions. They may be either steady-state or time-
dependent, and may be defined in terms of integrals over the domain, or by point values of other
functions.
Examples:
Samples | Applications | Control | Control_Steady.pde 367
P roblem Descriptor Reference : The Sections of a Descriptor 200
3.3.6 Definitions
The DEFINTIONS section is used to declare and assign names to special numerical constants,
coefficients, and functions used in a problem descriptor.
Must begin with an alphabetic character. May not begin with a number or symbol.
May be a single character other than the single character t , which is reserved for the time
variable.
May be of any length and any combination of characters, numbers, and symbols other
than reserved words, coordinate names or variable names.
May not contain any separators. Compound names can be formed with the '_' symbol
(e.g. temperature_celsius).
May not contain the '-' which is reserved for the minus sign.
Normally, when a definition is declared it is assigned a value by following it with the assignment operator
'=' and either a value or an expression. Definitions are dynamic elements and when a value is assigned, it
will be the initial value only and will be updated, if necessary, by the problem solution.
Example:
Viscosity = 3.02e-4*exp(-5*Temp)
Definitions are expanded inline in the partial differential equations of the EQUATIONS section. They are
not represented by a finite element approximation over the mesh, but are calculated as needed at various
times and locations.
Names defined in the DEFINITIONS section may be given overriding definitions in some or all of the
REGIONS of the BOUNDARIES section. In this case, the quantity may take on different region-specific
201 FlexP DE 7 : P roblem Descriptor Reference
values. Quantities which are completely specified in subsequent REGIONS may be stated in the
DEFINITIONS section without a value.
Note: See the User Guide section "Setting Material Properties by Region" 96 for examples of
redefined regional parameters.
Normally, DEFINITIONS are stored as the defining formulas, and are recomputed as needed. In rare
cases (as with RANDOM elements), this is inappropriate. The qualifier CONST() can be used to force the
storage of numeric values instead of defining formulas. Values will be computed when the script is
parsed, and will not be recomputed.
name = CONST (expression )
Note: Scripts with staged geometry 207 will reparse the script file and regenerate any CONST values.
Names may be defined as representing arrays or lists of values. ARRAY definition can take several forms:
Examples:
u = array[11]
v = array(0,1,2,3,4,5,6,7,8,9,10)
w = array(0 by 0.1 to 10)
alpha =array for x(0 by 0.1 to 10) : sin(x)+1.
The value of the selected ARRAY element is computed and used as though it were entered literally in the
text.
ARRAY elements that have not been previously assigned may be given values individually by conventional
assignment syntax:
name [ index ] = expression
Example:
beta = sin(w)+1.1 { beta is an ARRAY with the same data as alpha }
gamma = sin(v)+0.1 { gamma is an ARRAY with the dimension of v }
The operator SIZEOF may be used to retrieve the allocated size of an ARRAY .
Example:
n = SIZEOF(v) { returns 11, the allocates size of the example array "v" above }
Normally, ARRAYS are stored as the defining formulas for the elements, and are recomputed as needed.
In rare cases (as with RANDOM elements), this is inappropriate. The qualifier CONST can be prepended
to the ARRAY definition to force the storage of numeric values instead of defining formulas. Elements will
be computed when the script is parsed, and will not be recomputed. For example:
name = CONST ARRAY ( value_1 , value_2 ... value_n )
Note: Scripts with staged geometry 207 will reparse the script file and regenerate any CONST 200 values.
Names may be defined as representing matrices or tables of values. MATRIX definition can take several
forms:
Examples:
m1 = matrix((1,2,3),(4,5,6),(7,8,9))
P roblem Descriptor Reference : The Sections of a Descriptor 204
The value of the selected MATRIX element is computed and used as though it were entered literally in the
text.
MATRIX elements that have not been previously assigned may be given values individually by
conventional assignment syntax:
name [ row_index , column_index ] = expression
The special operator ** is defined for conventional (matrix x vector) multiplication, in which each
205 FlexP DE 7 : P roblem Descriptor Reference
element of the result vector is the dot product of the corresponding matrix row with the argument
vector.
The special operator // is defined for (vector / matrix) division. This operation is defined as
multiplication of the vector by the inverse of the argument matrix.
Examples:
V2 = M ** V1 { V2 is an ARRAY , each element of which is the dot product of the corresponding
row of M with the ARRAY V1 }
V2 = V1 // M { V2 is an ARRAY that satisfies the equation M**V2 = V1 }
The operator SIZEOF may be used to retrieve the allocated size of a MATRIX.
Example:
n = SIZEOF(v) { returns 11, the allocates size of the example array "v" above }
Normally, MATRICES are stored as the defining formulas for the elements, and are recomputed as
needed. In rare cases (as with RANDOM elements), this is inappropriate. The qualifier CONST can be
prepended to the MATRIX definition to force the storage of numeric values instead of defining formulas.
Elements will be computed when the script is parsed, and will not be recomputed. For example:
name = CONST MATRIX ( ( value_11 , value_12 ... value_1m ) ,
... ( value_n1 , value_n2 ... value_nm) )
You may declare that a DEFINITION name represents a complex quantity. The format of a complex
P roblem Descriptor Reference : The Sections of a Descriptor 206
declaration is:
name = COMPLEX ( real_name , imaginary_name )
This declaration tells FlexPDE that name represents a complex quantity, and assigns the real_name
and imaginary_name to the real and imaginary parts of name. You can perform arithmetic operations
or request graphical output of either the name itself, or its components individually.
Example:
DEFINITIONS
Cr = 5
Ci = 7
C = COMPLEX(Cr,Ci)
Definitions can be made to depend on one to three explicit arguments, much as with a Function definition
in a procedural language. The syntax of the parameterized definition is
name ( argname ) = expression
name ( argname1 , argname2 ) = expression
name ( argname1 , argname2 , argname3 , ...) = expression
The maximum number of arguments is 10, and the construct is only meaningful if expression contains
references to the argnames. Names defined in this way can later be used by supplying actual values for
the arguments. As with other definitions in FlexPDE, these actual parameters may be any valid
expression with coordinate or variable dependences. The argnames used in the definition are local to
the definition and are undefined outside the scope of the defining expression.
Note that it is never necessary to pass known definitions, such as coordinate names, variable names, or
other parameters as arguments to a parameterized definition, because they are always globally known
and are evaluated in the proper context. Use the parameterized definition facility when you want to pass
values that are not globally known.
Note: This construct is implemented by textual expansion of the definitions in place of the
function reference. It is not a run-time call, as in a procedural language.
Example:
DEFINITIONS
sq(arg) = arg*arg
...
EQUATIONS
div(a*grad(u)) + sq(u+1)*dx(u) +4 = 0;
FlexPDE can perform automated parameter studies through use of the STAGE facility. In this mode,
FlexPDE will run the problem a number of times, with differing parameters in each run. Each STAGE begins
with the solution and mesh of the previous STAGE as initial conditions.
HISTORY 258 plots can be used to show the variation of scalar values as the STAGES proceed.
Note: The STAGE facility can only be used on steady-state problems. It cannot be used w ith time
dependent problems.
STAGES = number
specifies that the problem will be run number times. A parameter named STAGE is defined, which takes
on the sequence count of the staged run. Other definitions may use this value to vary parameter values,
as for example:
Voltage = 100*stage
STAGED Definitions
A parameter definition may also take the form:
In this case, the parameter param takes on value_1 in stage 1, value_2 in stage 2, etc.
If STAGED parameters are defined, the STAGES selector is optional. If the STAGES selector is not
defined, the length of the STAGED list will be used as the number of stages. If the STAGES selector is
defined, it overrides the length of the STAGED list. Commas are optional.
STAGED Geometry
If the geometric domain definition contains references to staged quantities, then the solution and mesh will
not be retained, but the mesh will be regenerated for the new geometry. History plots can still be
displayed for staged geometries.
FlexPDE attempts to detect stage dependence in the geometrical domain definition and automatically
regenerate the mesh. If for any reason these dependencies are undetected, the global selector
STAGEGRID can be used to force grid staging.
Note: Scripts with staged geometry will reparse the script file and regenerate any CONST 200 values.
point_name = POINT(a,b)
Here a and b must be computable constants at the time the definition is made. They may not depend on
variables or coordinates. They may depend on stage number.
The name of the point can subsequently appear in any context in which the literal point (a,b) could
appear.
Individual coordinates of a named point can be extracted using vector component operators 177 .
Movable Points
The qualifier MOVABLE can be used with named points that are used in boundary definitions in moving-
mesh problems. These points become locked to the mesh, and will move as the mesh moves.
Such points can be used in "AT " selectors for histories to track values at points that move with the mesh.
Examples:
Samples | Usage | Moving_Mesh | 2D_Movepoint.pde 608
FlexPDE supports the import of tabular data in several script commands. In each case, the model
assumes that a text file contains data defining one or more functions of one, two or three coordinates.
The coordinates may be associated with any quantity known to FlexPDE, such as a spatial coordinate, a
variable, or any defined quantity. At each point of evaluation, whether of a plot or a quadrature
computation of coupling matrix, or any other context, the values of the declared coordinates of the table
are computed and used as lookup parameters to interpolate data from the table.
This feature is useful for modeling systems where experimental data is available and for interfacing with
other software programs.
The names of quantities to be used as table coordinates may be declared inside the table file, or they may
209 FlexP DE 7 : P roblem Descriptor Reference
TABLE data are defined on a rectangular grid, and interpolated with linear, bilinear or trilinear
interpolation. Modifiers can be prepended to table definitions to create spline interpolation or histogram
interpretation, or to smooth the imported data.
Table import files are ASCII text files, and can be generated with any ASCII text editor, by user
programs designed to generate tables, or by FlexPDE itself, using the EXPORT plot modifier or the
TABLE output statement (see MONITORS and PLOTS 245 ).
See TABLE File Format 211 for a definition of the table file format.
See Importing Data from other applications 139 for a discussion of TABLE usage.
3.3.6.7.1 T h e T A BLE In pu t fu n ct i on
Both forms import a data table from the named file and associate the data with the defined name .
In the first form, the coordinates of the table must be named in the file.
In the second form, the coordinates are named explicitly in the command.
In either case, the declared coordinates must be names known to FlexPDE at the time of reading the file.
The format of the TABLE file describes a function of one, two or three coordinates.
The TABLE statement must appear in a parameter definition (in the DEFINITIONS section or as a regional
parameter definition in a REGION clause), and the table data are associated with the given name. Note:
FlexPDE version 6 and later do not allow TABLE to be used directly in arithmetic expressions.
When the parameter name is used in subsequent computations, the current values of the table
coordinates will be used to interpolate the value. For instance, if the table coordinates are the spatial
coordinates X and Y, then during computations or plotting, the named parameter will take on a spatial
distribution corresponding to the table data spread over the problem domain.
In version 7.11 and later, FlexPDE will issue an error diagnostic if table data is accessed outside of the
defined range. This was added as a warning to the user since extrapolated data may not be trustworthy.
This table bounds check can be turned off using the selector CHECK_TABLES 186 .
Examples:
Samples | Usage | Import-Export | Table.pde 572
Samples | Usage | Import-Export | Blocktable.pde 565
Samples | Usage | Import-Export | Smoothtable.pde 571
P roblem Descriptor Reference : The Sections of a Descriptor 210
3.3.6.7.2 T h e T A BLEDEF i n pu t st a t em en t
The TABLEDEF input statement is similar to the TABLE 209 input function, but can be used to directly
define one or several parameters from a multi-valued table file.
The format is
Whereas in the TABLE statement the additional arguments are coordinate reassignments, in the
TABLEDEF statement the additional arguments are the names to be defined and associated with the table
data. The TABLEDEF statement is not able to redefine the names of the table coordinates, and the names
in the table file must be those of values known to FlexPDE at the time of reading the table.
The default interpolation for table data is linear (or bilinear or trilinear) within the table cells. Alternative
treatments of the data can be specified by prefixes attached to the TABLE statement.
Modifier Effect
SPLINE A cubic spline is fit to the table data (one- and two-dimensional tables
only)
BLOCK Data points are assumed to denote the beginning of a histogram level. The
data value at a given point will apply uniformly to the coordinate interval
ending at the next coordinate point. A ramped transition will be applied to
the interpolation, transitioning from one level to the next in 1/10 of the
combined table cell widths.
BLOCK(fraction) Data are interpreted as with BLOCK, but fraction is used as the transition
width factor in place of the default 1/10.
SMOOTH(wavelength A diffusive smoothing is applied to the TABLE data, in such a way that the
) integral of the data is preserved, but sharp transitions are blurred. This can
result in more efficient solution times if the data are used as sources or
parameters in time-dependent problems.
Fourier components with spatial wavelengths less than wavelength will be
damped. (See Technical Note: Smoothing Operators in PDE's 349 ).
211 FlexP DE 7 : P roblem Descriptor Reference
Examples:
Data = SMOOTH(0.1) TABLE("input_file")
Data = SPLINE TABLE("input_file")
Data files for use in TABLE or TABLEDEF input must have the following form:
{ comments }
name_coord1 datacount1
value1_coord1 value2_coord1 value3_coord1 …
name_coord2 datacount2
value1_coord2 value2_coord2 value3_coord1 …
name_coord3 datacount3
value1_coord3 value2_coord3 value3_coord3 …
data { comments }
data111 data211 data311 …
data121 data221 data321 …
data131 data231 data331 …
… … …
… … …
data112 data 212 data312 …
data122 data 222 data322 …
data132 data 232 data 332 …
… … …
… … …
where
name_coordN is the coordinate name in the N direction. Names must match defined names in
the importing script unless table coordinate redefinition is used.
valueN_coordM is the Nth value of the Mth coordinate. These must be in monotonic increasing
order.
… ellipses indicate extended data lists, which may be continued over multiple lines.
Note that in presenting data, coord1 is cycled first, then coord1, then coord3.
Coordinate lists and data lists are free-format, and may be arbitrarily spaced, indented or divided into
lines.
Example:
-0.01 2 4 6 8 10.01
y 6
-0.01 2 4 6 8 10.01
data
1.1 2.1 3.1 4.1 5.1 6.1
1.2 2.2 3.2 4.2 5.2 6.2
1.3 2.3 3.3 4.3 5.3 6.3
1.4 2.4 3.4 4.4 5.4 6.4
1.5 2.5 3.5 4.5 5.5 6.5
1.6 2.6 3.6 4.6 5.6 6.6
The TABULATE statement can be used to generate a TABLE internally from arithmetic expressions. The
result is a TABLE identical to one produced externally and read by the TABLE or TABLEDEF statements.
This facility can be used to tabulate parameters that are very expensive to compute, resulting in an
improvement in the efficiency of the system solution.
The TABULATE statement has a syntax identical to that of ARRAY and MATRIX definition, with the
addition of a possible third table dimension.
name = TABULATE FOR param1 (first1 BY step1 TO final1 ) : expression
These statements define name to be a TABLE of values generated by evaluating expression at all
combinations of the specified parameters. param1, param2 and param3 must be names already defined
in the script, and they become the coordinate values of the table.
As with MATRICES and ARRAYS, table points can be stated explicitly
name = TABULATE FOR param1 ( p11 , p12 { , p13 ...} ) : expression
Interpretation of the resulting table can be modified as with the TABLE statement, by prefixing the
213 FlexP DE 7 : P roblem Descriptor Reference
Examples:
Samples | Usage | Misc | Tabulate.pde 601
FlexPDE supports a TRANSFER facility for exchanging data between FlexPDE problem runs. The
format is unique to FlexPDE, and is not supported by other software products. The file format for
version 7 is different from that of previous versions, but files written by version 6 can also be read by
version 7. See TRANSFER file format 262 and TRANSFER6 file format 266 for descriptions of the file
formats.
A TRANSFER file contains data defined on the same unstructured triangle or tetrahedral mesh as used in
the creating FlexPDE computation, and maintains the full information content of the original computation.
It also contains a description of the problem domain definition of the creating run.
Note: Unlike FlexPDE Version 6, Version 7 TRANSFER import restores the state of HISTORY plots (if
the file was written by Version 7).
The file specified in the transfer input function must have been written by FlexPDE using the TRANSFER
output function. The names listed in the input function will become defined as if they had appeared in a
"name=" definition statement. The names will be positionally correlated with the data fields in the
referenced output file.
With the TRANSFER form, the mesh structure of the imported file is stored independently from the
computation mesh, and is not influenced by refinement or merging of the computation mesh.
The TRANSFERMESH input statement not only imports data definitions stored on disk, but also
IMPOSES THE FINITE ELEMENT MESH STRUCTURE of the imported file onto the current
problem, bypassing the normal mesh generation process. In order for this imposition to work, the
importing descriptor file must have EXACTLY the same domain definition structure as the exporting file.
Be sure to use a copy of the exporting domain definition in your importing descriptor. You may change
the boundary conditions, but not the boundary positions and ordering.
The TRANSFERMESHTIME statement acts precisely as the TRANSFERMESH statement, except that the
problem time is imported from the transfer file as well as the mesh. This statement can be used to
resume a time-dependent problem from the state recorded in the transfer file. In version 7 the
TRANSFERMESHTIME statement is depricated and has been replaced by the RESTART statement.
Restart :
P roblem Descriptor Reference : The Sections of a Descriptor 214
The file specified in the transfer input function must have been written by FlexPDE using the RESTART
output function or the automatic .
Examples:
Definitions may be specified as PASSIVE, in which case they will be blocked from differentiation with
respect to system variables in the formation of the global Jacobian matrix. In strongly nonlinear systems,
this sometimes prevents pathological behavior, at the expense of slower convergence.
Example:
Viscosity = Passive(3.02*exp(-5*Temp))
The derivative of Viscosity with respect to Temp will be forced to zero, instead of the true value (-5)
*3.02*exp(-5*Temp).
FlexPDE uses an adaptive initial mesh generation procedure. Cell sizes are generated to conform with
local boundary feature sizes, and cell sizes will grow gradually from locales of small cell size to locales of
large cell size. Cells sides always match everywhere, and there is never a mismatch between adjacent
cells.
It is possible, however, to override the default cell size logic by use of the controls MESH_SPACING and
MESH_DENSITY. These parameters have special meaning in controlling the initial mesh layout. They
may appear in the context of a parameter definition or redefinition (ie, in the DEFINITIONS section or in
a REGION), or in the context of a boundary condition. There may be more than one control active in any
locale, and the control (default or explicit) resulting in the smallest mesh cells will dominate.
MESH_SPACING dictates the desired spacing between mesh nodes.
MESH_DENSITY is the reciprocal of MESH_SPACING, and dictates the desired number of mesh nodes
215 FlexP DE 7 : P roblem Descriptor Reference
MESH_SPACING and MESH_DENSITY specifications may be any function of spatial coordinates (but not
of VARIABLES).
Examples:
MESH_DENSITY = exp(-(x^2+y^2+z^2)
This will create a Gaussian density distribution around (0,0,0), with spacing ultimately overridden by
the size limit implied by NGRID.
See the User Guide section "Controlling Mesh Density 134 " for more information.
See also
"Samples | Usage | Mesh_Control | Mesh_Density.pde" 584
"Samples | Usage | Mesh_Control | Mesh_Spacing.pde" 584
"Samples | Usage | Mesh_Control | Boundary_Density.pde" 581
"Samples | Usage | Mesh_Control | Boundary_Spacing.pde" 582
3.3.7 Materials
The MATERIALS section is used to create sets of DEFINITIONS that can be applied to a REGION by
the USE MATERIAL statement.
Example:
MATERIALS
"wood" :
a=1
b=2
c=3
"plastic" :
a=10
b=20
c=30
BOUNDARIES
REGION 1
P roblem Descriptor Reference : The Sections of a Descriptor 216
REGION 2
USE MATERIAL "plastic"
... ! a is 10 in this region
Examples:
Samples | Usage | Misc | Material_Sets.pde 593
Example:
BOUNDARY CONDITIONS
"outside" :
VALUE(u)=1
NATURAL(v)=0
"inside" :
NATURAL(u)=100
VALUE(v)=10
BOUNDARIES
REGION 1
START(...)
USE BC "outside"
... ! value of u is 1 on this path
REGION 2
START(...)
USE BC "inside"
... ! natural of u is 100 on this path
Examples:
Samples | Usage | Misc | BC_Sets.pde 587
When not specifically initialized, the dependent variables are initialized to zero.
For time dependent problems, the INITIAL VALUES section should include a value assignment statement
for each dependent variable.
Initial value statements are formed by following the dependent variable name with the assignment
operator '=' and either a constant, function, expression or previously defined definition.
Example:
INITIAL VALUES
U = 1.0-x
For syntactic reasons, initial values cannot be set directly from TABLE 208 or TRANSFER 213 .
An intermediate name must be defined by the TABLE or TRANSFER command, and then assigned to the
initial value:
DEFINITIONS
TRANSFER("initial_U.xfr",U0)
INITIAL VALUES
U = U0
In some problems, especially moving mesh problems, it is important to specify initial time derivatives that
are not zero.
This can be done by specifying DT(variable) = expression
Example:
INITIAL VALUES
DT(U) = V0
3.3.10 Equations
The EQUATIONS section is used to list the partial differential equations that define the dependent
variables of the problem.
There must be one equation for each dependent variable listed in the VARIABLES and GLOBAL
VARIABLES sections.
Each equation must be prefixed by variable_name: in order to associate the equation with a variable
P roblem Descriptor Reference : The Sections of a Descriptor 218
and with boundary condition declarations. (If there is only a single equation, the prefix may be omitted.)
Equations are entered into a problem descriptor in much the same way as they are written on paper. In
their simplest form they can be written using the DIV (divergence), GRAD (gradient), CURL and
DEL2(Laplacian) operators. FlexPDE will correctly expand these operators in the coordinate system
specified in the COORDINATES section.
When it is necessary to enter partial differential terms, differential operators of the form D<name> or
D<name1><name2> may be used. Here <name> represents a coordinate name, such as X, Y or Z (or
other names chosen by the user in the COORDINATES section).
In the default 2D Cartesian geometry, the operators DX, DY, DXX, DXY, DYX and DYY are defined.
Similarly, in the default cylindrical geometries (XCYLINDER and YCYLINDER), the operators DR, DZ, DRR,
DRZ, DZR and DZZ are defined.
In 3D Cartesian geometry, the operators DZ, DZZ, DXZ, and DYZ are also defined.
Example:
EQUATIONS
u: div(k*grad(u)) + u*dx(u) = 0
Example:
VARIABLES
U = COMPLEX(Ur,Ui)
EQUATIONS
U: DIV(k*GRAD(U)) + COMPLEX(Ui,Ur) = 0
In problems with a single variable, there is no ambiguity about the assignment of boundary conditions to
the equations.
In problems with more than one variable, FlexPDE requires that equations be explicitly associated with
variables by tagging each equation with a variable name. This process also allows optimal ordering of
219 FlexP DE 7 : P roblem Descriptor Reference
Example:
U: div(k*grad(u))+u*dx(u)= 0 { associates this equation with the variable U }
Boundary conditions are defined in the BOUNDARIES 226 section, and are associated with equations by
use of the variable name, which selects an equation through the association tag. VALUE(U)=0, for
example, will cause the nodal equations for the equation tagged U: to be replaced by the equation u=0
along the selected boundary .
Natural boundary conditions must be written with a sign corresponding to the sign of the generating terms
when they are moved to the left side of the equal sign. We suggest that all second-order terms should be
written on the left of the equal sign, to avoid confusion regarding the sign of the applied natural boundary
condition.
Any number of THEN equation sets may be designated and these sets along with the main EQUATIONS
section will be run sequentially and repetitively (including regrids) until the solution meets the normal error
criteria. Once the EQUATIONS and THEN sets are finished, the last set defined in the FINALLY section
will be solved.
Each set of equations is solved for the variables defined by the equations of that set, with the other
variables held constant at their current values. Solutions of the EQUATIONS set will be held constant
during the solution of the first THEN set, etc.
Each VARIABLE may be defined only once in the complete list of equations.
In time-dependent problems, the full set of equations is solved once during each timestep. The FINALLY
clause is ignored in time-dependent problems.
Note: This facility finds its greatest utility in steady-state problems and time-dependent
problems with one-way coupling. In time-dependent problems with two-way coupling, use of
sequenced equations may falsify propagation speeds, or lead to instability.
P roblem Descriptor Reference : The Sections of a Descriptor 220
Example:
EQUATIONS
u: div(grad(u)) + s = 0
THEN
v: div(grad(v)) + u = 0
Examples:
Samples | Usage | Sequenced_Equations | Theneq.pde 639
Samples | Usage | Sequenced_Equations | Theneq+time.pde 638
Iteration of Equations
Example:
EQUATIONS
START_ITERATION
u: div(grad(u)) = v
r: div(grad(r)) = s
THEN
v: div(grad(v)) = u
s: div(grad(s)) = r
END_ITERATION
Examples:
Samples | Usage | Sequenced_Equations | Equation_Iteration.pde 634
New in version 7 is the ability to state an initial set of steady-state equations that will be solved as the
221 FlexP DE 7 : P roblem Descriptor Reference
EQUATIONS
u: visc*div(grad(u)) - dx(p) = dens*dt(u) + dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*dt(v) + dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
c: dt(c) + u*dx(c) + v*dy(c) = div(Kc*grad(c))
Examples:
Samples | Usage | Sequenced_Equations | Initialeq.pde 636
Samples | Applications | Fluids | Coupled_Contaminant_Initeq.pde 396
When modal analysis is desired, it must be declared in the SELECT section with the selector
MODES = integer
Where F(V) and G(V) are the appropriate terms containing the dependent variable, and H(X,Y) is a
driving source term.
The name LAMBDA is automatically declared by FlexPDE to mean the eigenvalue, and should not be
declared in the DEFINITIONS section.
FlexPDE can support moving computation meshes in time-dependent problems. Use of this capability
requires:
In some problems, the mesh positions may be driven directly. In others, there will be a variable defining
the mesh velocity. This may be the same as the fluid velocity, in which case the model is purely
Lagrangian, or it may be some other better-behaved motion, in which case the model is mixed Lagrange/
Eulerian (ALE).
EQUATIONS are always assumed to refer to the stationary Eulerian (Laboratory) reference frame.
FlexPDE automatically computes the required correction terms for mesh motion. .
Alternatively, the user can declare LAGRANGIAN EQUATIONS, and FlexPDE will not modify the user's
stated equations. In this case, the equations must be written correctly for the values at the moving nodes.
The declaration EULERIAN EQUATIONS can also be used for clarity, although this is equivalent to the
default EQUATIONS declaration.
When the mesh is not tied directly to a fluid velocity, a convenient technique for maintaining mesh
integrity is to diffuse either the mesh coordinates or the mesh velocities in the problem interior.
For direct coordinate diffusion, we apply the diffusion equation to the surrogate coordinates:
DIV(GRAD(x_surrogate)) = 0
and apply the motion conditions to the coordinate boundary conditions with either VALUE or
VELOCITY conditions:
VELOCITY(x_surrogate) = x_velocity
or
VALUE(x_surrogate) = moving_positions
If the mesh is driven by a mesh velocity variable, we apply the diffusion equation to the velocity variables:
DIV(GRAD(x_velocity_variable)) = 0
DT(x_coordinate) = x_velocity_variable
At the boundaries, we apply the driving motions to the velocity variables and lock the surrogate
coordinate variable to its associated velocity
223 FlexP DE 7 : P roblem Descriptor Reference
VALUE(x_velocity_variable) = x_velocity
VELOCITY(x_surrogate) = x_velocity
Note: See the User Guide section on Moving Meshes 130 and the example problems in the
"Samples | Moving_Mesh" folder.
EQUATIONS are always written in the Eulerian (Laboratory) reference frame, regardless of whether the
mesh moves or not. FlexPDE automatically computes the required correction terms for mesh motion.
3.3.11 Constraints
The CONSTRAINTS section, which is optional, is used to apply integral constraints to the system. These
constraints can be used to eliminate ambiguities that would otherwise occur in steady state systems, such
as mechanical and chemical reaction systems, or when only derivative boundary conditions are specified.
The CONSTRAINTS section, when used, normally contains one or more statements of the form
INTEGRAL ( argument ) = expression
CONSTRAINTS should not be used with steady state systems which are unambiguously defined by their
boundary conditions, or in time-dependent systems.
A CONSTRAINT creates a new auxiliary functional which is minimized during the solution process. If
there is a conflict between the requirements of the CONSTRAINT and those of the PDE system or
boundary conditions, then the final solution will be a compromise between these requirements, and may
not strictly satisfy either one.
CONSTRAINTS cannot be used to enforce local requirements, such as positivity, to nodal variables.
Examples:
Samples | Usage | Constraints | Constraint.pde 529
Samples | Usage | Constraints | Boundary_Constraint.pde 528
Samples | Usage | Constraints | 3D_Constraint.pde 526
Samples | Usage | Constraints | 3D_Surf_Constraint.pde 527
Samples | Applications | Chemistry | Reaction.pde 365
3.3.12 Extrusion
The layer structure of a three-dimensional problem is specified bottom-up to FlexPDE in the
P roblem Descriptor Reference : The Sections of a Descriptor 224
EXTRUSION Section:
EXTRUSION
SURFACE "Surface_name_1" Z = expression_1
LAYER "Layer_name_1"
SURFACE "Surface_name_2" Z = expression_2
LAYER "Layer_name_2"
...
SURFACE "Surface_name_n" Z = expression_n
The specification must start with a SURFACE and end with a SURFACE.
LAYERS correspond to the space between the SURFACES.
The Layer_names and Surface_names in these specifications are optional. The LAYER specifications
may be omitted if a name is not needed to refer to them.
Surfaces need not be planar, and they may merge, but they must not cross. expression_1 is
assumed to be everywhere less than or equal to expression_2, and so on. Use a MIN or MAX
function when there is a possibility of crossover.
Surface expressions can refer to regionally defined parameters, so that the surface takes on
different definitions in different regions. The disjoint expressions must, however, be continuous
across region interfaces. (see example "Samples | Usage | 3d_Domains | Regional_surfaces.pde"
499 )
If surface expressions contain conditional values (IF...THEN or MIN, MAX, etc), then the base
plane domain should include FEATURES to delineate the breaks, so they can be resolved by the
gridder.
Surfaces must be everywhere continuous, including across material interfaces. Use of conditionals
or regional definitions must guarantee surface continuity.
Surface expressions can refer to tabular input data (see example "Samples | Usage | 3D_Domains |
Tabular_surfaces.pde" 500 ).
See the User Guide chapter Using FlexPDE in Three-Dimensional Problems 92 for more information on
3D extrusions.
Shorthand form
Stripped of labels, the EXTRUSION specification may be written:
EXTRUSION Z = expression_1, expression_2 {, ...}
In this form layers and surfaces must subsequently be referred to by numbers, with surface numbers
running from 1 to n and layer numbers from 1 to (n-1). SURFACE #1 is Z=expression_1, and LAYER
#1 is between SURFACE #1 and SURFACE #2.
PLANE ( point1 , point2 , point3 ) Defines a plane surface containing the three stated points.
CYLINDER ( point1 , point2 , Defines the top surface of a cylinder with axis along the line
radius ) from point1 to point2 and with the given radius (see note
below). point1 and point2 must be at the same z
coordinate. Z-Tilted cylinders are not supported.
SPHERE ( point , radius ) Defines the top surface of a sphere of the given radius with
center at the specified center point (see note below).
CYLINDER and SPHERE construct the top surface of the specified figure (see note below). To generate
both the upper and lower halves of the CYLINDER and SPHERE, simply construct the figure at Z=0 and
add and subtract the surface function from the desired Z coordinate of the center or axis.
Example:
DEFINITIONS
Zsphere = SPHERE((0,0,0), 10)
EXTRUSION
Zcenter-Zsphere, Zcenter+Zsphere
Note: These functions generate surfaces defined throughout X,Y space. CYLINDER and
SPHERE include Z=constant skirts to extend the surface definitions. The diameters of the
CYLINDER and SPHERE, as well as the extent of the CYLINDER along its axis and of the PLANE
must be provided by REGION BOUNDARIES or FEATURES.
P roblem Descriptor Reference : The Sections of a Descriptor 226
3.3.13 Boundaries
The BOUNDARIES section is used to describe the problem domain over which the specified equation
system is to be solved, and to specify boundary conditions along the outer surfaces of this domain.
Because of the history of FlexPDE, the discussion of boundaries has a strong two-dimensional
orientation. Three-dimensional figures are made up by extruding a two-dimensional domain into the third
dimension. One-dimensional domains are constructed by specializations of 2D techniques.
For concrete examples of the constructs described here, refer to the sample problems distributed with
the FlexPDE software.
3.3.13.1 Points
The fundamental unit used in building problem domains is the geometric POINT . POINTS in a FlexPDE
script are expressed as a parenthesized list of coordinate values, as in the two dimensional point (2.4,
3.72).
Since two- and three- dimensional domain definitions both begin with a two-dimensional layout, the use
for three-dimensional points is generally limited to ELEVATION PLOTS.
where (a,b) and (c,d) are the physical coordinates of the ends of the segment, and segment is either
LINE, SPLINE or ARC.
The path continues with a connected series of segments, each of which moves the segment to a new
point. The end point of one segment becomes the start point of the next segment.
A path ends whenever the next input item cannot be construed as a segment, or when it is closed by
227 FlexP DE 7 : P roblem Descriptor Reference
returning to the start point. The closing segment may simply end at the start point, or it can explicitly
reference CLOSE, which will cause the current path to be continued to meet the starting point:
... segment TO CLOSE.
or
... segment CLOSE.
Line Segments
Line segments take the form
LINE TO (x,y)
When successive LINE segments are used, the reserved word LINE does not have to be repeated, as
in the following:
LINE TO (x1,y1) TO (x2,y2) TO (x3,y3) TO ...
Spline Segments
Spline segments are syntactically similar to Line segments
A cubic spline will be fit to the listed points. The first point of the spline will be either the
START point or the ending point of the previous segment. The last point of the spline will be
the last point stated in the chain of TO(,) points.
The fitted spline will have zero curvature at the end points, so it is a good idea to begin and
end with closely spaced points to establish the proper endpoint directions.
Arc Segments
Arc segments create either circular or elliptical arcs, and take one of the following the forms:
Here angle is an angle measured in degrees , and follows the convention that positive angles rotate
counter-clockwise and negative angles rotate clockwise. The coordinate point at the end of the arc is
determined by the radius swept out by the angle. To specify the angle in radians, follow the radian
value by the qualifier RADIANS.
Elliptical Segments
When the form ARC ( CENTER = x1,y1) to (x2,y2) is used and the center (x1,y1) is not equidistant
from the start and end points, an elliptical arc segment is generated with major and minor axes along
the X and Y coordinate directions.
The orientation of the major and minor axes can be rotated with the ROTATE qualifier.
ARC ( CENTER = x1,y1 ROTATE = 30 ) TO (x2,y2)
P roblem Descriptor Reference : The Sections of a Descriptor 228
The rotation angle is defined in degrees unless followed by the qualifier RADIANS.
The end point is not rotated by this command, and must be stated correctly to intercept the rotated
ellipse.
Examples:
Samples | Usage | Misc | Rotated_Ellipse.pde 595
In the first form, equation defines a relation between the X and Y coordinates that lie on the curve,
such as x2 +y2 =R2 . The boundary will follow the given equation exactly, and the start and end points
must lie on the path or an error will be issued.
In the second form, expression is the left side of an equation, like x2 +y2 . The expression will be
equated to a value computed using the starting point. Then this calculated equation will be used as in
the first form. The end point must lie on the computed equation or an error will be issued.
In both forms, direction will dictate which way to start tracing the path, and must be +X, -X, +Y, or -
Y. The +X means move in the positive X direction, -X means move in the negative X direction, and
so on.
Note : Avoid using CURVE with the start and end points at the same position, even if the expression
is unambiguous.
Examples:
Samples | Usage | Implicit_Curves | Implicit_Curve_Boundary.pde 559
Samples | Usage | Implicit_Curves | Implicit_Curve_Surface.pde 559
Samples | Usage | Implicit_Curves | Sine_Boundary.pde 560
Samples | Usage | Implicit_Curves | Sine_Boundary_3D.pde 561
Named Paths
Names can be assigned to paths. When names are assigned to paths they take the form of a quoted
string and must be placed immediately after the reserved word START :
Assigned path names are useful when boundary or line-related integrals are desired or for establishing
paths over which ELEVATION plots are desired.
Names can be assigned to portions of a path by entering a new START clause, or by overlaying a
229 FlexP DE 7 : P roblem Descriptor Reference
In the case of ARRAYS, two arrays of equal dimension are used to specify the coordinates in a LIST
boundary:
LINE LIST(Ax,Ay)
SPLINE LIST(Ax,Ay)
Here Ax and Ay are ARRAYS listing the X- and Y- coordinates of the path.
A 2-by-N MATRIX may also be used to specify a LINE or SPLINE LIST , with the syntax:
LINE LIST(Mxy)
SPLINE LIST(Mxy)
Examples:
Samples | Usage | Arrays+Matrices | Array_Boundary.pde 513
Samples | Usage | Arrays+Matrices | Matrix_Boundary.pde 515
3.3.13.3 Regions
Example:
Overlaying regions:
RULE:
REGIONS DEFINED LATER OVERLAY AND OBSCURE REGIONS DEFINED EARLIER.
P roblem Descriptor Reference : The Sections of a Descriptor 230
AREAS COMMON TO TWO REGIONS BECOME PART OF THE LATER DEFINED REGION.
So, in the example above, the two smaller boxes overlay the large box. The material parameters
assigned to the large box pertain only to the part of the large box not overlaid by the small boxes.
It is customary to make the first region define the entire outer boundary of the problem domain, and
then to overlay the parts of the domain which differ in parameters from this default region. If you
overlay all parts of the outer domain with subregions, then the outer region definition becomes
invisible. It may be useful to do this in some cases, since it allows a localization of boundary condition
specifications. Nevertheless, one of the subregions is superfluous, because it could be the default.
Names previously defined in the DEFINITIONS section can be assigned a new value within a REGION by
adding one or more assignments of the form
name = new_expression
Example:
DEFINITIONS
K=1 { the default value }
REGION 1 { assumes default, since no override is given }
START(0,0) LINE TO (10,0) TO (10,10) TO (0,10) TO CLOSE
REGION 2
K=2 { both sub-boxes are assigned K=2 }
START(1,1) LINE TO (2,1) TO (2,2) TO (1,2) TO CLOSE
START(5,5) LINE TO (6,5) TO (6,6) TO (5,6) TO CLOSE
REGION 3 { again assumes the default }
START(3,3) LINE TO (4,3) TO (4,4) TO (3,4) TO CLOSE
3.3.13.3.2 Regi on s i n On e Di m en si on
In one-dimensional domains, the concept that a REGION bounds a finite area by closing on itself is no
longer true. In one dimension, it is sufficient to define a path from the start of a material region to its
finish. (Referencing CLOSE in a 1D bounding path will cause serious troubles, because the path will
retrace itself.)
REGION 1
231 FlexP DE 7 : P roblem Descriptor Reference
are sufficient to define a region of material extending from location 0 to location 5 in the 1D coordinate
system.
In order to maintain grammatical consistency with two- and three- dimensional constructs, omitting the
parentheses is not permitted.
3.3.13.3.3 Regi on s i n T h r ee Di m en si on s
The concept of a REGION in 3D domains retains the same character as for 2D domains.
The REGION is a partition of the 2D projection of the figure, and is extruded into the third dimension
according to the EXTRUSION specification.
A material compartment in 3D is uniquely defined by the REGION of the projection which bounds it, and
the LAYER of the extrusion in which it resides.
Extrusion of each 2D REGION therefore creates a stack of layers above it, each with possibly unique
material properties.
A question then arises as to when a component that exists in a given layer of the domain must be divided
into multiple regions. The rule can be stated as follows:
Rule: When two points in the projection plane see different stacks of materials above them in the
extrusion direction, then these two points must reside in different REGIONS of the domain layout.
In the presence of LIMITED REGIONS 232 , the above rule can be interpreted to consider only the two
layers adjoining a given extrusion surface. If the materials above and below the surface differ between
two points, then there must be a REGION boundary separating the two points in the subject extrusion
surface. REGION boundaries are induced in surfaces by the presence of a REGION boundary in either
adjoining LAYER (subject to the overlay rule 229 ).
See the User Guide chapter Using FlexPDE in Three-Dimensional Problems 92 for further discussion of
the construction of 3D domains.
3.3.13.3.4 Regi on a l Pa r a m et er V a l u es i n 3D
The LAYER qualifier acts on all subsequent parameter redefinitions, until a new LAYER qualifier or a
functionally distinct clause breaks the group of redefinitions.
Example:
The following descriptor fragment shows the redefinition of a parameter K in various contexts:
DEFINITIONS
K=1 { defines the default value }
BOUNDARIES
LAYER 1 K=2 { (valid only in 3D) defines the value in layer 1 of all regions }
REGION 1
K=3 { redefines the value in region 1 only, in all layers of a 3D domain }
LAYER 2 K=4 { (valid only in 3D) defines the value in layer 2 of region 1
only }
START(0,0) LINE TO ....
3.3.13.3.5 Li m i t ed Regi on s i n 3D
In three dimensional problems, many figures to not fit readily into the extrusion model. In particular, there are
frequently features that in reality exist only at very restricted positions in the extrusion dimension, and which
create poor meshes when extruded throughout the domain.
FlexPDE implements the concept of LIMITED REGIONS to accommodate this situation.
A LIMITED REGION is defined as one that is considered to exist only in specified layers or surfaces of the
domain, and is absent in all other layers and surfaces.
The LIMITED REGION will be constructed only in layers and surfaces specifically stated in the body of the
REGION definition.
An example of this type of structure might be a transistor, where the junction structure of the device is
present only in a very thin layer of the domain, while the substrate occupies the majority of the volume.
In earlier versions of FlexPDE, the shape of the junction structure was propagated and meshed throughout
the extrusion dimension. Since version 4, the structure can be restricted, or LIMITED, to a single layer or a
few layers.
For example, the following descriptor fragment defines a 3-unit cube with a 0.2-unit cubical structure in the
center. The small structure is present in the layer 2 mesh only.
EXTRUSION Z=0, 1.4, 1.6, 3
BOUNDARIES
REGION 1
START(0,0) LINE TO (3,0) TO (3,3) TO (3,0) TO CLOSE
LIMITED REGION 2
LAYER 2 K=9
START(1.4,1.4)
233 FlexP DE 7 : P roblem Descriptor Reference
See the User Guide section "Limited Regions 98 " for a graphical example of this facility.
Examples:
Samples | Usage | 3D_Domains | 3D_Limited_Region.pde 480
3.3.13.3.6 Em pt y La y er s i n 3D
In three dimensional problems, it is sometimes necessary to define holes or excluded regions in the extruded
domain. This may be done using the VOID qualifier. VOID has the syntax of a parameter redefinition.
For example, the following descriptor fragment defines a 3-unit cube with a 1-unit cubical hole in the center:
EXTRUSION Z=0,1,2,3
BOUNDARIES
REGION 1
START(0,0) LINE TO (3,0) TO (3,3) TO (3,0) TO CLOSE
REGION 2
LAYER 2 VOID
START(1,1) LINE TO (2,1) TO (2,2) TO (1,2) TO CLOSE
Examples:
Samples | Usage | 3D_Domains | 3D_Void.pde 497
3.3.13.4 Ex cludes
EXCLUDE subsections are used to describe closed domains which overlay parts of one or more REGION
subsections. The domain described by an exclude subsection is excluded from the system. EXCLUDE
subsections must follow the REGION subsections which they overlay
EXCLUDE subsections are formed in the same manner as REGION subsections and can use all the same
LINE and ARC segments.
3.3.13.5 Features
FEATURE subsections are used to describe non-closed entities which do not enclose a subdomain with
definable material parameters.
FEATURE subsections are formed in the same manner as REGION 229 subsections and can use all the
same LINE and ARC segments.
P roblem Descriptor Reference : The Sections of a Descriptor 234
Example:
REGION 1 { an outer box }
START(0,0) LINE TO (10,0) TO (10,10) TO (0,10) TO CLOSE
FlexPDE supports the ability to place mesh nodes at specific points in the problem geometry. This is
done with the statements
NODE POINT (x_value , y_value)
NODE POINT (x_value , y_value , z_value)
A mesh node will be placed at the specified location, and linked into the computation mesh.
NODE POINTS can be used to place POINT VALUE 237 or POINT LOAD 237 boundary conditions (see
Caveat 237 ).
In moving mesh problems, NODE POINTS will move with the mesh; they will not be locked to the
specified location unless appropriate POINT VALUE boundary conditions are used to freeze the point.
In 3D geometries, specification of only two coordinates will cause a vertical meshing line to be placed
throughout the Z-coordinate range of the domain. A three-coordinate point will specify a single node.
Placing NODE POINTS in coincidence with EXTRUSION surfaces will have undefined effects, and may
lead to mesh generation failure.
An alternative way of forcing nodes is to run a FEATURE or REGION boundary to and through the
desired point.
While not strictly enforced, it is recommended that all REGION subsections be listed before any
EXCLUDE or FEATURE subsections and that all EXCLUDE subsections be listed before any FEATURE
subsections.
It is further recommended that the first REGION subsection be formed by walking the outside boundary
235 FlexP DE 7 : P roblem Descriptor Reference
Rule:
REGIONS defined later are assumed to overlay any previously listed REGIONs, and any
properties assigned to a REGION will override properties previously assigned to the domains
they overlay.
Regions in 3D Domains
In 3D domains, the above rule is applied in each extrusion surface.
REGION, EXCLUDE and FEATURE subsections can be assigned numbers and/or names.
When numbers are assigned they should be in ascending sequential order beginning with one. It is
recommended that numbers always be assigned.
When names are assigned they must take the form of a quoted string and must be placed immediately
after either the reserved word REGION, EXCLUDE, or FEATURE or any number assigned to the REGION,
EXCLUDE, or FEATURE. Assigned names must be unique to the REGION, EXCLUDE or FEATURE that
they name.
Assigned region names are useful when region-restricted plots or volume integrals are desired.
Example:
REGION 2 'Thing'
{...}
PLOTS
contour(u) on 'Thing'
The point will be replaced by a circular arc of the specified radius, or by a bevel of the specified length.
FILLETS and BEVELS should not be applied to points which are the intersection of several segments, or
confusion may ensue.
Example:
LINE TO (1,1) FILLET(0.01)
P roblem Descriptor Reference : The Sections of a Descriptor 236
Example problem:
Samples | Usage | Misc | Fillet.pde 590
Samples | Usage | 3D_Domains | 3D_Fillet.pde 590
The following forms of boundary condition specification may be applied to boundary segments:
The variable designated in the boundary condition specification identifies (by explicit association) the
equation to which this boundary condition is to be applied.
NOBC(VARIABLE) can be used to turn off a previously specified boundary condition on the current
path. It is equivalent in effect to NATURAL(VARIABLE)=0 (the default boundary condition), except
that it will not lead to "Multiple Boundary Condition Specification" diagnostics.
Segment boundary conditions are added to the problem descriptor by placing them in the BOUNDARIES
section.
Segment boundary conditions must immediately precede one of the reserved words LINE or ARC and
cannot precede the reserved word TO.
A top-down system is used for applying segment boundary conditions to the equations. Following the
START point specification in each path definition, a segment boundary condition is set up for each
variable/equation. It is recommended that a boundary condition be specified for each variable/equation.
If no other segment boundary condition is specified no error will occur and a NATURAL(VARIABLE) = 0
segment boundary condition is assumed.
Under the top-down system, as boundary segments occur, the previously specified segment boundary
condition for a variable will continue to hold until a new boundary condition is specified for that variable.
If the recommendation is followed that REGION 1 be formed by walking the outside boundary of the
problem, thereby enclosing the entire domain of the problem, then for most problems segment boundary
conditions need only be specified for the segments in REGION 1.
following a coordinate specification. The stated value will be imposed at the coordinate point
immediately preceding the specification.
following a coordinate specification. The stated load will be imposed as a lumped source on the
coordinate point immediately preceding the specification.
A Caveat:
The results achieved by use of these specifications are frequently disappointing.
A diffusion equation, for example, div(grad(u))+s=0, can support solutions of the form u=A-Br-
Cr^2, where r is the distance from the point value and A, B and C are arbitrary constants. By the
superposition principle, FlexPDE is free to add such shapes to the computed solution in the vicinity of
the point value, without violating the PDE. A POINT VALUE condition usually leads to a sharp spike
in the solution, pulling the value up to that specified, but otherwise leaving the solution unmodified.
The POINT LOAD is not subject to this same argument, but since it is a load without scale, it will
frequently produce a dense mesh refinement around the point.
A better solution is to use a distributed load or an extended value boundary segment, ring or box.
The idea that a boundary condition applies along the length of a boundary segment, while meaningful in
two and three dimensions, is meaningless in one dimension, since it is the value along the segment that is
the object of the computation.
In one dimensional problems, therefore, it is necessary to use the Point boundary condition described in
the previous section for all boundary condition specifications.
Example:
BOUNDARIES
REGION 1
START(0) POINT VALUE(u)=1
LINE TO (5) POINT LOAD(u)=4
The node at coordinate 0 will have value 1, while that at coordinate 5 will have a load of 4.
3.3.13.10.4 Bou n da r y Con di t i on s i n 3D
The LAYER qualifier applies to all subsequent boundary condition specifications until a new LAYER
qualifier is encountered, or the segment geometry (LINE or ARC) statements begin.
239 FlexP DE 7 : P roblem Descriptor Reference
The boundary conditions on the extrusion surfaces themselves (the slicing surfaces) can be specified by
the SURFACE qualifier preceding the boundary condition specification.
Consider a simple cube. The EXTRUSION and BOUNDARIES sections might look like this:
EXTRUSION z = 0,1
BOUNDARIES
SURFACE 1 VALUE(U)=0 {1}
REGION 1
SURFACE 2 VALUE(U)=1 {2}
START(0,0)
NATURAL(U)=0 {3}
LINE TO (1,0)
LAYER 1 NATURAL(U)=1 {4}
LINE TO (1,1)
NATURAL(U)=0 {5}
LINE TO (0,1) TO CLOSE
Line { 1 } specifies a fixed value of 0 for the variable U over the entire surface 1 (ie. the Z=0 plane).
Line { 2 } specifies a value of 1 for the variable U on the top surface in REGION 1 only.
Line { 3 } specifies an insulating boundary on the Y=0 side wall of the cube.
Line { 4 } specifies a flux (whose meaning will depend on the PDE) on the X=1 side wall in LAYER 1
only.
Line { 5 } returns to an insulating boundary on the Y=1 and X=0 side walls.
[Of course, in this example the restriction to region 1 or layer 1 is meaningless, because there is only one
of each.]
3.3.13.10.5 Ju m p Bou n da r i es
In the default case, FlexPDE assumes that all variables are continuous across internal material interfaces.
This is a consequence of the positioning of mesh nodes along the interface which are shared by the cells
on both sides of the interface.
FlexPDE supports the option of making variables discontinuous at material interfaces (see the
"Discontinuous Variables 86 " in the User Guide for tutorial information). This capability can be used to
model such things as contact resistance, or to completely decouple the variables in adjacent regions.
The key words in employing this facility are CONTACT and JUMP. The conceptual model is that of
contact resistance, where the difference in voltage V across the interface (the JUMP) is given by
V2 - V1 = R*current
In the general case, the role of "current" is played by the generalized flux, or Natural boundary condition
237 . (See the User Guide for further discussion of Natural Boundary Conditions 82 .) The CONTACT
boundary condition is a special form of NATURAL, which defines a flux but also specifies that FlexPDE
should model a double-valued boundary.
So the method of specifying a discontinuity is
P roblem Descriptor Reference : The Sections of a Descriptor 240
CONTACT(V) = (1/R)*JUMP(V)
CONTACT(V), like NATURAL(V), means the outward normal component of the generalized flux as seen
from any cell. So from any cell, the meaning of JUMP(V) is the difference between the interior and
exterior values of V at a point on the boundary. Two cells sharing a boundary will then see JUMP values
and outward normal fluxes of opposite sign. "Flux" is automatically conserved, since the same numeric
value is used for the flux in both cells.
Specifying a CONTACT boundary condition at an internal boundary causes duplicate mesh nodes to be
generated along the boundary, and to be coupled according to the JUMP boundary condition statement.
Specifying a very small (1/R) value effectively decouples the variable across the interface.
Example Problems:
FlexPDE supports periodic and antiperiodic boundary conditions in one, two or three dimensions.
The mapping expressions specify the arithmetic required to convert a point (X,Y) in the immediate
boundary to a point (X',Y') on a remote boundary. The mapping expressions must result in each
point on the immediate boundary being mapped to a point on the remote boundary. Segment
endpoints must map to segment endpoints. The transformation must be invertible; do not specify
constants as mapped coordinates, as this will create a singular transformation.
The periodic boundary statement terminates any boundary conditions in effect, and instead imposes
equality of all variables on the two boundaries. It is still possible to state a boundary condition on the
remote boundary, but in most cases this would be inappropriate.
241 FlexP DE 7 : P roblem Descriptor Reference
The periodic statement affects only the next following LINE or ARC path. These paths may contain
more than one segment, but the next appearing LINE or ARC statement terminates the periodic
condition unless the periodic statement is repeated.
Periodicity in 1D
Periodicity in a one-dimensional problem is invoked by the POINT PERIODIC or POINT
ANTIPERIODIC statement. All other aspects are similar to the description above for X-Y periodicity.
In this case, the top and bottom extrusion surfaces are assumed to be conformable, and the values are
forced equal (or sign-reversed) along these surfaces.
The PERIODIC (or ANTIPERIODIC) statement presets the behavior of all variables. Variables then
mapped to 1 will be periodic. Variables mapped to -1 will be antiperiodic. For example, assuming
variables A, B, C, the following would make A and C periodic, and B antiperiodic :
PERIODIC(x-2,y) MAP(a)=1 MAP(b)=-1
Note :
Prior to version 7, each node in the finite element mesh could have at most one periodic image.
This meant that two-way or three-way periodicity at a single mesh node could not be
supported. However, in version 7 multiple periodic images at one mesh node is supported.
Example Problems:
Samples | Usage | Periodicity | periodic.pde 628
Samples | Usage | Periodicity | periodic_map.pde 629
Samples | Usage | Periodicity | periodic+time.pde 627
Samples | Usage | Periodicity | two-way_periodic.pde 630
Boundary conditions for COMPLEX or VECTOR VARIABLES may be declared for the complex or vector
variable directly, or for the individual components.
If C is a COMPLEX VARIABLE with components Cr and Ci, the following boundary condition declarations
are equivalent:
VALUE(C) = Complex(a,b)
VALUE(Cr) = a VALUE(Ci) = b
If V is a VECTOR VARIABLE with components Vx and Vy, the following boundary condition declarations
are equivalent:
NATURAL(V) = Vector(a,b)
NATURAL(Vx) = a NATURAL(Vy) = b
The component form allows the application of different boundary condition forms (VALUE or NATURAL)
to the components, while the root variable form does not.
3.3.14 Front
The FRONT section is used to define additional criteria for use by the adaptive regridder. In the normal
case, FlexPDE repeatedly refines the computational mesh until the estimated error in the approximation
of the PDE's is less than the declared or default value of ERRLIM. In some cases, where meaningful
activity is confined to some kind of a propagating front, it may be desirable to enforce greater refinement
near the front. In the FRONT section, the user may declare the parameters of such a refinement.
The FRONT section has the form:
The stated criterion will be evaluated at each node of the mesh. Cells will be split if the values at the
nodes span a range greater than (-delta/2, delta/2) around zero.
That is, the grid will be forced to resolve the criterion to within delta as it passes through zero.
Example:
Samples | Usage | Mesh_Control | Front.pde 582
3.3.15 Maximize
The MAXIMIZE section is used to optimize parameters. FlexPDE implements the Nelder-Mead
"amoeba" algorithm to minimize or maximize an objective function. This is not the method of greatest
243 FlexP DE 7 : P roblem Descriptor Reference
speed, but it is very flexible, and allows FlexPDE to perform optimization searches in a wide range of
problem environments.
The method creates a simplex of parameter values, each parameter assigned a random sampling of
values centered about the start value with the stated range. The parameter values are modified until the
value of the objective is maximized within the OPTERRLIM 188 or the range of values of each parameter is
bracketed to OPTERRLIM*parameter.
In the first form, the values of the parameter are allow to shift without limits on values. The second form
is used to enforce an upper and lower limit to the acceptable values for the parameter. So as the
optimization is taking place, the parameter will never go beyond these limits. When multiple parameters
are declared, each parameter may be either form.
See also : MINIMIZE 243
Examples:
Samples | Usage | Optimization | Criticality.pde 617
Samples | Usage | Optimization | Criticality_Size.pde 618
Samples | Usage | Optimization | Power_Control.pde 620
Samples | Usage | Optimization | Size_Control.pde 621
3.3.16 Minimize
The MINIMIZE section works the same as the MAXIMIZE 242 section but with optimization looking for a
minimum rather than a maximum.
3.3.17 Resolve
The RESOLVE section is used to define additional criteria for use by the adaptive regridder. In the
normal case, FlexPDE repeatedly refines the computational mesh until the estimated error in the
approximation of the PDE's is less than the declared or default value of ERRLIM. In some cases, this can
be achieved with a much less dense mesh than is necessary to make pleasing graphical presentation of
derived quantities, such as derivatives of the system variables, which are much less smooth than the
variables themselves. In the RESOLVE section, the user may declare one or more additional functions
whose detailed resolution is important. The section has the form:
RESOLVE ( spec1 ) , ( spec2 ) , ( spec3 ) {...}
Here, each spec may be either an expression, such as "( shear_stress)", or an expression followed by
a weighting function, as in "(shear_stress, x^2)".
In the simplest form, only the expressions of interest need be presented. In this case, for each stated
P roblem Descriptor Reference : The Sections of a Descriptor 244
Because the finite element interpolation thus formed assumes continuous functions, application of
RESOLVE to a discontinuous argument will result in dense gridding at the discontinuity. An exception to
this is at CONTACT 239 boundaries, where the finite element representation is double valued.
In the weighted form, an importance-weighting function is defined, possibly to restrict the effective
domain of resolution. The splitting operation described above is modified to multiply the deviation at
each point by the weight function at that point. Areas where the weight is small are therefore subjected to
a less stringent accuracy requirement.
Example:
Samples | Usage | Mesh_Control | Resolve.pde 585
3.3.18 Time
The TIME section is used in time dependent problem descriptors to specify a time range over which the
problem is to be solved. It supports the following alternative forms:
FROM time1 TO time2
FROM time1 BY increment TO time2
FROM time1 TO time2 BY increment
Where:
time1 is the beginning time
time2 is the ending time.
increment is an optional specification of the initial time step
for the solution. (the default initial time step is 1e-
4*(time2-time1)).
All time dependent problem descriptors must include statements which define the time range.
While the problem descriptor language supports alternate methods of specifying a time range, it is
recommended that all time dependent problems include the TIME section to specify the total time
domain of the problem.
Halting Execution
The time range specification may optionally be followed by a HALT statement:
HALT minimum
HALT = minimum
This statement will cause the computation to halt if the automatically controlled timestep drops below
minimum. This facility is useful when inconsistencies in data or discontinuities in parameters cause the
245 FlexP DE 7 : P roblem Descriptor Reference
HALT condition
Here the condition can be any relational operation, such as globalmax(myvariable) < 204. If the
condition is met on any timestep, the computation will be halted.
This statement will prevent the timestep controller from increasing the computation timestep beyond the
stated maximum.
maximum may be any constant arithmetic expression.
Critical Times
The time range specification may optionally be followed by a CRITICAL statement:
CRITICAL time1 {, time2, time3 ...}
This will ensure that each of the times in the list will fall at the end of some timestep interval.
Times may be separated by commas or spaces.
An #include statement can be used to read the times from a disk file.
display_specification must be one of the known plot types, as described in the next section.
In some cases, multiple plot_data arguments may be provided.
There may be any number of display_modifiers, with meanings determined by the
display_specification.
P roblem Descriptor Reference : The Sections of a Descriptor 246
The various display_modifiers supported by FlexPDE are listed in the "Graphic Display Modifiers 248
" section.
An Exhortation:
The MONITORS facility has been provided to allow users to see immediate feedback on the progress
of their computation, and to display any and all data that will help diagnose failure or
misunderstanding. Please use MONITORS extensively, especially in the early phases of model
development! Since they do not write to the .pg7 storage file, they can be used liberally without
causing disk file bloat. After the model is performing successfully, you can remove them or comment
them out. Many user pleas for help recieved by PDE Solutions could be avoided if the user had
included enough MONITORs to identify the cause of trouble.
Examples:
Samples | Usage | Plotting | Plot_test.pde 633
The MONITORS or PLOTS sections can contain one or more display specifications of the following types:
CONTOUR ( arg )
Requests a two dimensional contour map of the argument, with levels at uniform intervals of the
argument.
May be combined with FIELDMAP (as CONTOUR FIELDMAP) to generate overlayed potential
contours and field lines.
Requests a two dimensional contour map of both arg1 and arg2, each with levels at independent
uniform intervals.
A level table is displayed for both arg1 and arg2.
Requests a two dimensional display (some times called a line-out) which displays the value of its
argument(s) vertically and the value of its path horizontally.
Each ELEVATION listed must have at least one argument and may have multiple arguments
separated by commas.
path can be either a line segment specified using the forms FROM 254 (X1,Y1) TO (X2,Y2) or ON
254 name , where name is a literal string selecting a path named in the BOUNDARIES 226 section.
247 FlexP DE 7 : P roblem Descriptor Reference
Requests a two dimensional map of the force field lines of a potential, arg.
The namedpath will be used as the starting boundary of the field lines.
The number of field lines can be adjusted using the modifier FIELDLINES 249 .
A level table is not displayed.
May be combined with CONTOUR (as CONTOUR FIELDMAP) to generate overlayed potential
contours and field lines.
See example "Samples | Applications | Electricity | Fieldmap.pde" 374 .
Requests a two dimensional plot of the computation grid, with nodal coordinates defined by the
two arguments.
Grids are especially useful for displaying material deformations.
In 3D problems, a two-argument GRID plot will show a cut-plane, and must be followed by an ON
254 specification.
3D cut plane grid plots do not necessarily accurately represent the computational grid.
Requests a three dimensional plot of the computation grid, with nodal coordinates defined by the
three arguments.
Only the outer surface of the grid will be drawn.
This plot can be interactively rotated, as with SURFACE 247 plots.
MODE_SUMMARY
In eigenvalue problems, this produces a SUMMARY page for each mode (comparable to the version
5 SUMMARY ).
This has been replaced with MODE SUMMARY (no underscore).
SUMMARY
This plot type defines a text page on which only REPORT 257 items may appear.
A SUMMARY page can be EXPORT 249 ed to produce text reports of scalar values.
SUMMARY ( 'string' )
If a string argument is given with a SUMMARY command, it will appear as a page header on the
summary page.
SURFACE ( arg )
VECTOR ( vector )
Requests a two dimensional display of directed arrows in which the direction and magnitude of the
arrows is set by the vector argument.
The origin of each arrow is placed at its reference point.
Requests a two dimensional display of directed arrows in which the horizontal and vertical
components of the arrows are given by arg1 and arg2.
The origin of each arrow is placed at its reference point.
-----------------------------------------------------------------------------
For all commands, the argument(s) can be any valid expression.
The appearance of any display can be modified by adding one or more of the following clauses:
AREA_INTEGRATE
Causes CONTOUR and SURFACE plots in cylindrical geometry to be integrated with dr*dz
element, rather than default 2*pi*r*dr*dz volume element.
See also: LINE_INTEGRATE 251
AS 'string'
Changes the label on the display from the evaluated expression to string.
BLACK
BMP
BMP ( pixels )
BMP ( pixels, penwidth )
CONTOURS = number
Selects the number of contour lines for CONTOUR plots. This is a local control equivalent to the
global CONTOURS control, but applying only to a single plot.
249 FlexP DE 7 : P roblem Descriptor Reference
DROPOUT
Marks EXPORT and TABLE output points which fall outside the problem domain as "external". This
modifier affects only EXPORTS and TABLES with FORMAT strings (see below).
EMF
EMF ( pixels )
EMF ( pixels, penwidth )
EPS
EXPORT
Causes a disk file to be written containing the data represented by the associated MONITOR or
PLOT .
A regular rectangular grid will be constructed, and the data will be printed in a format suitable for
reading by the FlexPDE TABLE function.
The dimension of the grid will be determined by the plot grid density appropriate to the type of
plot.
The format of EXPORTED data may be controlled by the FORMAT modifier (see below).
(This is a renaming of the older PRINT modifier)
EXPORT ( n )
Modifies the EXPORT command by specifying the dimension of the printed data grid.
For two- or three-dimensional plots, the grid will be (n x n) or (n x n x n).
EXPORT ( nx, ny )
EXPORT ( nx, ny, nz )
Modifies the EXPORT command by specifying the dimension of the printed data grid.
FIELDLINES = n
Overrides the default number of FIELDMAP 247 field lines and uses n instead.
P roblem Descriptor Reference : The Sections of a Descriptor 250
FILE 'string'
Overrides the default naming convention for files created by the EXPORT or PRINT modifiers, and
writes the file named 'string' instead.
Changes the dynamically set range used for the variable axis to a minimum value of arg1 and a
maximum of arg2. Data outside this range is not plotted.
See also: RANGE 253
FORMAT 'string'
This modifier replaces the default format of the EXPORT or PRINT modifiers, or of the TABLE
output command. When this modifier appears, the output will consist of one line for each point in
the export grid.
The contents of this line will be completely controlled by the format string as follows:
1. all characters except "#" will be copied literally to the output line.
2. "#" will be interpreted as an escape character, and various options will be selected by the
character following the "#":
a. #x, #y, #z and #t will print the value of the spatial coordinates or time of the data point;
b. #1 through #9 will print the value of the corresponding element of the plot function list;
c. #b will write a taB character;
d. #r will cause the remainder of the format string to be repeated for each plot function in the
plot list;
e. #i inside a repeated string will print the value of the current element of the plot function list.
Forces the plot frame to the specified coordinates, regardless of the size of the problem domain.
The plot frame will be forced to a 1:1 aspect ratio using the largest of the width and height values.
This allows the creation of consistently-sized plots in moving-mesh problems.
See "Samples | Moving_Mesh | Piston.pde".
See also: ZOOM 254
GRAY
Draws current plot with a 32-level gray scale instead of the default color palette.
INTEGRATE
This integral differs from a REPORT(INTEGRAL(...)) in that this command will integrate on the plot
grid, while the REPORT will integrate on the computation grid.
This modifier can be globally imposed by use of PLOTINTEGRATE in the SELECT section.
LINE_INTEGRATE
Causes ELEVATIONS in cylindrical geometry to be integrated with dl element, rather than default
2*pi*r*dl element.
See also: AREA_INTEGRATE 248
LOG
LINLOG
LOGLIN
LOGLOG
Changes the default linear scales used to those specified by the scaling command.
LOG is the same as LINLOG, and specifies logarithmic scaling in the data coordinate.
<lx><ly><lz>
Changes the default linear scales used to those specified by the scaling command.
Each of <lx>, <ly> and <lz> can be either LIN or LOG, and controls the scaling in the
associated dimension.
LOG ( number )
...combinations as above
MERGE
Sends EXPORT output for all stages or plot times to a single output file.
This is the default for TECPLOT output.
This option can be set globally by SELECT PRINTMERGE.
MESH
In SURFACE plots, causes the surface to be displayed as a hidden-line drawing of the meshed
surface.
This display is more suitable on some hardcopy devices.
NOHEADER
NOLINES
NOMERGE
Sends EXPORT output for each stage or plot time to a separate output file.
This is the default for EXPORT output.
NOMINMAX
Deletes "o" and "x" marks at min and max values on contour plot.
NORM
In VECTOR plots, causes all vectors to be drawn with the same length. Only the color identifies
different magnitudes.
NOTAGS
NOTIPS
ON <control>
Selects region, surface or layer restrictions of plot domain. See "Controlling the Plot Domain 254 ".
PAINTED
Fills areas between contour lines with color. (This is slower than conventional contour lines.)
PAINTMATERIALS
PAINTREGIONS
PENWIDTH = n
PNG
253 FlexP DE 7 : P roblem Descriptor Reference
PNG ( pixels )
PNG ( pixels, penwidth )
POINTS = n
POINTS = ( nx , ny )
POINTS = ( nx, ny, nz )
PPM
PPM ( pixels )
PPM ( pixels, penwidth )
PRINT
PRINT ( n )
PRINT ( nx, ny )
PRINT ( nx, ny, nz )
PRINTONLY
Supresses graphical output. Use with PRINT or EXPORT to create text output only.
Changes the dynamically set range used for the variable axis to a minimum value of arg1 and a
maximum of arg2.
If the calculated value of the variable falls outside of the range argument, the range argument is
ignored and the dynamically calculated value is used.
P roblem Descriptor Reference : The Sections of a Descriptor 254
VIEWPOINT( X, Y, angle )
With SURFACE plots, the VIEWPOINT modifier sets the viewing azimuth and perspective distance
and the viewing elevation angle.
VOL_INTEGRATE
XPM
XPM ( pixels )
XPM ( pixels, penwidth )
Expands (zooms) a selected area of the display or export, with (X,Y) defining the lower left hand
corner of the area and (Wide,High) defining the extent of the expanded area.
In 3D cut planes, the X and Y coordinates refer to the horizontal and vertical dimensions in the cut
plane.
See also: FRAME 250
Expands (zooms) a selected volume of an export, with (X,Y,Z) defining the lowest corner of the
volume and (Xsize,Ysize,Zsize) defining the extent of the included volume.
"ON" selectors
The primary mechanism for controlling the domain over which plot data are constructed is the "ON"
statement, which has many forms:
ON "name"
ON REGION "name"
ON REGIONS "name1" , "name2" { , ... }
ON REGION number
255 FlexP DE 7 : P roblem Descriptor Reference
The first listed form selects a boundary path, region, layer or surface depending on the definition of the
"name". (It is actually redundant to specify SURFACE "name", etc, since the fact that a surface is
being specified should be clear from the "name" itself. Nevertheless, the forms are acceptable.)
The multiple REGIONS and LAYERS forms allow grouping REGIONS and LAYERS to select the portion
of the domain over which to display the plot.
In many cases, particularly in 3D, more than one "ON" clause can be used for a single plot, since each
"ON" clause adds a restriction to those already in effect. There is a direct correspondence between
the "ON" clauses of a plot statement and the arguments of the various INTEGRAL 172 operators,
although some of the allowable integral selections do not have valid corresponding plot options.
In two dimensional geometries, area plots which are not otherwise restricted are assumed to be taken
over the entire problem domain.
Contours, "surfaces" (3D topographic displays), grid plots and vector plots must be taken on some
kind of two dimensional data surface, so in 3D problems these plot commands are incomplete without
at least one "ON" clause. This can be an extrusion-surface name, or a cut-plane equation (it cannot
be a projection-plane boundary path). For example, in a 3D problem,
CONTOUR(...) ON SURFACE 2
requests a contour plot of data evaluated on the second extrusion surface.
CONTOUR(...) ON SURFACE "top"
requests a contour plot of data evaluated on the extrusion surface named "top".
CONTOUR(...) ON X=Y
requests a contour plot of data evaluated on the cut plane where x=y.
In addition to a basic definition of the data surface, "ON" clauses may be used to restrict the display to
an arbitrary REGION or LAYER. In 2D, a REGION restriction will display only that part of the domain
which is in the stated region:
CONTOUR(...) ON REGION 2
requests a contour plot of data evaluated on REGION 2.
P roblem Descriptor Reference : The Sections of a Descriptor 256
Similarly, in 3D,
Cut Planes in 3D
Contours, surface plots and vector plots can also be specified on cut planes by giving the general
formula of the cutting plane:
CONTOUR(...) ON X = expression
requests a contour plot of data evaluated on the Y-Z plane where X is the specified value.
CONTOUR(...) ON X=Y
requests a contour plot of data evaluated on the plane containing the z-axis and the 45 degrees
line in the XY plane.
The coordinates displayed in oblique cut planes have their origin at the point of closest approach to
the origin of the domain coordinates. The axes are chosen to be aligned with the nearest domain
coordinate axes.
Elevation Plots
The plot will be displayed on the straight line connecting the specified endpoints. These endpoints
might span only a small part of the problem domain, or they might exceed the domain dimensions
somewhat, in which case the plot line will be truncated to the interior portion.
In 2D geometry only, an elevation plot may be specified by the name of a boundary path, as in
ELEVATION(...) ON "outer_boundary"
These boundary-path elevations can be additionally restricted as to the region in which the evaluation
is to be made:
257 FlexP DE 7 : P roblem Descriptor Reference
This form requests that the evaluation of the plot function be made in the region named "core", with the
assumption that "core" is one of the regions adjoining the "inner_boundary" path.
CONTOUR(...) ON GRID(Xposition,Yposition)
In many cases, boundary-path elevations present normal or tangential components of vectors. For
these applications, the sense of the direction is the same as the sense of the NATURAL boundary
condition:
The positive normal is outward from the evaluation region.
The positive tangent is counter-clockwise with respect to the evaluation region.
Plots of the normal components of vectors on extrusion surfaces in 3D follows the same rule:
The positive normal is outward from the evaluation region.
3.3.19.4 Reports
Any display specification can be followed by one or more of the following clauses to add report
quantities to the plot page:
REPORT expression
REPORT (expression)
Adds to the bottom of a display the text 'expression = value_of_expression'. Any valid
expression is accepted, including integrals. Multiple REPORT clauses may be used. REPORT is
especially useful for reporting boundary and area integrals and functions thereof.
REPORT 'string'
P roblem Descriptor Reference : The Sections of a Descriptor 258
REPORT ('string')
Inserts 'string' into the REPORT sequence.
The reserved word ERROR can be used to display the current state of spatial error estimates over the
mesh, as for example:
CONTOUR(ERROR)
When multiple MONITORS or PLOTS are listed, FlexPDE displays each one in a separate window and
automatically adjusts the window sizes to tile all the windows on the screen. Individual windows cannot
be independently resized or iconized. Any plot window can be maximized by double-clicking, or by
right-clicking to bring up a menu.
In steady-state and eigenvalue problems, MONITORS are displayed during solution, and are
replaced by PLOTS on completion.
In time-dependent problems, MONITORS, PLOTS and HISTORIES are displayed at all times.
In steady state problems the listed MONITORS are displayed after each regrid. In addition, after each
Newton-Raphson iteration of a nonlinear problem or after each residual iteration of a linear problem, if
sufficient time has elapsed since the last monitor display, an interim set of monitors will be displayed.
In time dependent problems the display specifications must be preceded by a display-time declaration
statement. The display-time declaration statement may be either of the form
in which case the displays will be refreshed every number time steps, or
In this case the displays will be refreshed at times specified by the timeset values.
Any number of plot commands can follow a display-time declaration, and the specification will apply to
259 FlexP DE 7 : P roblem Descriptor Reference
all of them. It is not necessary to give a display-time specification for each plot.
Multiple display time declaration statements can be used. When multiple display time statements are
used each applies to all subsequent display commands until a new time declaration is encountered or the
MONITORS or PLOTS section ends.
The the last time step may be referenced using the qualifier endtime :
FOR T = 0 BY 10 TO endtime
In the above example a plot would be generated every ten time units and at the last time step, whatever
was defined in the TIME section or whatever was the last time step due to a HALT condition.
Examples:
"Samples | Applications | Heatflow | Float_Zone.pde" 417
A right-click on any plot window, whether tiled or maximized, will bring up a menu from which the plot
may be printed or exported (or rotated, if this is meaningful for the plot).
Text listings of plotted values can be written to disk by the plot modifier EXPORT (aka PRINT) in the
descriptor.
Bitmaps
A right-click in any displayed plot window brings up a menu, one item of which is "Export". Clicking
this item brings up a dialog for exporting bitmap forms of the displayed plot. Current options are
BMP, PNG, PPM and XPM. See the "Getting Started" section for more information.
All these formats can also be selected automatically as graphic display modifiers 248 .
Retained Graphics
All displays in the PLOTS section are written in compressed form to a disk file with the extension
".PG7".
These files may be redisplayed at a later time by use of the "View" menu item in the "File" menu. On
some systems, this may be accomplished simply by double-clicking the ".PG7" file in the system file
manager.
See the "Getting Started" section for more information.
Screen Grabs
Any display may also be pasted into other windows programs by using a screen capture facility such
as that provided with PaintShopPro by JASC (www.jasc.com).
P roblem Descriptor Reference : The Sections of a Descriptor 260
Export Files
The plot types CDF, TABLE, TECPLOT and VTK 260 can be used to export data to other applications
for external processing. TRANSFER 261 and RESTART 260 can be used to transfer data to another
FlexPDE run for postprocessing.
See Graphics Display Specifications 246 and Exporting Data to Other Applications 137 for more
information.
Examples:
Requests for data export are included in the MONITORS or PLOTS sections as for graphic output. This
allows the control of when the export is performed in a standard way. A data export request may be
any of the following types:
RESTART ()
Requests the export of the listed values to a file readable by the TecPlot visualization system.
The output will be two or three dimensional, following the current coordinate system.
The entire mesh is exported.
If the FILE 250 modifier does not follow, then the output will be written to a file
"<problem>_<sequence>.dat".
Staged, eigenvalue and time-dependent problems will stack subsequent outputs in the same file,
consistent with TecPlot conventions.
TecPlot uses the actual triangular or tetrahedral computation mesh (subdivided to linear basis), so
material interfaces are preserved.
Requests the export of the listed values and finite element mesh data in a file readable by FlexPDE
using the TRANSFER or TRANSFERMESH 213 input command. This method of data transfer
between FlexPDE problems retains the full accuracy of the computation, without the error
introduced by the rectangular mesh of the TABLE function.
The exported domain cannot be zoomed.
If the FILE 250 modifier does not follow, then the output will be written to a file
"<problem>_<sequence>.xfr". This export format uses the actual computation mesh, so material
interfaces are preserved.
The full computation mesh is exported.
When used in Staged, Time dependent or Eigenvalue problems, each output file will be identified
by appending a sequence number to the file name.
TRANSFER files record the state of HISTORY plots. Problems restarted from a TRANSFER file will
restore the data sequence of HISTORY plots.
See TRANSFER File format 262 for a description of the data format.
"<problem>_<sequence>.dat".
TRANSFER6 files do NOT record the state of HISTORY plots. Problems restarted from a
TRANSFER file will have fragmented HISTORY plots.
See TRANSFER6 File format 266 for a description of the data format.
Requests the export of the listed values to a file in VTK (Visualization Tool Kit) format for display
by visualization systems such as VisIt.
The output will be two or three dimensional, following the current coordinate system.
The entire mesh is exported.
If the FILE modifier does not follow, then the output will be written to a file
"<problem>_<sequence>.vtk".
Staged, eigenvalue and time-dependent problems will produce a family of files distinguished by the
sequence number.
VTK format uses the actual triangular or tetrahedral computation mesh, so material interfaces are
preserved.
The VTK format supports quadratic finite element basis directly, but not cubic. To export from
cubic-basis computations, use VTKLIN.
The format of a TRANSFER file is dictated by the TRANSFER output format, and contains the following
data.
(Note that the file format for Version 7 is different than that for previous versions. The new keyword
TRANSFER6 can be used to write files in the old format. The TRANSFER import facility will
automatically recognize the file type and import correctly for either.)
1) A identifying section enclosed in comment brackets, { ... } and containing the following:
a) the exporting FlexPDE version and date
b) the generating problem name and run time
c) the problem title
d) the list of quantities reported in the file.
2) A file identifier "FlexPDE v700 transfer file". The version number listed here will determine which file
format is to be read on import.
263 FlexP DE 7 : P roblem Descriptor Reference
6) The geometric basis (which may be different than the solution basis)
9) A FLAG specification, showing the number of flags and their values. This row may change in later
versions, but will not alter the readability of the file. Currently defined flags are:
a) Curvegrid, which allows curved cell sides where required by boundary definitions
b) Curveall, which forces curved cell sides for all cells in the mesh
10) The total number of degrees of freedom in the mesh (number of interpolation coefficients per
variable).
12) The number of output quantities and their names, one per line. Global quantities also define the
value.
13) The number mesh control definitions that follow, one line each.
14) The number of domain joints (boundary break points) and their descriptions, one per line, defining:
Joint number
Periodic image joint (or 0)
Associated mesh node number
Extrusion surface (or 0)
Active flag
Mesh density control indices (parenthesized)
15) The number of domain edges and their descriptions, one per line, defining:
Edge number
Associated base plane edge number
Beginning joint number
P roblem Descriptor Reference : The Sections of a Descriptor 264
16) The number of 3D domain faces (3D only) and their descriptions, including
Face number
Associated base plane face number
Left adjoining Region number
Right adjoining Region number
Periodic image face (or 0)
Shape selector (face extrusion, edge extrusion, CAD face or 0)
Layer or surface number
Active and Contact flags
Face name
Mesh density control indices (parenthesized)
Unlike previous versions, version 7 ascribes nodes only to the mesh vertices. There are no midside or
midface nodes. The nodal coefficients define a linear (order=1) approximation to the described quantity.
This is then supplemented by quadratic and cubic coefficients which are ascribed to Sides (2D), Legs
(3D), or Cells (cubic models). Interpolation coefficients for the entire mesh are numbered sequentially,
and each may be associated with a Node, a Side, a Leg, or a Cell. Exported mesh data are then as
follows.
1) The number of Nodes. Nodes are numbered sequentially as they are created by the mesh generator.
2) The nodal descriptions, containing one line for each mesh node with the following format:
the node number
one, two or three spatial coordinates
265 FlexP DE 7 : P roblem Descriptor Reference
3) The number of Sides, a referencing flag and an imaging flag. Sides are numbered sequentially as they
are created by the mesh generator. In 2D a Side is the leg of a triangle. In 3D a Side is a tetrahedral
face.
4) The side descriptions, one line per side, listing the following:
the side number
a packed flag word (1=warped; 2=periodic; 4=contact; 16=joint; 32=edge; 48=face;
64=exterior)
the boundary identifier
the geometric bulge (2D only)
the reference node (if referencing)
the image side (if imaging)
the coefficient indices associated with this side (varying numbers, depending on
dimension and order).
5) The number of Legs (3D only) and a referencing flag. Legs are numbered sequentially as they are
created by the mesh generator.
6) The leg descriptions, one line per side, listing the following:
the leg number
a packed flag word (1=warped; 32=edge; 48=face; 64=exterior)
the face identifier
the geometric bulge (3D only)
the reference node (if referencing)
the coefficient indices associated with this side (varying numbers, depending on
dimension and order).
7) The number of cells. Cells are numbered sequentially as they are created by the mesh
generator.
8) The cell connectivity data, one line per cell, listing the following:
the cell number
a packed flag word (1=bounding; 2=warped)
the node numbers of the vertices (2 in 1D, 3 in 2D, 4 in 3D)
the side numbers of the sides (none in 1D, 3 in 2D, 4 in 3D)
the leg numbers (3D only)
the neighboring cell numbers (corresponding to listed sides)
the region number and material number of the containing region
the coefficient indices associated with this cell (varying numbers, depending on
P roblem Descriptor Reference : The Sections of a Descriptor 266
Each distinct material type in the exported problem is represented by a separate section in the
TRANSFER file. Material types are defined by matching parameter definitions. Each coefficient has one
value for each of the field quantities exported (global quantities do not appear). Coefficients shared
between adjoining materials will appear once in each material group. The values reported may be
different, if the coefficient lies on a contact boundary.
2) The coefficient data, containing one line for each coefficient with the following format:
the coefficient number.
one value for each of the exported quantities.
If the exporting problem has assembled data for the creation of HISTORY plots, that data will be
recorded in the TRANSFER file, so that an importing problem can present the full history. This segment
of the file contains the following data:
1) The number of Histories and the number of times recorded.
2) The list of times at which data have been recorded.
3) The History blocks, one for each History, containing the following data:
o The History number, together with number of functions, the number of "at" points, the start time, the
time window, the window start, the window end, the instance count and the axis length (if plot was
"vs" a quantity other than time)
o If the History was "Versus" some axis other than time, the list of axis values
o The evaluation expressions for the requested "at" points, one line per function.
o The history data, one block for each output function. Each block contains:
i. The evaluation expression for the requested output function.
ii. The history values for the output function.
The format of a TRANSFER6 file is identical to the version 6 output format, and contains the following
data.
267 FlexP DE 7 : P roblem Descriptor Reference
1) A header containing an identifying section listing the FlexPDE version, generating problem name and
run time, and plotted variable name or function equation. This header is enclosed in comment brackets,
{ ... }.
8) The number of domain joints (boundary break points) and their descriptions, including
Joint number
Periodic image joint (or 0)
Associated global node number
Extrusion surface (or 0)
Active flag
Each distinct material type in the exported problem is represented by a separate section in the
TRANSFER file. Material types are defined by matching parameter definitions. Each data section
consists of:
2) The nodal data, containing one line for each node with the following format:
two or three coordinates and as many data values as specified in (7).
a colon (:)
the global node index
the node type (0=interior; 1=joint; 2=edge; 3=face; 4=exterior)
the type qualifier (region number, joint number, edge number or face number)
the periodic node index
4) The cell connectivity data, one line per cell, listing the following:
the geometric basis (as in Header 4)
the node numbers (local to the current material block) which comprise the cell. The
count of these node numbers is controlled by (Header 5).
a colon (:)
the global cell number
the logical region number
269 FlexP DE 7 : P roblem Descriptor Reference
3.3.19.12 Ex am ples
See the sample problem Samples | Usage | Plotting | Plot_test.pde 633 for examples of PLOTS and
MONITORS.
See the sample problem Samples | Usage | Plotting | Print_test.pde 631 for examples of exporting plot
data.
See the sample problem Samples | Usage | Import-Export | Export.pde 566 for examples of exports
without display.
See the sample problem Samples | Usage | Import-Export | Export_Format.pde 566 for examples of
formatted exports without display.
See the sample problem Samples | Usage | Import-Export | Export_History.pde 567 for examples of
exports of history data.
P roblem Descriptor Reference : The Sections of a Descriptor 270
3.3.20 Histories
The HISTORIES section, which is optional, specifies values for which a time history is desired. While
multiple HISTORY statements can be listed they must all be of the form:
HISTORY ( arg1 [ ,arg2,...] )
HISTORY ( arg1 [ ,arg2,...] ) AT (X1,Y1) [ (X2,Y2)...]
The coordinates specify locations in the problem at which the history is to be recorded. If no coordinate
is given, the arg must evaluate to a scalar.
The modifiers and reports available to PLOTS and MONITORS may also be applied to HISTORY
statements.
The display of HISTORIES i s controlled by the AUTOHIST select switch, which defaults to ON. With
the default setting all HISTORIES are automatically refreshed and displayed with the update of any
MONITORS or PLOTS.
If desired, HISTORY statements can be included directly in the MONITORS section or PLOTS section.
Histories in Staged Problems
HISTORY statements may be used in STAGED problems as well as in time-dependent problems.
In this case, the default abscissa will be stage number. You can select a different value for the
abscissa quantity by appending the clause
VERSUS expression
In this case, the values of the given expression in the various stages will be used as the plot axis.
HISTORY plots by default display the total time range of the problem run. Specific time ranges can
be specified in several ways. A global window specifier can be set in the SELECT section:
This command causes all histories to display only the most recent time interval of the data.
Individual HISTORY plots can be windowed by the two plot qualifier forms:
WINDOW = time selects a moving window containing the most recent time interval
WINDOW ( time1 , selects a fixed time range, plotting the time between time1 and
time2 ) time2
See the sample problem "Samples | Usage | Two_Histories.pde" 603 for an example.
271 FlexP DE 7 : P roblem Descriptor Reference
3.3.21 End
All problem descriptors must have an END section.
With the exception of a numeric enabling key used in special demonstration files prepared by PDE
Solutions Inc., anything appearing after the reserved word end is ignored by FlexPDE and treated as a
comment.
Problem notes can be conveniently placed after the reserved word END.
A single "section" introduced by the word BATCH identifies a descriptor as a batch control file.
Following this header, a sequence of names appears, each name enclosed in quote marks. Commas
may optionally be used to separate the names. Any number of names may appear on each line of the
descriptor. Each name is the name of a problem descriptor to be run. Names may include directory
paths, which are assumed to originate in the directory containing the batch descriptor. The ".pde"
extension is not required, and will be assumed if omitted. The list should be closed with an END
statement.
Example:
BATCH
{ FlexPDE will accept either \ or / as a separator }
"misc\table", "steady_state\heat_flow\slider"
"steady_state/stress/3d_bimetal"
END
The entire problem list is examined immediately, and any syntax errors in the names are reported. All files
named in the list are located, and missing files are reported before any processing begins.
Each problem named in the list is run to completion in sequence. As the problems run, status information
is written to a log file in the directory containing the batch descriptor. This file has the same name as the
batch descriptor, with the extension "_log.txt", and all problems in the list are summarized in this single
file. Graphical output from each problem is written as usual to a unique ".pg7" file in the directory with
the specific descriptor. After the run is completed, this graphic output may be reviewed by restarting
FlexPDE and using the VIEW 26 menu item.
Simple names may be listed without the quotes, but in this case embedded spaces, path separators,
reserved words and numeric initials will all cause error diagnostics.
An optional SELECT 183 section may be placed immediately following the BATCH identifier. Most
P roblem Descriptor Reference : Batch P rocessing 272
selectors set in the section will be used as the default value for all scripts run by the batch. These values
will not override values set explicitly by the individual scripts.
Example:
BATCH
SELECT ngrid=10
...
END
An optional DELAY value may be set immediately following the BATCH identifier. This delay value
specifies the number of seconds to wait prior to starting the next problem in the sequence.
Example:
BATCH
DELAY = 3
...
END
The batch can be terminated before completion by using the "Stop Batch" item in the Controls Menu 10 .
Part
IV
Technical Notes
Technical Notes : Natural Boundary C onditions 274
4 Technical Notes
4.1 Natural Boundary Conditions
The NATURAL boundary condition 82 is a generalization of the concept of a flux boundary condition.
In diffusion equations, it is in fact the outward flux of the diffusing quantity. In stress equations, it is the
surface load. In other equations, it can be less intuitive.
FlexPDE uses integration by parts to reduce the order of second derivative terms in the system
equations.
Application of this technique over a two-dimensional computation cell produces an interior area integral
term and a boundary line integral term. Forming the same integral in two adjacent computation cells
produces the same boundary integral at their interface, except that the direction of integration is opposite
in the two cells. If the integrals are added together to form the total integral, the shared boundary
integrals cancel.
Applied to the term dx(f), where f is an expression containing further derivative terms, integration
by parts yields
Integral(dx(f)*dV) = Integral(f*c*dS),
where c denotes the x-component of the outward surface-normal unit vector and dS is the
differential surface element.
(Y- and Z- derivative terms are handled similarly, with c replaced by the appropriate unit-vector
component.)
Applied to the term dxx(f), where f denotes a scalar quantity, integration by parts yields
Integral(dxx(f)*dV) = Integral(dx(f)*c*dS),
where c denotes the x-component of the outward surface-normal unit vector and dS is the
differential surface element.
(Y- and Z- derivative terms are handled similarly, with c replaced by the appropriate unit-vector
component.)
Applied to the term DIV(F), where F denotes a vector quantity containing further derivative terms,
integration by parts is equivalent to the divergence theorem,
Integral(DIV(F)dV) = Integral(F . n dS),
where n denotes the outward surface-normal unit vector and dS is the differential surface element.
Applied to the term CURL(F), where F denotes a vector quantity containing further derivative terms,
integration by parts is equivalent to the curl theorem,
Integral(CURL(F) dV) = Integral(n x F dS),
where again n denotes the outward surface-normal unit vector and dS is the differential surface
element.
FlexPDE performs these integrations in 3 dimensions, including the volume and surface elements
appropriate to the geometry. In 2D Cartesian geometry, the volume cell is extended one unit in the
Z direction; in 2D cylindrical geometry, the volume cell is r*dr*dtheta.
275 FlexP DE 7 : Technical Notes
This technique forms the basis of the treatment of exterior boundary conditions and interior material
interface behavior in FlexPDE.
All boundary integral terms are assumed to vanish at internal cell interfaces.
All boundary integral terms are assumed to vanish at internal and external boundaries, unless a
NATURAL boundary condition statement provides an independent evaluation of the boundary
integrand.
Note that it is not necessary to write the equations explicitly with the DIV or CURL operators for these
conditions to be met. Any valid differential equivalent in the coordinate system of the problem will be
treated the same way.
Note also that the NATURAL boundary condition and the PDE are intimately related.
If a differential operator has an argument that itself contains a differential operator, then that
argument becomes the object of integration by parts, and generates a corresponding component of
the NATURAL boundary condition.
If the PDE is multiplied by some factor, then the associated NATURAL boundary condition must be
multiplied by the same factor.
The NATURAL boundary condition must have a sign consistent with the sign of the associated PDE
terms when moved to the left side of the equation.
The NATURAL boundary condition statement specifies to FlexPDE the integrand of the surface
integral generated by the integration by parts, which is otherwise assumed to be zero.
Technical Notes : Solving Nonlinear P roblems 276
In nonlinear systems, we are not guaranteed that the system will have a unique solution, and even if it
does, we are not guaranteed that FlexPDE will be able to find it. The solution method used by FlexPDE
is a modified Newton-Raphson iteration procedure. This is a "descent" method, which tries to fall down
the gradient of an energy functional until minimum energy is achieved (i.e. the gradient of the functional
goes to zero). If the functional is nearly quadratic, as it is in simple diffusion problems, then the method
converges quadratically (the relative error is squared on each iteration). The default strategy
implemented in FlexPDE is usually sufficient to determine a solution without user intervention.
Time-Dependent Problems
In nonlinear time-dependent problems, the default behavior is to compute the Jacobian matrix (the
"slope" of the functional) and take a single Newton step at each timestep, on the assumption that any
nonlinearities will be sensed by the timestep controller, and that timestep adjustments will guarantee an
accurate evolution of the system from the given initial conditions.
Several selectors are provided to enable more robust (but more expensive) treatment in difficult cases.
The "NEWTON=number" selector can be used to increase the maximum number of Newton iterations
performed on each timestep. In this case, FlexPDE will examine the change in the system variables and
recompute the Jacobian matrix whenever it seems warranted. The Selector REMATRIX=ON will force
the Jacobian matrix to be re-evaluated at each Newton step.
The PREFER_SPEED selector is equivalent to the default behavior, setting NEWTON=1 and
REMATRIX=Off .
The PREFER_STABILITY selector resets the values of NEWTON=3 and REMATRIX=On.
Steady-State Problems
In the case of nonlinear steady-state problems, the situation is somewhat more complicated. The default
controls are usually sufficient to achieve a solution. The Newton iteration is allowed to run a large
number of iterations, and the Jacobian matrix is recomputed whenever the change in the solution values
seem to warrant it. The Selector REMATRIX=On may be used to force re-computation of the Jacobian
matirx on each Newton step.
In cases of strong nonlinearities, it may be necessary for the user to help guide FlexPDE to a valid
solution. There are several techniques that can be used to help the solution process.
Start with a Good Initial Value
Providing an initial value which is near the correct solution will aid enormously in finding a solution. Be
particularly careful that the initial value matches the boundary conditions. If it does not, serious
excursions may be excited in the trial solution, leading to solution difficulties.
277 FlexP DE 7 : Technical Notes
FlexPDE uses the method of subspace iteration (see Bathe and Wilson, "Numerical Methods in Finite
Element Analysis", Prentice-Hall, 1976) to solve for a selected number of eigenvalues of lowest
Technical Notes : Eigenvalues and Modal Analysis 278
magnitude. In this method, the full problem is projected onto a subspace of much smaller dimension,
and the eigenvalues and eigenvectors of this reduced system are found. This process is repeated until
convergence of the eigenvalues is achieved. The eigenvectors of the full system are then recovered from
expansion of the eigenvectors of the reduced system. As in a power-series expansion, there is some loss
of accuracy in the higher modes due to truncation error. For this reason, FlexPDE solves a subspace of
dimension min(n+8,2*n), where n is the number of requested modes.
See the eigenvalue examples 538 for demonstrations of this use of FlexPDE.
Eigenvalue Shifting
It is possible to examine eigenmodes which do not correspond to eigenvalues of the smallest magnitude
by the technique of eigenvalue shifting. Consider the two systems
L(u) + lambda*u = 0
And
L(u) + lambda*u + shift*u = 0.
These systems will have the same eigenvectors as those associated with eigenvalues of "lambda+shift" in
the original system. Given the latter problem, FlexPDE will find a set of eigenvalues corresponding to the
eigenvalues closest above "shift" in the spectrum of the former problem. The sum "lambda+shift" will
correspond to the eigenvalue in the former system.
Steady-State
The finite element model used in FlexPDE assumes that all variables are continuous throughout the
problem domain. This follows from the fact that the mesh nodes that sample the values of the variables
are shared between the cells that they adjoin. Internally, the solution variables are interpolated by low-
order polynomials over each cell of the finite element mesh. A discontinuous change in boundary
conditions along the boundary path, particularly between differing VALUE conditions, will require intense
mesh refinement to resolve the transition.
Whenever possible, use RAMP 165 , URAMP 163 , SWAGE 167 , part of a sine or supergaussian, or some
other smooth function to make a transition in value conditions over a physically meaningful distance.
If the quantity you have chosen as a system variable is in fact expected to be discontinuous at an
interface, consider choosing a different variable which is continuous, and from which the real variable can
be computed.
279 FlexP DE 7 : Technical Notes
Time-Dependent
It is a common tendency in posing problems for numerical solution to specify initial conditions or
boundary conditions as discontinuous functions, such as "at time=2 seconds, the boundary temperature is
raised instantaneously to 200 degrees." A little thought will reveal that such statements are totally
artificial. They violate the constraints of physics, and they pose impossible conditions for numerical
solution. Not quite so obvious is the case where a boundary condition is applied at the start of the
problem which is inconsistent with the initial values. This is in fact a statement that "at time=0 the
boundary temperature is raised instantaneously to a new value", and so is the same as the statement
above.
To raise a temperature "instantaneously" requires an infinite heat flux. To move a material position
"instantaneously" requires an infinite force. In the real world, nothing happens "instantaneously".
Viscosity diffuses velocity gradients, elastic deformation softens displacement velocities, thermal diffusion
smoothes temperature changes. At some scale, all changes in nature are smooth.
In the mathematical view, the Fourier transform of a step function is (1/frequency). This means that a
discontinuity excites an infinite spectrum of spatial and temporal frequencies, with weights that diminish
quite slowly at higher frequencies. An "accurate" numerical model of such a system would require an
infinite number of nodes and infinitesimal time steps, to satisfy sampling requirements of two samples per
cycle. Any frequency components for which the sampling requirement is not met will be modeled wrong,
and will cause oscillations or inaccuracies in the solution.
How then have numerical solutions been achieved to these problems over the decades? The answer is
that artificial numerical diffusion processes have secretly filtered the frequency spectrum of the solution to
include only low-frequency components. Or the answers have been wrong. Right enough to satisfy the
user, and wrong enough to satisfy the calculation.
It is useful in this context to note that the effect of a diffusion term D*div(grad(U)) is to apply an
attenuation of 1/(1+D*K*K) to the K-th frequency component of U. Conversely, any side effect of a
numerical approximation which damps high frequency components is similar to a diffusion operator in the
PDE.
We have attempted in FlexPDE to eliminate as many sources of artificial solution behavior as possible.
Automatic timestep control and adaptive gridding are mechanisms which try to follow accurately the
solution of the posed PDE. Discontinuities cannot be accurately modeled, and are therefore, strictly
speaking, ill-posed problems. They cause tiny timesteps and intense mesh refinement in the early phases,
causing long running times.
It may seem like an imposition that we should require such adulteration of your pure PDE, but the
alternative is that we apply these adulterations behind your back, in unknown quantities and with
unknown affect on your solution. At least this way, you're in control.
4.5 Extrusions in 3D
The specification of three-dimensional geometries as extrusions in FlexPDE is based on the
decomposition of the object into two parts:
The projection of the object onto the base X-Y plane.
The division of the extrusion of this projection into layers in the Z dimension.
Let us take as a model a sandwich formed by a layer of dielectric material with two rectangular
conductive patches, top and bottom, with differing dimensions. We wish to model the dielectric, the
conductive patches and the surrounding air.
First, we form the projection of this figure onto the X-Y plane, showing all relevant interfaces:
281 FlexP DE 7 : Technical Notes
The geometry is specified to FlexPDE primarily in terms of this projection. A preliminary description of
the 2D base figure is then:
BOUNDARIES
REGION 1 {this is the outer boundary of the system}
START(0,0)
LINE TO (5,0) TO (5,5) TO (0,5) TO CLOSE
REGION 2 {this region overrides region 1 and describes the larger plate}
START(1,0)
LINE TO (4,0) TO (4,5) TO (1,5) TO CLOSE
REGION 3 {this region overrides region 1 & 2 and describes the smaller plate}
START(2,0)
LINE TO (3,0) TO (3,5) TO (5,3) TO CLOSE
Note that any part of the projection which will have a different stack of material properties above it must
be represented by a region. All parts of the projection which will have the same stack of material
properties may be included in a single region, even though they may be disjoint in the projection.
EXTRUSION
SURFACE "Bottom" Z=0
LAYER "Bottom Air"
SURFACE "Bottom Air - Metal" Z=0.9
LAYER "Bottom Metal"
SURFACE "Bottom Metal - Dielectric" Z=1
LAYER "dielectric"
SURFACE "Top Metal - Dielectric" Z=2
LAYER "Top Metal"
SURFACE "Top Metal - Air" Z=2.1
LAYER "Top Air"
SURFACE "top" Z=3
The LAYER statements are optional, as are the names of the surfaces. If surfaces and layers are not
named, then they must subsequently be referred to by numbers, with surface numbers running in this case
from 1 to 6 and layer numbers from 1 to 5. SURFACE 1 is Z=0, and LAYER 1 is between SURFACE 1
and SURFACE 2.
DEFINITIONS
K = Kair {default the dielectric coefficient to the value for air}
Kdiel = 999 {replace 999 with problem value}
Kmetal = 999 {replace 999 with problem value}
EQUATIONS
283 FlexP DE 7 : Technical Notes
DIV(K*GRAD(V))
We now modify the BOUNDARIES section to include layering information in the various regions:
BOUNDARIES
REGION 1 {this is the outer boundary of the system}
LAYER "Dielectric" K = Kdiel {all other layers default to Kair}
START(0,0)
LINE TO (5,0) TO (5,5) TO (0,5) TO CLOSE
REGION 2 {this region overrides region 1 and describes the larger plate}
LAYER "Bottom Metal" K = Kmetal
LAYER "Dielectric" K = Kdiel
START(1,0)
LINE TO (4,0) TO (4,5) TO (1,5) TO CLOSE
REGION 3 {this region overrides region 1 & 2 and describes the smaller plate}
LAYER "Bottom Metal" K = Kmetal
LAYER "Dielectric" K = Kdiel
LAYER "Top Metal" Kmetal
START(2,0)
LINE TO (3,0) TO (3,5) TO (5,3) TO CLOSE
If layers are not named, then layer numbers must be used in place of the names above. The LAYER
specifiers act as group headers, and all definitions following a LAYER specification refer to that layer, until
the group is broken by SURFACE, LAYER or START . Definitions which apply to all layers of the region
must appear before any LAYER specification.
BOUNDARIES
REGION 1 { this is the outer boundary of the system }
LAYER "Dielectric" K = Kdiel { all other layers default to Kair }
START(0,0)
LINE TO (5,0) TO (5,5) TO (0,5) TO CLOSE
REGION 2 { this region overrides region 1, and describes the larger plate }
LAYER "Bottom Metal" K = Kmetal
LAYER "Dielectric" K = Kdiel
START(1,0)
LAYER "Bottom Metal" VALUE(V)=V0
LINE TO (4,0)
LAYER "Bottom Metal" NATURAL(V)=0
LINE TO (4,5) TO (1,5) TO CLOSE
REGION 3 { this region overrides regions 1&2, and describes the smaller
plate}
LAYER "Bottom Metal" K = Kmetal
Technical Notes : Extrusions in 3D 284
The final requirement for boundary condition specification is the attachment of boundary conditions to the
X-Y end faces of the extruded figure. This is done by the SURFACE modifier. Suppose we wish to
force the bottom surface to V=0 and the top to V=1. We would modify the descriptor as follows:
BOUNDARIES
SURFACE "Bottom" VALUE(V)=0
SURFACE "Top" VALUE(V)=1
REGION 1 { this is the outer boundary of the system }
LAYER "Dielectric" K = Kdiel { all other layers default to Kair }
START(0,0)
LINE TO (5,0) TO (5,5) TO (0,5) TO CLOSE
REGION 2 { this region overrides region 1, and describes the larger plate }
LAYER "Bottom Metal" K = Kmetal
LAYER "Dielectric" K = Kdiel
START(1,0)
LAYER "Bottom Metal" VALUE(V)=V0
LINE TO (4,0)
LAYER "Bottom Metal" NATURAL(V)=0
LINE TO (4,5) TO (1,5) TO CLOSE
REGION 3 { this region overrides regions 1&2, and describes the smaller plate}
LAYER "Bottom Metal" K = Kmetal
LAYER "Dielectric" K = Kdiel
LAYER "Top Metal" K = Kmetal
START(2,0)
LINE TO (3,0) TO (3,5)
LAYER "Top Metal" VALUE(V)=V1
LINE TO (2,5)
LAYER "Top Metal" NATURAL(V)=0
LINE TO CLOSE
Observe that since the SURFACE statements lie outside any REGION specification, they apply to all
regions of the surface. To specialize the SURFACE statement to a specific region, it should be included
within the REGION definition.
In this example, we have used named surfaces and layers. The same effect can be achieved by omitting
the layer names and specifying layers and surfaces by number:
BOUNDARIES
SURFACE 1 VALUE(V)=0
SURFACE 6 VALUE(V)=1
REGION 1 { this is the outer boundary of the system }
LAYER 3 K = Kdiel { all other layers default to Kair }
START(0,0)
285 FlexP DE 7 : Technical Notes
Remember that in our terminology a REGION refers to an area in the projected base plane, while a
LAYER refers to a section of the Z-extrusion. A particular 3D chunk of the figure is uniquely identified by
the intersection of a REGION and a LAYER.
A completed form of the descriptor outlined here may be found in the sample problem "Samples | Usage
| 3D_Domains | 3D_Extrusion_spec.pde". A slightly more complex and interesting variation may be
found in "Samples | Applications | Electricity | 3D_Capacitor.pde".
On layer 0, enter as text the entire body of the problem description, excluding the BOUNDARIES
section.
Use one layer for each region of the problem. Draw on each layer the boundaries pertaining to that
region. Enter as text on each layer the necessary regional definitions for that region. For
boundaries that are shared between regions, be sure that the points are recognizably the same
(within 1e-6*domain size). Snap-to-grid is advised.
Enter as text the necessary boundary conditions. Place the text so that the insertion point is near the
boundary to which the boundary condition applies.
Export the drawing as a DXF file in R14 format.
You may chose to modify the translated .PDE file, or to continue to update the .DXF file, whichever is
most convenient for your needs.
Examples:
See the sample problem "Samples | Usage | Import-Export | AcadSample.dxf" and its associated
drawing file AcadSample.dwg.
To have FlexPDE automatically generate a basic starting script file to import the OBJ mesh, do the
following :
Select the "Import->OBJ 3D" item from the "File" menu. Browse to the desired OBJ file and click
"Open". (Alternatively, you may use the "Open" menu item and switch the file filter to "OBJ"). This will
create a basic script file with the appropriate sections for the import process. This step is optional and
may be skipped once you have familiarity with the script grammar for importing OBJ files.
Add the sections VARIABLES 195 , EQUATIONS 217 , and PLOTS 245 .
Modify the MATERIALS 215 and BOUNDARY CONDITIONS 216 sections as needed.
287 FlexP DE 7 : Technical Notes
Note : FlexPDE will use flat-sided tetrahedra when creating computation meshes from
imported OBJ surface meshes. It will not curve the sides as in self constructed surface meshes.
Since there are no REGIONS 229 or boundary paths 226 stated in the script when you import an OBJ mesh
file, we have provided two new sections for defining material property sets and boundary condition sets.
They are the MATERIALS 215 and BOUNDARY CONDITIONS 216 sections.
In a normal script these definitions can be used in the normal flow with USE MATERIAL "name" and USE
BC "name". In order to use them in your OBJ import you have to label and group some items in the OBJ
file (usually before exporting from the CAD program, although it can be reopened and patched up by
hand if needed).
In order to apply material parameters to a given object, simply select the complete bounding mesh of that
object and name it. That name will be used to apply a parameter set definition. If you name the object
"box" then a MATERIAL named "box" must be present in the FlexPDE script.
In order to apply a BC to a set of mesh cells (like the side of a box) you will need to extract those cells
from the closed mesh, group them, and name the group. The group name will be used to apply a BC set
definition. If you name the group "right side" then a BOUNDARY CONDITION named "right side" must be
present in the FlexPDE script.
Try and get a uniform mesh created in the CAD program. It is easy to get a mesh with large long skinny
cells very close to other small cells. FlexPDE7 does a pre-process pass where it will split cells in order
to make them more uniform, but it is better to try and get uniformity from the CAD mesh generator first.
FlexPDE will accept triangular and square cells from the OBJ mesh, but it is better to make them
triangular in the CAD program before exporting the OBJ file. FlexPDE will divide a square cell into four
cells, whereas in the CAD program you can divide them into two. The reason for FlexPDE dividing into
four is related to matching up common cell faces and their normals on faces shared between objects.
The normals of the cells will need to be directed outward. This is the default for most CAD programs
when creating a mesh from closed objects. If you make an object from pieces, you will need to make
sure the normals point outward.
Create two objects one inside the other. Invert the normals of the inside object. Name them as the same
object.
Technical Notes : Importing OBJ Files 288
Examples:
Samples | Usage | CAD_Import | cube_OBJimport.pde 518 - the most basic usage of the OBJ import.
Samples | Usage | CAD_Import | cube2_OBJimport.pde 518 - two objects with a shared face.
Samples | Usage | CAD_Import | helix_OBJimport.pde 522 - a stress model of a coil.
Samples | Usage | CAD_Import | boxinbox_OBJimport.pde 517 - void volume.
Samples | Usage | CAD_Import | horn_OBJimport.pde 523 - random crazy shape.
See all the other examples in the "Samples | Usage | CAD_Import" directory.
Please see the supplementary YouTube videos on OBJ mesh construction and import :
www.youtube.com/playlist?list=PLfkFm0BfPLmw_hxfw7KSBCt-xqaxyaYB0
I. Maxwell's Equations
The purpose of this note is to develop formulations for the application of FlexPDE to various problems in
electromagnetics. It is not our intention to give a tutorial on electromagnetics; we assume that the reader
has some familiarity with the subject, and has access to standard references.
The starting point for our discussion is, as usual, Maxwell's equations:
v
v v D
(1) H J
t
v
(2) gB 0
v
v B
(3) E
t
v
(4) gD
To these we add the constitutive relations
v v
(5) D E
v v
(6) B H
v v
(7) J E
(In isotropic materials, , and are scalars, possibly nonlinear. In more complex materials, they
may be tensors. In studies involving hysteresis or permanent magnets, modifications must be made to
equation (6))
289 FlexP DE 7 : Technical Notes
A constraint due directly to the Finite Element model used in FlexPDE strikes us at the very outset.
FlexPDE uses a continuous piecewise polynomial representation of all model variables. That is, at each
computational node in the system it is assumed that each variable takes on a unique value, and that these
nodal values can be connected in space by polynomial interpolations.
Application of the Divergence Theorem and Stokes' Theorem to Maxwell's equations yield the following
boundary rules at material interfaces.
v v v
The tangential component of E is continuous; the normal component of D E is
continuous (in the absence of surface charges).
v
The tangential component of H is continuous (in the absence of surface current); the normal
v v
component of B H is continuous.
These rules are in general inconsistent with the model assumptions of FlexPDE. This means that the field
components themselves cannot be chosen as the model variables unless one of the following conditions
applies:
For example, if we know that in a specific configuration that all the electric fields must be tangential to the
v
material interfaces, we can use E as a model variable. If we know instead that all the electric fields are
v
normal to the material interfaces, we can use D as a model variable.
The analysis of fields in terms of the field components comprises the bulk of textbook treatments, and we
will not pursue the topic further here. We will instead turn our attention to a more generally applicable
modeling approach. Nevertheless, despite the seemingly restrictive nature of these prohibitions, there is
a large class of problems which can be analyzed successfully by FlexPDE in terms of field components.
Technical Notes : Applications in Electromagnetics 290
III. Potentials
v v
For any twice-differentiable vector v , the vector identity v 0 holds. This identity together
v
with equation (2) implies that we can define a vector potential function A , the magnetic vector potential,
such that
v v
(9) A B
A theorem due to Helmholtz states that a vector field can be uniquely defined only by specifying both its
curl and its divergence. We must remain aware, therefore, that at this point our vector potential is
v
incompletely determined. The arbitrariness of A is frequently exploited to simplify the equations.
v
In many cases, it is not necessary to explicitly specify A , allowing the boundary conditions and the
artifacts of the computational model to define it by default.
v v
Substituting relation (9) into equation (3) gives E A 0 . Another vector identity states
t
that 0 for any twice differentiable scalar . This allows us to define a scalar potential
function V such that
v v
(10) E V A
t
In the absence of time variation, V is seen to be the electrostatic potential.
Application of Faraday's Law to a pillbox on a material interface shows that V must be continuous
v
across material interfaces. Application of Stokes' Theorem to A shows that the tangential component
v v
of A must be continuous across material interfaces. All the conventional definitions of A also
v
have the property that the normal component of A is continuous across material interfaces. Therefore,
v
formulations in terms of V and A completely satisfy the modeling assumptions of FlexPDE.
Since the two definitions (9) and (10) satisfy equations (2) and (3), we are left with Maxwell's equations
v
(1) and (4), which in terms of A and V are:
v v 2
v
A A A
(11) V V 0
t t2 t
v
A
(12) V 0
t
v
A
At this point, it is customary in the literature to apply vector identities to convert the into
v v
a form containing A , so that a complete definition of A can be achieved. In fact, these
transformations require that be continuous across material interfaces. We therefore defer this
291 FlexP DE 7 : Technical Notes
operation for discussion under the appropriate specializations to follow. We should also point out that in
v v
(11) we have substituted (7) J E , a substitution we may later wish to rescind.
FlexPDE uses the Divergence Theorem and its related Curl Theorem to reduce the order of second
derivative terms, and assumes that the resulting surface integrals vanish at internal boundaries. Applied to
v
(12), this process results in the continuity of the normal component of D , as required by boundary rule
v
1). Applied to (11), this process results in the continuity of the tangential component of H , as required
by boundary rule 2).
At exterior boundaries, the Natural boundary condition specifies the value of the integrand of the surface
v
integrals. For equation (11) this means the tangential component of H , while for equation (12) it means
v
the normal component of D .
1. Symmetry planes
Following the above definition of the natural boundary condition, the specification "NATURAL(V)=0"
v
for equation (12) means that the normal component of D is zero. This means that field lines must be
parallel to the system boundary and that potential contours must be normal to the boundary. These are
the conditions of a symmetry plane.
Similarly, if we specify "NATURAL(A)=0" for equation (11), we require that the tangential component
v
of H be zero. This says that field lines and potential contours must be normal to the boundary, which is
again the condition of a symmetry plane.
2. Perfect conductors
Since a perfect conductor cannot sustain a field, the boundary condition "VALUE(V)=constant" for
equation (12) defines a perfectly conducting boundary. Note that since equation (12) contains only
derivatives of V, an arbitrary constant value may be added to the solution without affecting the equation.
In order for a numerical solution to succeed, there must be some point in the domain at which a value
condition is prescribed, in order to make the potential solution unique.
v
Similarly, the specification "VALUE(A)=constant" for equation (11) forces the normal component of H
v
to be zero. As with V, a value should be ascribed to A somewhere in the domain, in order to make the
potential solution unique.
3. Distant Boundaries
v v
Ampere's Law states that the integral of H dl around a closed path is equal to the integral of
v v v v
J dS over the enclosed surface, or just I, the enclosed current. Now, H dl is the tangential
Technical Notes : Applications in Electromagnetics 292
v
component of H , which is exactly the quantity specified in equation (11) by the Natural boundary
condition. In many cases, this fact can be used to construct meaningful terminating boundary conditions
for otherwise open domains.
v
The differential form of Ampere's Law can also be used to derive a general rule for the value of A :
v v
v v J ( R ') 3 v
A( R) v v d R'
R R'
v v
(In time-varying systems, J must refer to a current retarded in time by the propagation time from R ' to
v
R .)
v
This form has the property that A 0 . We may add to this definition the gradient of an arbitrary
scalar function G without affecting the resulting fields.
V. Harmonic Analysis
Equations (11) and (12) describe a full time dependent model of the fields, which can be extremely
expensive to compute. In many cases of interest, the time dependence we desire to study is the stable
oscillation caused by a sinusoidal excitation. In these cases it is convenient to make the assumption that
each of the field components can be expressed in the complex form
v
P P ei t
v
Where P is any of the field quantities, P is an associated complex amplitude (a function of space
only),
is the angular velocity, and i is the square root of minus 1. The observable field quantity is then the
real part of P, Re(P).
With these assumptions, the time derivative terms in our equations reduce to simple forms:
v
P v
i P
t
v
2
P 2
v
2
P
t
Applying these assumptions to equations (11) and (12) results in the harmonic equations
293 FlexP DE 7 : Technical Notes
v
A v
(13) i A i V 0
v
(14) V i A 0
These equations require solution in space only, and are thus much more economical than the full time
dependent system (11), (12). We will return to these equations frequently in the sections which follow.
We have been writing our equations in terms of vector fields, but in fact FlexPDE is not able to deal
directly with vector fields; we must manually reduce the system to component equations. In a three
dimensional space, equation (11) comprises three component equations while equation (12) is scalar.
So we have a total of four equations in four unknowns, Ax, Ay, Az and V.
Equations (13)-(14) are more complicated, since each component has a real and an imaginary part, for a
total of eight components. Each of these eight scalar variables must be represented by a separate
component equation.
We will not expand the equations into their final form just yet, because in most of the specializations
addressed subsequently the resulting forms are not nearly so frightening as the full equations.
VII. Specializations
In most problems of interest, the full generality of equations (11) and (12) or their harmonic equivalents
(13) and (14) are not necessary. Analysis of the needs of the problem at hand can usually lead to
considerable simplification. We will consider a few cases here.
1. Electrostatics
For fields which are constant in time, equation (12) decouples from equation (11), and the electric scalar
potential may be found from the single equation
(15) V 0
Since FlexPDE applies the divergence theorem over each computational cell, inclusion of inside the
divergence is sufficient to guarantee the correct behavior of the field quantities across material interfaces.
The natural boundary condition on V becomes a specification of the normal derivative of V .
2. Magnetostatics
v
Here the term s Grad(V) is in fact a representation of the current density J , which we will probably
wish to specify directly as the driving current for the fields:
v
A v
(16) J 0
v v v
In the geometric interpretation of A , for which A 0 , A has components parallel to the
v v v
components of J , so if J is restricted to a single component, we may restrict A to only that
component.
v
As discussed in section IV, the Natural boundary condition for A specifies the tangential component of
v v v
H . Natural( A )=0 specifies a symmetry plane, and Value( A )=0 specifies a perfect conductor.
In the common case where is constant, we can perform some simplification on equation (11). We
can apply the vector identity
v v v
A A A
To give
v v
1 v A 2
A 1 v
(17) A A V V .
t t2 t
v
Since we now have an explicit A , we are in a position to define it in any way we choose to
v
generate a form appropriate to our needs. The definition of A is commonly known as the "Gauge
Condition". The choice of gauge will be determined by what it is that we know about the problem at
hand. Several common gauge conditions and the resulting forms of (11)-(12) are given below.
Note that this operation is not without consequences. The definition of the natural boundary condition
v v
A A
has changed. It is no longer the boundary value of , but is now the boundary value of .
v v
Natural( A )=0 remains the condition for a symmetry plane, and Value( A )=0 still defines a perfect
v
conductor boundary, but care must be taken if other values are assigned. In the case A 0 , the
two will be equivalent, in other choices of gauge they may not be.
v
Also note that because of typographical constraints we have written A for the component-wise
v
Laplacian of the vector A . This notation is not strictly correct in curvilinear coordinates, and a more
careful derivation must be made in those cases.
Without making further assumptions about or , we can apply the Coulomb gauge condition,
v
A 0.
295 FlexP DE 7 : Technical Notes
In the special case where both and are constant, the scalar potential equation (19) with Coulomb
gauge can be simplified to
(19') V 0
Alternatively, we can use the "Diffusion" gauge condition:
v V
A
t
v
We can reverse the order of differentiation and cause A to cancel the V term in equation
t
v
A
(11) and replace the term in equation (12)
t
v v
v A 2
A
(20) A V
t t2
2
V
(21) V 0
t2
In some cases, s Grad(V) may be interpreted as the negative of the static current density, in which case
the equations decouple and (20) may be eliminated.
In the special case where , and are all constant, we can use the Lorentz gauge condition:
Technical Notes : Applications in Electromagnetics 296
v V
A V
t
v
This allows all the V terms to cancel from equation (17) resulting in decoupled equations for A and V
v v
v A 2
A
(22) A 0
t t2
2
V V
(23) V 0
t t2
The equations have now been decoupled, and may be solved separately. These forms are useful in the
solution of wave propagation problems.
1. Non-magnetic Materials
Equations (13) and (14) can also be specialized to the case of constant . The basic form of equation
(13) is
1 v v 1 v
(24) A i A A i V
Without making further assumptions about or we may apply the Coulomb gauge condition
v
A 0,
from which equations (13) and (14) become
v v
(25) A i A i V
v
(26) V i A 0
v v
Note that even though we have assumed A 0 , we are not free to delete the A from
equation (26) unless is constant.
In the special case where both and are constant, equation (26) with Coulomb gauge can be
simplified to
(26') V 0
Alternatively, we can use the diffusion gauge condition
v
A i V
from which we derive the equations
297 FlexP DE 7 : Technical Notes
v v
(27) A i A V
2
(28) V V 0
In some cases, V may be interpreted as the negative of the conduction current density, in which case
the equations decouple and (28) may be eliminated.
In the special case where , and are all constant, we can use the Lorentz gauge condition,
which in the harmonic approximation becomes
v
A ( i )V
All the V terms vanish in equation (24), and the pair (13), (14) become
v v
(29) A i A 0
(30) V i V 0
The equations have now been decoupled, and may be solved separately. These forms are useful in the
solution of wave propagation problems.
4.8.1 Introduction
FlexPDE is a software tool for finding numerical solutions to systems of linear or non-linear partial
differential equations using the methods of finite element analysis. The systems may represent static
boundary value, time dependent initial/boundary value, or eigenvalue problems. Rather than addressing
the solution of specific equations related to a given area of application, FlexPDE provides a framework
for treating partial differential equation systems in general. It gives users a straightforward method of
defining the equations, domains and boundary conditions appropriate to their application. From this
description it creates a finite element solution process tailored to the problem. Within quite broad limits,
then, FlexPDE is able to construct a numerical solution to a wide range of applications, without itself
having any built-in knowledge of any of them.
The goal of this book is not to provide a discussion of the specific grammatical rules of writing scripts for
FlexPDE, nor to describe the operation of the graphical user interface. Those topics are covered in
other volumes of the FlexPDE documentation, the Getting Started guide, the User Guide tutorial, and the
Problem Descriptor Reference.
In this book we will address several fields of physics in which FlexPDE finds fruitful application,
describing the various problems, the mathematical statement of the partial differential equation system,
and the ultimate posing of the problem to FlexPDE. The volume is accompanied by the text of all the
examples, which the user can submit to FlexPDE to see the solution in progress or use as a foundation
for problems of his own.
This manual is emphatically not a compendium of the problems FlexPDE “knows how to solve”. It is
Technical Notes : Applications in Electromagnetics 298
rather a group of examples showing ways in which the power of FlexPDE can be applied to partial
differential equations systems in many fields. The true range of applicability of FlexPDE can be
demonstrated only by the full range of ingenuity of users with insight into the mathematics of their own
special fields.
Nor does this manual attempt to present textbook coverage of the theory of the topics addressed. The
range of applications addressable by FlexPDE would make such an attempt impossible, even if we were
capable of such an endeavor. Instead, we have presented enough of the theory of each topic to allow
those practitioners who are familiar with the subject to see how the material has been analyzed and
presented to FlexPDE. Users who are unfamiliar with the various fields of application should consult
standard textbooks to find the full theoretical development of the subjects.
It is not our intent to provide an elaborate discussion of finite element methods. One goal of FlexPDE
has been to allow users in the various fields of science and engineering to begin reaping the benefits of
applying finite element analysis to their individual work without becoming programmers and numerical
analysts. There are hundreds of books in print detailing the method and its variants in many fields, and
the interested student can find a wealth of material to keep him busy. If we have been successful in our
endeavors, he won’t have to.
Nevertheless, a familiarity with some of the concepts of finite element analysis can be of benefit in
understanding how FlexPDE works, and why it sometimes does not. Hence this brief overview.
4.8.1.2 Principles
Partial differential equations generally arise as a mathematical expression of some conservation principle
such as a conservation of energy, momentum or mass. Partial differential equations by their very nature
deal with continuous functions -- a derivative is the result of the limiting process of observing differences
at an infinitesimal scale. A temperature distribution in a material, for example, is assumed to vary
smoothly between one extreme and another, so that as we look ever more closely at the differences
between neighboring points, the values become ever closer until at “zero” separation, they are the same.
Computers, on the other hand, apply arithmetic operations to discrete numbers, of which only a limited
number can be stored or processed in finite time. A computer cannot analyze an infinitude of values.
How then can we use a computer to solve a real problem?
Many approaches have been devised for using computers to approximate the behavior of real systems.
The finite element method is one of them. It has achieved considerable success in its few decades of
existence, first in structural mechanics, and later in other fields. Part of its success lies in the fact that it
approaches the analysis in the framework of integrals over small patches of the total domain, thus
enforcing aggregate correctness even in the presence of microscopic error. The techniques applied are
little dependent on shapes of objects, and are therefore applicable in real problems of complex
configuration.
The fundamental assumption is that no matter what the shape of a solution might be over the entire
domain of a problem, at some scale each local patch of the solution can be well approximated by a low-
299 FlexP DE 7 : Technical Notes
order polynomial. This is closely related to the well-known Taylor series expansion, which expresses the
local behavior of a function in a few polynomial terms.
In a two-dimensional heat flow problem, for example, we assume that if we divide the domain up into a
large number of triangular patches, then in each patch the temperature can be well represented by, let us
say, paraboloidal surfaces. Stitching the patches together, we get a Harlequin surface that obeys the
differential limiting assumption of continuity for the solution value—but perhaps not for its derivatives.
The patchwork of triangles is referred to as the computation “mesh”, and the sample points at vertices or
elsewhere are referred to as the “nodes” of the mesh.
In three dimensions, the process is analogous, using a tetrahedral subdivision of the domain.
How do we determine the shape of the approximating patches?
1. Assign a sample value to each vertex of the triangular or tetrahedral subdivision of the domain.
Then each vertex value is shared by several triangles (tetrahedra).
2. Substitute the approximating functions into the partial differential equation.
3. Multiply the result by an importance-weighting function and integrate over the triangles surrounding
each vertex.
4. Solve for the vertex values which minimize the error in each integral.
This process, known as a “weighted residual” method, effectively converts the continuous PDE problem
into a discrete minimization problem on the vertex values. This is usually known as a “weak form” of the
equation, because it does not strictly enforce the PDE at all points of the domain, but is instead correct in
an integral sense relative to the triangular subdivision of the domain.
The locations and number of sample values is different for different interpolation systems. In FlexPDE,
we use either quadratic interpolation (with sample values at vertices and midsides of the triangular cells),
or cubic interpolation (with values at vertices and two points along each side). Other configurations are
possible, which gives rise to various “flavors” of finite element methods.
A fundamental component of any partial differential equation system is the set of boundary conditions,
which alone make the solution unique. The boundary conditions are analogous to the integration
constants that arise in integral calculus. We say x 2 dx 1
3
x3 C , where is any constant. If we
differentiate the right hand side, we recover the integrand, regardless of the value of C.
2
u
In a similar way, to solve the equation 0 , we must integrate twice. The first integration gives
x2
u
C1 , and the second gives C1 x C2 . These integration constants must be supplied by the
x
boundary conditions of the problem statement.
It is clear from this example that there are as many integration constants as there are nested
Technical Notes : Applications in Electromagnetics 300
differentiations in the PDE. In the general case, these constants can be provided by a value at each end
of an interval, a value and a derivative at one end, etc. In practice, the most common usage is to provide
either a value or a derivative at each end of the domain interval. In two or three dimensions, a value or
derivative condition applied over the entire bounding curve or surface provides one condition at each end
of any coordinate integration path.
A fundamental technique applied by FlexPDE in treating the finite element equations is “integration by
parts”, which reduces the order of a derivative integrand, and also leads immediately to a formulation of
derivative boundary conditions for the PDE system.
In its usual form, integration by parts is given as
b b b
udv (uv) vdu
a a a .
Application of integration by parts to a vector divergence in a two- or three-dimensional domain, for
example, results in the Divergence Theorem, given in 2D as
v v
A
FdA Ñ l
ˆ
F ndl
.
This equation relates the integral inside the area to the flux crossing the outer boundary ( referring to the
outward surface-normal unit vector).
As we shall see, the use of integration by parts has a wide impact on the way FlexPDE interprets and
solves PDE systems.
Applied to the weighted residual method, this process dictates the flux conservation characteristics of the
finite element approximation at boundaries between the triangular approximation cells, and also provides
a method for defining the interaction of the system with the outside world, by specifying the value of the
surface integrand.
The values of the surface integrands are the “Natural” boundary conditions of the PDE system, a term
which also arises in a similar context in variational calculus.
FlexPDE uses the term “Natural” boundary condition to specify the boundary flux terms arising from the
integration by parts of all second-order terms in the PDE system.
(0.1) A
k dA Ñ l
k nˆ dl
The right hand side is the heat flux crossing the outer boundary, and the value of k must be
provided by the user in a Natural boundary condition statement (unless a value BC is applied instead).
301 FlexP DE 7 : Technical Notes
At an interface between two materials, k1 ( )1 nˆ1 represents the heat energy leaving material 1 at
a point on the interface. Likewise, k2 ( ) 2 nˆ2 represents the heat energy leaving material 2 at
the same point. Since the outward normal from material 1 is the negative of the outward normal from
material 2, the sum of the fluxes at the boundary is k2 ( ) 2 k1 ( )1 nˆ1 , and this becomes the
Natural boundary condition at the interface. In this application, we want energy to be conserved, so that
the two flux terms must sum to zero. Thus the internal Natural BC is zero at the interface, and this is the
default value applied by FlexPDE.
(0.2) V
fdV Ò S
ˆ dS
nf (Gradient Theorem)
v v
(0.3) V
FdV Ò S
nˆ F dS (Divergence Theorem)
v v v
(0.4) V
FdV Ò S
nˆ F dS
V
FdV
v v
(0.5) V
FdV Ò S
nˆ F dS (Curl Theorem)
We have said that at “some scale“, the solution can be adequately approximated by a set of low-order
polynomials. But it is not always obvious where the mesh must be dense and where a coarse mesh will
suffice. In order to address this issue, FlexPDE uses a method of “adaptive mesh refinement“. The
problem domain presented by the user is divided into a triangular mesh dictated by the feature sizes of
the domain and the input controls provided by the user. The problem is then constructed and solved,
and the cell integrals of the weighted residual method are crosschecked to estimate their accuracy. In
locations where the integrals are deemed to be of questionable accuracy, the triangles are subdivided to
give a new denser mesh, and the problem is solved again. This process continues until FlexPDE is
satisfied that the approximation is locally accurate to the tolerance assigned by the user. Acceptable
local accuracy does not necessarily guarantee absolute accuracy, however. Depending on how errors
accumulate or cancel, the global accuracy could be better or worse than the local accuracy condition
implies.
4.8.1.6 T im e Integration
The finite element method described above is most successful in treating boundary value problems.
When addressing initial value problems, while the finite element method could be applied (and sometimes
is), other techniques are frequently preferable. FlexPDE uses a variable-order implicit backward
difference method (BDM) as introduced by C.W. Gear. In most cases, second order gives the best
tradeoff between stability, smoothness and speed, and this is the default configuration for FlexPDE. This
method fits a quadratic in time to each nodal value, using two known values and one future (unknown)
Technical Notes : Applications in Electromagnetics 302
value. It then solves the coupled equations for the array of nodal values at the new time. By looking
backward one additional step, it is possible to infer the size of the cubic term in a four-point expansion of
the time behavior of each nodal value. If these cubic contributions are large, the timestep is reduced, and
if extreme, the current step repeated.
With this very cursory examination of finite element methods, we are ready to start applying FlexPDE to
the solution of PDE systems of interest in real scientific and engineering work.
Disclaimer
We have tried to make these notes as accurate as possible, but because we are not experts in all the
fields addressed, it is possible that errors have crept in. We invite readers to comment freely on the
material presented here, and to take us to task if we have erred.
4.8.2 Electrostatics
Perhaps the most important of all partial differential equations is the simple form
(1.1) k q 0
It is encountered in virtually all branches of science and engineering, and describes the diffusion of a
quantity with diffusivity k and volume source q. With k=1 it is referred to as Poisson’s equation,
2 2
q 0 . With k=1 and q=0, it is referred to as Laplace’s equation, 0.
If is electric potential, k is permittivity and q is charge density, then (1.1) is the electrostatic field
equation.
If is temperature, k is thermal conductivity and q is heat source, then (1.1) is the heat equation.
u , v
x y
In most cases, we can identify k with the flux of some quantity such as heat, mass or a chemical.
(1.1) then says that the variation of the rate of transfer of the relevant quantity is equal to the local source
(or sink) of the quantity.
If we integrate the divergence term by parts (or equivalently, apply the divergence theorem), we get
303 FlexP DE 7 : Technical Notes
(1.2) V
k dV Ò S
nˆ k dS
V
qdV
That is, the total interior source is equal to the net flow across the outer boundary.
The simplest form of the natural boundary condition is the insulating or “no flow“ boundary,
Natural(phi) = 0.
Let us as a first example construct the electrostatic field equation for an irregularly shaped block of high-
dielectric material suspended in a low-dielectric material between two charged plates.
The equation is as presented above, using the div and grad operators in place of and :
equations
div(eps*grad(V)) = 0
The domain will consist of two regions; the bounding box containing the entire space of the problem, with
charged plates top and bottom:
Technical Notes : Applications in Electromagnetics 304
boundaries
region 1
start (0,0)
value(V) = 0
line to (1,0)
natural(V) = 0
line to (1,1)
value(V) = 100
line to (0,1)
natural(V) = 0
line to close
region 2
eps = 50
start (0.4,0.4)
line to (0.8,0.4)
to (0.8,0.8)
to (0.6,0.8)
to (0.6,0.6)
to (0.4,0.6)
to close
Notice that we have used the insulating form of the natural boundary condition on the sides of the
bounding box, with specified potentials top (100) and bottom (0).
We have specified a permittivity of 50 in the imbedded region. (Since we are free to multiply through the
equation by the free-space permittivity , we can interpret the value as relative permittivity or dielectric
constant.)
What will happen at the boundary between the dielectric and the air? If we apply equation (1.2) and
integrate around the dielectric body, we get
Ñ l
nˆ k dl
A
qdA 0
If we perform this integration just inside the boundary of the dielectric, we must use = 50, whereas just
outside the boundary, we must use = 1. Yet both integrals must yield the same result. It therefore
follows that the interface condition at the boundary of the dielectric is
nˆ k inside
nˆ k outside .
v v v
Since the electric field vector is E and the electric displacement is D E , we have the
condition that the normal component of the electric displacement is continuous across the interface, as
required by Maxwell’s equations.
305 FlexP DE 7 : Technical Notes
We want to see what is happening while the problem is being solved, so we add a monitor of the
potential:
monitors
contour(V) as 'Potential'
At the end of the problem we would like to save as graphical output the computation mesh, a contour
plot of the potential, and a vector plot of the electric field:
plots
grid(x,y)
contour(V) as 'Potential'
vector(-dx(V),-dy(V)) as 'Electric Field'
Putting all these sections together, we have the complete script for the dielectric problem:
title
'Electrostatic Potential'
variables
V
definitions
eps = 1
equations
div(eps*grad(V)) = 0
boundaries
region 1
start (0,0)
value(V) = 0 line to (1,0)
natural(V) = 0 line to (1,1)
value(V) = 100 line to (0,1)
natural(V) = 0 line to close
region 2
eps = 50
start (0.4,0.4)
line to (0.8,0.4) to (0.8,0.8)
to (0.6,0.8) to (0.6,0.6)
to (0.4,0.6) to close
monitors
contour(V) as 'Potential'
plots
grid(x,y)
contour(V) as 'Potential'
vector(-dx(V),-dy(V)) as 'Electric Field'
Technical Notes : Applications in Electromagnetics 306
end
4.8.2.2 Electrostatics in 3D
We can convert this example quite simply to a three dimensional calculation. The modifications that must
be made are:
Specify cartesian3 coordinates.
Add an extrusion section listing the dividing surfaces.
Provide boundary conditions for the end faces.
Qualify plot commands with the cut plane in which the plot is to be computed.
In the following descriptor, we have divided the extrusion into three layers. The dielectric constant in the
first and third layer are left at the default of k=1, while layer 2 is given a dielectric constant of 50 in the
dielectric region only.
A contour plot of the potential in the plane x=0 has been added, to show the resulting vertical cross
section. The plots in the z=0.15 plane reproduce the plots shown above for the 2D case.
title
'Electrostatic Potential'
coordinates
cartesian3
variables
V
definitions
eps = 1
equations
div(eps*grad(V)) = 0
extrusion
surface "bottom" z=0
surface "dielectric_bottom" z=0.1
layer "dielectric"
surface "dielectric_top" z=0.2
surface "top" z=0.3
boundaries
region 1
start (0,0)
value(V) = 0 line to (1,0)
natural(V) = 0 line to (1,1)
value(V) = 100 line to (0,1)
natural(V) = 0 line to close
region 2
layer "dielectric" eps = 50
start (0.4,0.4)
line to (0.8,0.4) to (0.8,0.8)
to (0.6,0.8) to (0.6,0.6)
to (0.4,0.6) to close
monitors
contour(V) on z=0.15 as 'Potential'
plots
contour(V) on z=0.15 as 'Potential'
vector(-dx(V),-dy(V)) on z=0.15 as 'Electric Field'
contour(V) on x=0.5 as 'Potential'
end
Technical Notes : Applications in Electromagnetics 310
The following potential plot on x=0 shows the vertical cross section of the extruded domain. Notice that
the potential pattern is not symmetric, due to the influence of the extended leg of the dielectric in the y
direction.
This problem illustrates the calculation of capacitance per unit length in a 2D X-Y geometry extended
indefinitely in the Z direction. The capacitance is that between a conductor enclosed in a dielectric sheath
and a surrounding conductive enclosure. In addition to these elements, there is also another conductor
(also with a dielectric sheath) that is "free floating" so that it maintains zero net charge and assumes a
potential that is consistent with that uncharged state.
v
We use the potential as the system variable, from which we can calculate the electric field E V
v v
and displacement D E , where is the local permittivity and may vary with position.
v v
D E V 0.
We impose value boundary conditions on at the surfaces of the two conductors, so that we do not
have to deal with regions that contain charge.
The metal in the floating conductor is "faked" with a fairly high permittivity, which has the effect of driving
the interior field and field energy to near zero. The imposition of (default) natural boundary conditions
then keeps the field normal to the surface of the conductor, as Maxwell requires. Thus we get a good
answer without having to solve for the charge on the floating conductor, which would be a real pain due
to its localization on the surface of the conductor.
The capacitance can be found in two ways. If we know the charge Q on the conductor at fixed
potential V , we solve
2
Alternatively, we can use the energy relation W 1
2 CV to get C 2W V 2 . We find the energy
v v
W by integrating the energy density 12 E D over the area of the problem.
SELECT
errlim 1e-4
thermal_colors on
plotintegrate off
VARIABLES
V
DEFINITIONS
mm = 0.001 ! meters per millimeter
Lx = 300 * mm ! enclosing box dimensions
Ly = 150 * mm
b = 0.7 ! fractional radius of conductor
! position and size of cable at fixed potential:
x0 = 0.25 * Lx
y0 = 0.5 * Ly
r0 = 15 * mm
Technical Notes : Applications in Electromagnetics 312
x1 = 0.9 * Lx
y1 = 0.3 * Ly
r1 = r0
epsr ! relative permittivity
epsd = 3 ! epsr of cable dielectric
epsmetal = 1000 ! fake metallic conductor
eps0 = 8.854e-12 ! permittivity of free space
eps = epsr * eps0
v0 = 1 ! fixed potential of the cable
EQUATIONS
div( eps * grad( v) ) = 0
BOUNDARIES
region 1 'inside' epsr = 1
start 'outer' ( 0, 0) value( v) = 0
line to (Lx,0) to (Lx,Ly) to (0,Ly) to close
region 2 'diel0' epsr = epsd
start 'dieb0' (x0+r0, y0)
arc ( center = x0, y0) angle = 360
region 3 'cond0' epsr = 1
start 'conb0' (x0+b*r0, y0) value(v) = v0
arc ( center = x0, y0) angle = 360
region 4 'diel1' epsr = epsd
start 'dieb1' ( x1+r1, y1)
arc ( center = x1, y1) angle = 360
region 5 'cond1' epsr = epsmetal
start 'conb1' ( x1+b*r1, y1)
arc ( center = x1, y1) angle = 360
PLOTS
contour( v) as 'Potential'
contour( v) as 'Potential Near Driven Conductor'
zoom(x0-1.1*r0, y0-1.1*r0, 2.2*r0, 2.2*r0)
contour( v) as 'Potential Near Floating Conductor'
zoom(x1-1.1*r1, y1-1.1*r1, 2.2*r1, 2.2*r1)
elevation( v) from ( 0,y0) to ( x0, y0)
as 'Potential from Wall to Driven Conductor'
elevation( v) from ( x0, y0) to ( x1, y1)
as 'Potential from Driven to Floating Conductor'
vector( grad( v)) as 'Field'
contour( energyDensity) as 'Field Energy Density'
contour( energyDensity)
zoom( x1-1.2*r1, y1-1.2*r1, 2.4*r1, 2.4*r1)
as 'Field Energy Density Near Floating Conductor'
elevation( energyDensity)
from (x1-2*r1, y1) to ( x1+2*r1, y1)
as 'Field Energy Density Near Floating Conductor'
contour( epsr) paint on "inside"
as 'Definition of Inside'
313 FlexP DE 7 : Technical Notes
SUMMARY
report sintegral(normal(eps*grad(v)),'conb0', 'diel0')
as 'Driven charge'
report sintegral(normal(eps*grad(v)),'outer','inside')
as 'Outer charge'
report sintegral(normal(eps*grad(v)),'conb1','diel1')
as 'Floating charge'
report sintegral(normal(eps*grad(v)),'conb0','diel0')/v0
as 'Capacitance (f/m)'
report integral( energyDensity, 'inside')
as 'Energy (J/m)'
report 2 * integral( energyDensity, 'inside') / v0^2
as 'Capacitance (f/m)'
report 2 * integral(energyDensity)/(v0*
sintegral( normal(eps*grad(v)), 'conb0', 'diel0'))
as 'cap_by_energy / cap_by_charge'
END
Technical Notes : Applications in Electromagnetics 314
315 FlexP DE 7 : Technical Notes
Technical Notes : Applications in Electromagnetics 316
4.8.3 Magnetostatics
(2.1)
where is the magnetic field intensity, is the magnetic induction, is the magnetic
permeability and is the current density.
(2.2)
It is sometimes fruitful to use the magnetic field quantities directly as variables in a model. However, eq.
317 FlexP DE 7 : Technical Notes
(2.2) shows that the tangential components of are continuous across an interface, while the normal
components of are continuous.
The finite element method used by FlexPDE has a single value of each variable on an interface, and
therefore requires that the quantities chosen for system variables must be continuous across the interface.
In special cases, it may be possible to choose components of or which satisfy this continuity
requirement. We could, for example model in a problem where material interfaces are normal to .
In the general case, however, meeting the continuity requirements can be impossible.
It is common in Magnetostatics to use instead of the field quantities the magnetic vector potential ,
defined as
(2.3) .
can be derived from Ampere’s Law, and shown to be the integrated effect at each point of all the
current loops active in the domain. In this derivation, will have components parallel to the
components of , so that it can be determined a priori which components of must be represented.
Eq. (2.3) alone is not sufficient to uniquely define . It must be supplemented by a definition of to
be unique. This definition (the “gauge condition”) is usually taken to be (“Coulomb gauge”), a
definition consistent with the derivation of from Ampere’s Law. Other definitions are useful in some
applications. It is not important what the qauge condition is; in all cases , and therefore the field
quantities, remain the same.
(2.4)
In cases with multiple materials, where can take on different values, it is important to keep the
inside the curl operator, because it is the integration of this term by parts that gives the correct jump
conditions at the material interface.
(2.5) ,
so that the Natural boundary condition defines on external boundaries, and is assumed
continuous across internal boundaries, consistent with Maxwell’s equations.
Technical Notes : Applications in Electromagnetics 318
As a first example, we will calculate the magnetic field created by a coil, using 2D cylindrical (r,z)
v
geometry. We will apply current only in the azimuthal direction, so the only nonzero component of A
will be the azimuthal component A . With only a single component normal to the computational plane,
v 1 A
the gauge condition is automatically satisfied, since A 0 .
r
In the descriptor which follows, note that we have chosen to align the cylindrical axis with the horizontal
plot axis. FlexPDE uses a right-hand coordinate system, so in this case positive is outward from the
plot page.
See also "Samples | Applications | Magnetism | Magnet_Coil.pde" 430
Coordinates
xcylinder(Z,R)
Variables
Aphi { azimuthal component of the vector potential }
Definitions
mu = 1 { the permeability }
J =0 { global source term defaults to zero }
current = 10 { the source value in the coil }
Br = -dz(Aphi) { definitions for plots }
Bz = dr(r*Aphi)/r
Equations
Curl(curl(Aphi)/mu) = J
Boundaries
Region 1
start(-10,0)
value(Aphi) = 0 { specify A=0 along axis }
line to (10,0)
value(Aphi) = 0 { H x n = 0 on distant sphere }
arc(center=0,0) angle 180 to close
Region 2
J = current { redefine source value }
start (-0.25,1)
line to (0.25,1) to (0.25,1.5)
to (-0.25,1.5) to close
Monitors
319 FlexP DE 7 : Technical Notes
Plots
grid(z,r)
contour(Bz) as 'FLUX DENSITY B'
contour(Bz) zoom(-2,0,4,4) as 'FLUX DENSITY B'
elevation(Aphi, dr(Aphi), Aphi/r, Bz)
from (0,0) to (0,1) as 'Near Axis'
vector(Bz,Br) as 'FLUX DENSITY B'
vector(Bz,Br) zoom(-2,0,4,4) as 'FLUX DENSITY B'
contour(Aphi) as 'MAGNETIC POTENTIAL'
End
Technical Notes : Applications in Electromagnetics 320
321 FlexP DE 7 : Technical Notes
Select
errlim = 1e-4
Variables
A
Definitions
mu = 1 { default to air}
mu0 = 1 { for saturation plot }
mu_max = 5000
mu_min = 200
mucore = mu_max/(1+0.05*grad(A)^2) + mu_min
S =0
current = 2
y0 = 8
Equations
curl(curl(A)/mu) = S
Boundaries
Region 1 { The IRON core }
mu = mucore
mu0 = mu_max
start(0,0)
natural(A) = 0 line to (40,0)
value(A) = 0 line to (40,40) to (0,40) to close
Monitors
contour(A)
Plots
grid(x,y)
vector(dy(A),-dx(A)) as "FLUX DENSITY B"
vector(dy(A)/mu, -dx(A)/mu) as "MAGNETIC FIELD H"
contour(A) as "Az MAGNETIC POTENTIAL"
surface(A) as "Az MAGNETIC POTENTIAL"
contour(mu0/mu) painted as "Saturation: mu0/mu"
End
323 FlexP DE 7 : Technical Notes
Technical Notes : Applications in Electromagnetics 324
325 FlexP DE 7 : Technical Notes
v v
In two dimensional geometry with a single nonzero component of A , the gauge condition A 0 is
automatically satisfied. Direct application of eq. (2.4) is therefore well posed, and we can proceed
without further modification.
In 3D, however, direct implementation of eq. (2.4) does not impose a gauge condition, and is therefore
ill-posed in many cases. One way to address this problem is to convert the equation to divergence form
using the vector identity
v v 2
v
(2.6) A A A.
v
As long as is piecewise constant we can apply (2.6) together with the Coulomb gauge A 0 to
rewrite (2.4) as
v
A v
(2.7) J 0
Technical Notes : Applications in Electromagnetics 326
v
We assert without proof that there exists a gauge condition A F ( x, y, z ) which forces
v T
A
(2.9) 0.
It is not necessary to solve these equations; we show them merely to indicate that embodies the
commutation characteristics of the system. The value of is implied by the assertion (2.9). Clearly,
when is constant, the equations reduce to F 0 , for which F 0 is a solution.
Using the definition (2.9) we can again write the divergence form
v
(2.10) A J 0.
In converting the equation to a divergence, we have modified the interface conditions. The natural
boundary condition for each component equation of (2.10) is now the normal component of the
argument of the divergence:
Natural ( Ax ) nˆ Ax
(2.11) Natural ( Ay ) nˆ Ay
Natural ( Az ) nˆ Az
The default interior interface condition assumes component-wise continuity of the surface terms across
327 FlexP DE 7 : Technical Notes
the interface.
Of the conditions (2.2) required by Maxwell’s equations at an interface, the first describes the tangential
v v
components of H , which by (2.3) involve the normal components of A . Eq. (2.11) shows that
v
these components scale by 1 , satisfying the tangential condition on H .
The second condition is satisfied by the fact that the variables Az , Ay , Az have only a single
representation on the boundary, requiring that their tangential derivatives, and therefore the normal
component of , will be continuous across the interface.
In all cases it is important to keep the attached to the term to preserve the correct interface jump
conditions.
v
In magnetic materials, we can modify the definition of H to include magnetization and write
v v v
(2.12) H B M
v
We can still apply the divergence form in cases where M 0 , but we must treat the magnetization
terms specially.
FlexPDE does not integrate constant source terms by parts, and if is piecewise constant the
magnetization term will disappear in equation analysis. It is necessary to reformulate the magnetic term
so that it can be incorporated into the divergence. We have from (2.5)
v v
(2.14) V
M dV Ò S
nˆ MdS .
0 Mz My
v
N Mz 0 Mx
My Mx 0
v
This follows because integration by parts will produce surface terms n̂ N , which are equivalent to the
v
required surface terms n̂ M .
Ay
(2.17) Ny Jy 0
Az
Nz Jz 0
v
where the N i are the rows of N .
In this formulation, the Natural boundary condition will be defined as the value of the normal component
of the argument of the divergence, eg.
Ax
(2.18) Natural ( Ax ) nˆ Nx .
As an example, we will compute the magnetic field in a generic magnetron. In this case, only M z is
applied by the magnets, and as a result Az will be zero. We will therefore delete Az from the analysis.
The outer and inner magnets are in reversed orientation, so the applied M z is reversed in sign.
COORDINATES
CARTESIAN3
SELECT
alias(x) = "X(cm)"
alias(y) = "Y(cm)"
alias(z) = "Z(cm)"
nodelimit = 40000
errlim=1e-4
VARIABLES
Ax,Ay { assume Az is zero! }
DEFINITIONS
MuMag=1.0 { Permeabilities: }
MuAir=1.0
MuSST=1000
MuTarget=1.0
Mu=MuAir { default to Air }
EQUATIONS
Ax: div(grad(Ax)/mu + Nx) = 0
Ay: div(grad(Ay)/mu + Ny) = 0
EXTRUSION
SURFACE "Boundary Bottom" Z=-5
SURFACE "Magnet Plate Bottom" Z=0
LAYER "Magnet Plate"
SURFACE "Magnet Plate Top" Z=1
LAYER "Magnet"
SURFACE "Magnet Top" Z=2
SURFACE "Boundary Top" Z=8
BOUNDARIES
Surface "boundary bottom"
value (Ax)=0 value(Ay)=0
Surface "boundary top"
value (Ax)=0 value(Ay)=0
arc(center=20,0) angle=180
Line TO (-20,10)
arc(center=-20,0) angle=180
LINE TO CLOSE
REGION 3 { Air }
LAYER "Magnet Plate"
Mu=MuSST
START (20,-6)
arc(center=20,0) angle=180
Line TO (-20,6)
arc(center=-20,0) angle=180
LINE TO CLOSE
MONITORS
grid(x,z) on y=0
grid(x,y) on z=1.01
grid(x,z) on y=1
PLOTS
grid(x,y) on z=1.01
grid(y,z) on x=0
grid(x,z) on y=0
contour(Ax) on x=0
contour(Ay) on y=0
vector(Bxx,Byy) on z=2.01 norm
vector(Byy,Bzz) on x=0 norm
vector(Bxx,Bzz) on y=4 norm
contour(magnitude(Bxx,Byy,Bzz)) on z=2.01 LOG
331 FlexP DE 7 : Technical Notes
END
Technical Notes : Applications in Electromagnetics 332
333 FlexP DE 7 : Technical Notes
4.8.4 Waveguides
A waveguide is any of several kinds of structure intended to direct the propagation of high-frequency
electromagnetic energy along specific paths. While the analysis of bends and terminations in such a
system is an essentially three-dimensional problem, the propagation in long straight segments of the guide
can be reduced to a two-dimensional analysis. In this case, we assume that the guide is of uniform
cross-section in the (X,Y) plane, unvarying in the Z-dimension of the propagation direction. In this
configuration, we can make the assumption that the fields inside the guide may be represented as a
sinusoidal oscillation in time and space, and write
v v
E ( x, y, z , t ) E ( x, y )exp(i t i z )
(3.1) v v
H ( x, y, z , t ) H ( x, y )exp(i t i z )
It is easy to see that these expressions describe a traveling wave, since the imaginary exponential
generates sines and cosines, and the value of the exponential will be the same wherever z t. A
Technical Notes : Applications in Electromagnetics 334
purely real implies an unattenuated propagating mode with wavelength 2 / along the z
direction.
v v
v v D v E
H J J
t t
v v
B H 0
(3.2) v v
v B H
E
t t
v v
D E
v
Assume then that J 0 and 0 , and apply (3.1) :
v v v
H i E H 0
(3.3) v v v
E i H E 0
Taking the curl of each curl equation in (3.3) and substituting gives
v
H 2
v
H
(3.4) v
E 2
v
E
v v v
1x 1y 1z i
(3.5) x y
v
T 1z i
In many cases, the waveguide under analysis consists of a metal casing, either empty or filled
homogeneously with an isotropic dielectric. In these cases, the analysis can be simplified.
Eq. (3.3) can be expanded using (3.5) and rearranged to express the transverse x and y components in
terms of the axial z components Hz and Ez .
2 2 Hz Ez
Ex i
y x
2 2 Hz Ez
Ey i
x y
(3.6)
2 2 Ez Hz
Hx i
y x
2 2 Ez Hz
Hy i
x y
The i in the right hand side corresponds to a phase shift of 2 in the expansion (3.1).
2 2
These are eigenvalue equations in Ez and Hz , and the values of for which solutions
exist constitute the propagation constants of the unattenuated propagation modes that can be supported
in the guide under analysis. For any eigenvalue, there are an infinite number of combinations of
which can excite this mode, and the exact determination will depend on the materials and the
driving frequency.
Technical Notes : Applications in Electromagnetics 336
In a homogeneously filled waveguide, there exist two sets of distinct modes. One set of modes has no
magnetic field component in the propagation direction, and are referred to as Transverse Magnetic, or
TM, modes. The other set has no electric field component in the propagation direction, and are referred
to as Transverse Electric, or TE, modes. In either case, one member of (3.8) vanishes, leaving only a
single variable and a single equation. Correspondingly, equations (3.6) are simplified by the absence of
one or the other field component.
v
The boundary condition at an electrically conducting wall is nˆ H 0 Through (3.6), this implies
.
v
The boundary condition at a metallic wall is nˆ E
0 , which requires that tangential components of
v
E be zero in the wall. Since Ez is always tangential to the wall, the boundary condition is the Dirichlet
condition Ez 0 .
In the following example, we compute the first few TE modes of a waveguide of complex cross-section.
The natural boundary condition allows an infinite number of solutions, differing only by a constant offset
in the eigenfunction, so we add an integral constraint to center the eigenfunctions around zero. Since all
the material parameters are contained in the eigenvalue, it is unnecessary to concern ourselves with their
values. Likewise, the computation of the transverse field components are scaled by constants, but the
shapes are unaffected.
select
modes = 4 { This is the number of Eigenvalues desired. }
variables
337 FlexP DE 7 : Technical Notes
Hz
definitions
L =2
h = 0.5 ! half box height
g = 0.01 ! half-guage of wall
s = 0.3*L ! septum depth
tang = 0.1 ! half-width of tang
Hx = -dx(Hz)
Hy = -dy(Hz)
Ex = Hy
Ey = -Hx
equations
div(grad(Hz)) + lambda*Hz = 0
boundaries
region 1
start(0,0)
natural(Hz) = 0
line to (L,0) to (L,1) to (0,1) to (0,h+g)
natural(Hz) = 0
line to (s-g,h+g) to (s-g,h+g+tang) to (s+g,h+g+tang)
to (s+g,h-g-tang) to (s-g,h-g-tang)
to (s-g,h-g) to (0,h-g)
to close
monitors
contour(Hz)
plots
contour(Hz) painted
vector(Hx,Hy) as "Transverse H" norm
vector(Ex,Ey) as "Transverse E" norm
end
Technical Notes : Applications in Electromagnetics 338
339 FlexP DE 7 : Technical Notes
Technical Notes : Applications in Electromagnetics 340
Note: The development given here follows that of Fernandez and Lu, “Microwave and Optical
Waveguide Analysis”, and of Silvester and Ferrari, “Finite Elements for Electrical
Engineers”.
In many applications, a waveguide is partially or inhomogeneously filled with dielectric material. In this
case, pure TE and TM modes do not exist. Both Ez and Hz exist simultaneously, and the propagation
modes are hybrid in nature.
An alternative approach seeks to reduce the equations (3.4) to a pair of equations in the transverse
341 FlexP DE 7 : Technical Notes
v
components of the magnetic field, HT Hx1x + H y 1y . In the process, the condition B 0 is
explicitly imposed, and it is claimed that no spurious modes arise.
In the development that follows, we continue to treat as a constant (invalidating use where magnetic
materials are present), but we exercise more care in the treatment of .
v v
For notational convenience, we will denote the components of H as H a1ˆ x b1ˆ y c1ˆ z and use
subscripts to denote differentiation. The first equation of (3.4) can then be expanded with (3.5) to give
2 2
bx / y
ay / i cx / a/ a
y
2 2
(3.11) ay / bx / x
i cy / b/ b
x
2
cx / x
cy / i a/ x
i b/ y
c
y
v
The condition B 0 allows us to replace
(3.12) i c ax by
2 2 2
The equation pair (3.13) is an eigenvalue problem in . We can no longer bundle the and
2
terms inside the eigenvalue, because the r dividing is now variable across the domain. Given a
driving frequency , we can compute the axial wave numbers for which propagating modes exist.
Technical Notes : Applications in Electromagnetics 342
To see what the natural boundary conditions imply, integrate the second-order terms of (3.13) by parts:
(3.15)
(ax by ) x / r (bx ay ) y / r dxdy Ñ nx ( a x by ) / r n y (bx ay ) / r dl
T S
We have shown only the contour integrals arising from the integration, and suppressed the area integral
correcting for varying . This term will be correctly added by FlexPDE, and does not contribute to the
boundary condition.
The integrand of the contour integrals is the value represented by the NATURAL boundary
condition statement in FlexPDE.
Thus the NATURAL boundary condition specifications for the two equations define the values of the
quantities
The boundary conditions which must be satisfied at an electrically conducting wall are
v v
(3.17) nˆ H 0; nˆ E 0.
the condition becomes simply Hx 0 . Similarly, at a horizontal wall, it is H y 0 . Both are easily
expressed as Value boundary conditions. At an oblique wall, the condition can be expressed as an
implicit value boundary condition for one of the components, e.g. Value( H y )= n x n y Hx .
v
The second condition requires that the tangential components of E must vanish in the wall. In
particular, Ez is always tangential and must therefore be zero. From (3.3) we can derive
i Ez (bx
a y ) . But this term appears in each of the forms in (3.16), so at a vertical wall, where
ny 0, we can set Natural( Hy )=0, and at a horizontal wall, where nx 0, we can use Natural(
343 FlexP DE 7 : Technical Notes
Hx )=0. These are the reverse assignments from the value conditions above, so the two form a
complementary set and completely specify the boundary conditions for (3.13). Similar arguments can be
used at a magnetic wall, resulting in a reversed assignment of value and natural boundary conditions.
v v
At a material interface, Maxwell’s equations require that the tangential components of E and H and
v v
the normal components of E and H must be continuous.
bx ay bx ay
Continuity of Ez requires .
r 1 r 2
From (3.16) it is clear that at vertical interfaces, the continuity of Ez will be satisfied by the H y equation,
while for horizontal interfaces, it will be satisfied by the Hx equation.
If all material discontinuities occur at vertical faces and r is piecewise constant, we can multiply the
Hx equation by r , and continuity of Hz will be satisfied. Similarly, if all material discontinuities occur
at horizontal faces and r is piecewise constant, we can multiply the H y equation by r , and continuity
of Hz will be satisfied.
Clearly, at an internal interface where r is continuous, the internal natural boundary condition reduces
to zero, which is the default condition.
In the example which follows, we consider a simple 2x1 metal box with dielectric material in the left half.
Note that FlexPDE will compute the eigenvalues with lowest magnitude, regardless of sign, while
negative eigenvalues correspond to modes with propagation constants below cutoff, and are therefore
not physically realizable.
Technical Notes : Applications in Electromagnetics 344
select
modes = 5 { This is the number of Eigenvalues desired. }
ngrid = 30
overshoot = 1e-9 { request very tight Conjugate Gradient convergence }
variables
Hx, Hy
definitions
cm = 0.01 ! conversion from cm to meters
b = 1*cm ! box height
L = 2*b ! box width
epsr ! values will be given by region
epsr1=1 epsr2=1.5
eps0 = 8.85e-12
mu0 = 4e-7*pi
c = 1/sqrt(mu0*eps0) ! light speed
k0b = 4 ! normalized driving frequency
k0 = k0b/b
k02 = k0^2 ! k0^2=omega^2*mu0*eps0
equations
! Hx equation multiplied by epsr to enforce continuity of Hz
Hx: dx(divh) - dy(curlh) + k02*Hx*epsr - (lambda+shift)*Hx = 0
Hy: dx(curlh/epsr) + dy(divh)/epsr + k02*Hy - (lambda+shift)*Hy/epsr = 0
boundaries
region 1 epsr=epsr1
start(0,0)
natural(Hx) = 0 value(Hy)=0
345 FlexP DE 7 : Technical Notes
line to (L,0)
value(Hx) = 0 value(Hy)=0 natural(Hy)=0
line to (L,b)
natural(Hx) = 0 value(Hy)=0
line to (0,b)
value(Hx) = 0 natural(Hy)=0
line to close
region 2 epsr=epsr2
start(b,b)
line to (0,b) to (0,0) to (b,0)
line to close
monitors
contour(Hx) range=(-1,1)
contour(Hy) range=(-1,1)
plots
contour(Hx) range=(-1,1) report(k0) report(kz)
surface(Hx) range=(-1,1) report(k0) report(kz)
contour(Hy) range=(-1,1) report(k0) report(kz)
surface(Hy) range=(-1,1) report(k0) report(kz)
surface(divh) range=(-1,1) as "Hz" report(k0) report(kz)
surface(curlh/epsr) range=(-1,1) as "Ez" report(k0) report(kz)
summary export
report lambda
report shift
report true_lambda
report(k0)
report( if(true_lambda<0) then "*" else " ") ! mark negative eigenvalues
report(kz)
report(kz/k0)
end
Technical Notes : Applications in Electromagnetics 346
347 FlexP DE 7 : Technical Notes
Technical Notes : Applications in Electromagnetics 348
4.8.5 References
N. J. Cronin, “Microwave and Optical Waveguides”, London, Institute of Physics Publishing, 1995.
F. Anibal Fernandez and Yilong Lu, “Microwave and Optical Waveguide Analysis”, Somerset,UK,
Research Studies Press, Ltd. 1996.
S. R. H. Hoole, “Computer-Aided Analysis and Design of Electromagnetic Devices”, New York,
Elsevier, 1989.
Nathan Ida and Joao P.A. Bastos “Electromagnetics and Calculation of Fields”, New York, Springer-
Verlag, 1992.
J. D. Jackson, “Classical Electrodynamics”, Second Edition, New York, John Wiley & Sons, 1975.
Jianming Jin, “The Finite Element Method in Electromagnetics”, New York, John Wiley & Sons, Inc,
1993.
Peter P. Silvester and Ronald L. Ferrari, “Finite Elements for Electrical Engineers”, Third Edition,
Cambridge University Press, 1996.
C. T. Tai, “Generalized Vector and Dyadic Analysis”, New York, IEEE Press, 1992.
349 FlexP DE 7 : Technical Notes
2
We define u from the relation u - u = v
then Uk exp(i k x) ( 1 + k2) = Vk exp(i k x).
The Sampling Theorem states (McGillem and Cooper, "Continuous and Discrete Signal and System
Analysis", p 164):
" A band-limited signal can be uniquely represented by a set of samples taken at intervals spaced 1/2W
seconds apart, where W is the signal bandwidth in Hz."
The sampled signal is the product of the input signal and the sampling function, and the spectrum of the
sampled signal is the convolution of the two transforms. The spectrum of the sampling function is a series
of impulses at the harmonics of the sampling frequency (2W), and the convolution leads to a replication
of the signal spectrum around each of these harmonics. If the signal bandwidth exceeds the harmonic
spacing 2W, then the harmonics will overlap, and aliasing will occur.
From this we infer that if spatial data are available at a spacing of D meters, then the maximum
bandwidth in the defined signal will be W = 1/(2D) cycles per meter, corresponding to k = 2 W radians
per meter.
Combining these two items, we wish to infer a value of that will damp components of U with frequencies
above W. However, the Laplacian filter does not have a sharp cutoff at any frequency, so we have some
latitude in assigning .
Let us find such that the frequency component at frequency W is attenuated by a factor N, ie.
1/(1 + 4 2W2) = 1/N, with 1/(2W) = D.
Then = (N-1)/(4 2W2) = D2(N-1)/ 2.
In the solution of partial differential equation systems, it sometimes happens that auxiliary equations must be
solved simultaneously with the PDE, and that these auxiliary equations have no spatial coupling, being point
relations or other zero-order equations. In these cases, the finite element method works poorly, because
the discretization is based on integrals over space, and oscillatory solutions can satisfy the integrals. In such
systems, we are justified in adding to the equation a diffusion operator to impose a smoothing on the
solution. If we have, for example,
U = F(..)
then we can replace this equation with
U - (D2/ 2) 2 U = F(..), with D the approximate spatial wavelength of acceptable oscillations.
Suppose we have a system v/ t = f, in which the discretized equations support high frequency solutions
which destabilize the numerical solution process. We wish to damp high frequency components.
2
We define u from the relation u/ t - u = v/ t
2
then Uk exp(ik(x-ct)) ( -ikc + k ) = Vk exp(i k (x-ct))(-ikc).
2
Or, |Uk | = |Vk |/sqrt(1 + k2/c2)
2
1/sqrt(1 + k2/c2).
or approximately, = 2Dc/ .
2
We can now solve the equation u/ t - u = f, with the expectation that u will be a frequency-
351 FlexP DE 7 : Technical Notes
filtered representation of v.
In some cases, a steady-state limit of a known time-dependent system is desired, but while the time-
dependent equation itself is stable, the steady-state equation which results from merely setting the time
derivative to zero is not. In these cases, we can replace the time derivative by - 2 u, again with the
expectation that u will be a frequency-filtered representation of v.
DOMAIN REVIEW
The first facility that users should be aware of is the "Domain" item on the main menu bar. Selecting this
item instead of "Run" will give the user a step-by-step review of the mesh generation process. This
review reflects the order of operations performed by the mesh generator.
The first sequence of displays shows the domain boundaries in the surfaces and layers of the extrusion.
The first plot shows the domain boundaries present in the bottom surface; the next shows the
boundaries which extend through the first layer; then the boundaries present in the second extrusion
surface; and so on through entire domain, and ending with the top surface. You should examine each
of these displays to determine that the structure is as you intended. Errors at this point can create
serious trouble later.
After the individual surfaces and layers are displayed, a composite 3D display is presented of the total
domain, as represented by boundaries. This plot can be rotated to examine all aspects of the domain.
The next sequence of displays shows the triangular surface meshes created for the extrusion surfaces.
These meshes are created and displayed in 3D space, and can be rotated to be sure there are no
anomalies in the construction. Following initial surface mesh creation, the meshes are refined to create
sufficient resolution of surface curvature. They are then analyzed for proximity, and coarser meshes
are refined due to influence from nearby dense meshes.
The next sequence of displays shows the creation of the tetrahedral 3D meshes for each of the regions
and layers of the domain. Before a block is filled, the bounding surface is shown; after filling, the filled
block is displayed (it looks the same). The sequence presents first the region blocks for layer 1,
followed by a unified mesh of layer 1. This pattern is repeated through the layers of the domain, until
Technical Notes : 3D Mesh G eneration 352
finally a unified 3D mesh is displayed. At this point, the mesh is composed of linear (straight-sided)
tetrahedra.
Once the domain is filled with linear tetrahedra, the additional nodes needed for quadratic or cubic
interpolation. Cells are also bent at this point to conform to curved boundaries. This curving can
create troubles in thin curved shells. The 3D mesh generator is not yet smart enough to compute shell
thickness and curvature and automatically adapt the size. You may have to do it manually with the
MESH_SPACING command. Sqrt(Radius*thickness) is a good rule of thumb.
This completes the mesh generation process, and solution should proceed promptly.
You can localize the problem areas by building your domain one layer at a time. Build the first layer
and examine the regional meshes for compliance with your expectations. Then add the next layer.
You might at this point want to hide the first layer, so you can deal with the second layer as an
independent item.
Spatial Error
The Galerkin Finite Element method uses integrals of the PDE's to form the discretized equations at the
mesh nodes.
Each nodal equation requires that the weighted integral of the associated equation over the mesh cells
surrounding the node be satisfied within a convergence tolerance. In FlexPDE this tolerance is taken to
353 FlexP DE 7 : Technical Notes
In a regular hexagonal 2D mesh, for example, the Galerkin method requires that each hexagonal set of
six triangular mesh cells must produce a weighted integral residual of zero.
This method at no point imposes any conditions on the integral over a single mesh cell, and conceivably
on could have cancelling errors in adjacent cells.
In FlexPDE, we choose to use the individual cell integrals as a measure of the mesh quality. If the
aggregate (eg 6-cell) integral is correct but the individual cells show large error, then the mesh must be
refined.
The fundamental system which is solved by FlexPDE can be indicated as R=G(U)=0, where R is the
residual and G(U) is the Galerkin integral of the PDE for variable U. If the residual over an individual cell
is R, we can write J*dU=R, where J is the Jacobian matrix of derivatives of the Galerkin integral with
respect to the nodal values, and dU is the error in U which produces the residual R.
J is of course the coupling matrix which is solved to produce the solution U. We don't want to completely
repeat the solution process just to get an error estimate, so we use various simply-computed
approximations J' of J, to produce the error estimate dU=Inv(J')*R.
The "RMS Error" reported by FlexPDE in the Status Panel is just the root-mean-square average of dU/
range(U) over the cells of the problem, while the reported "MAX Error" is the largest error dU/
range(U) seen in any cell.
Mesh cells for which dU/range(U) > ERRLIM are split in the mesh refinement pass.
Notice that the error measure is not a guarantee that the computed solution is "accurate" to within the
stated error, that is, that the computed solution differs from the "true" solution by no more than the stated
error. The error estimate is a local measure of how much variation of the solution would produce the
computed error in the cell integral. Deviations from the "true" solution might accumulate over the domain
of the problem, or they might cancel in neighboring regions.
Temporal Error
In time dependent problems, an estimate must also be formed of the error in integrating the equations in
time.
FlexPDE integrates equations in time using a second-order implicit Backward Difference Formula (Gear
method).
In order to measure temporal error, FlexPDE stores an additional timestep of values previous to the
three points of the quadratic solution, and fits a cubic in time to the sequence at each node. The size of
the cubic term implies the error in the quadratic solution, and is used to either increase or decrease the
timestep in order to keep the RMS temporal error within the range specified by ERRLIM.
Technical Notes : Interpreting Error Estimates 354
The three-point integration method requires an independent method to create data for the initial interval.
FlexPDE uses a comparison of one-step and two-step trapezoidal rule integration to adapt the initial
timestep to a range that produces acceptable error.
There are several SELECT controls that can be used to alter the behavior of FlexPDE in regard to error
measures.
The basic control is ERRLIM, which specifies the desired relative error in the solution variables, and
controls both spatial and temporal measures. Smaller ERRLIM causes more mesh subdivision and smaller
timesteps. Larger ERRLIM allows cruder meshes and, in principle, larger timesteps. However, a large
ERRLIM can allow oscillations to develop, ultimately causing severe timestep cuts and a slower overall
execution. It is rarely advisable to use an ERRLIM value larger than the default 0.002.
XERRLIM and TERRLIM are analogous to ERRLIM, but refer specifically to the spatial and temporal
controls, allowing separate control of the two processes. If either of these controls is absent, it defaults to
the value of ERRLIM.
It is possible that FlexPDE will eventually implement automatic coordinate scaling, but in the meantime,
users can implement it manually.
div(k*grad(T))+Q = C*dt(T)
z = s*w
where w is the physical coordinate, z is the FlexPDE coordinate, and s is a scaling factor.
The expanded physical equation is then
355 FlexP DE 7 : Technical Notes
We can transform the heat equation using this transformation and observing that
The result is
Flux Conservation
In forming the finite element model for this equation, FlexPDE assumes continuity of the surface integrals
generated by integration-by-parts of the second-order terms (equivalent in this case to the Divergence
Theorem). This is the Natural Boundary Condition for the equation, as discussed elsewhere in the
FlexPDE documentation.
The z-directed flux terms in the transformed equation therefore assume that s^2*k*dz(T) is continuous
across cell interfaces. This is equivalent to flux conservation in the physical system as long as s is
constant throughout the domain.
In order to guarantee conservation of flux in the presence of differing scale factors in layers, we must
have the following equality across an interface between materials 1 and 2:
k1*dw(T)1 = k2*dw(T)2
or
k1*s1*dz(T)1 = k2*s2*dz(T)2
Un-Scaling Fluxes
Fluxes appropriate to the unscaled system can be recovered by the same modifications as those made in
the PDE:
Fluxes in the scaled direction must be multiplied by the scale factor. Integrals of these fluxes need not
be further modified, as they are integrated over surfaces in true coordinates.
Fluxes in the unscaled directions are correctly computed in true coordinates, but when integrated over
surfaces, they must be divided by the scale factor to account for the scaled area.
Flux integrals then appear in the same form as in the scaled PDE:
Total_Real_Flux = Surf_Integral(NORMAL(-k*dx(T)/s, -k*dy(T)/s, -k*dz(T)*s)
Technical Notes : C oordinate Scaling 356
The natural boundary condition defines the argument of the outermost derivative operator (or the
argument of the divergence). In the conservative equation (2):
Components in the unscaled direction have been divided by s. Therefore the natural boundary
conditions for these components must be divided by s. (e.g. NATURAL(T) = x_flux/s on x-normal
surfaces.)
In the scaled direction, the value defined by the natural is k*s*dz(T) which is in fact k*dw(T), the flux
in the physical coordinate system. The natural in the scaled direction is therefore unmodified by the
scaling. (e.g. NATURAL(T) = z_flux on z-normal surfaces.)
Examples
"Samples | Usage | Coordinate_Scaling | Scaled_Z.pde" 535 shows the implementation of this technique.
"Samples | Usage | Coordinate_Scaling | UnScaled_Z.pde" 537 provides an unscaled reference for
comparison.
Use JASC AnimationShop to assemble the individual files into a GIF animation.
Use GIF2SWF or other conversion program to create Flash animations.
Parentheses
Parens "( )" are no longer interchangeable with square brackets "[ ]". In particular,
Square brackets can no longer be used in expression grouping. They are reserved for array and
matrix indexing.
Parentheses can no longer be used for array indexing. Only square brackets will serve in this capacity.
Exponentiation
Double-asterisk "**" can no longer be used as an exponentiation operator. Double-asterisk is now the
matrix multiply operator. Use the caret "^" for exponentiation.
Solution Controls
Error estimation algorithms are somewhat different, and may result in somewhat shorter timesteps and
longer running for time-dependent problems. These changes were made in the interest of more truthful
reports of error.
The selector NRMATRIX has been changed to an ON/OFF selector REMATRIX which selects
recomputation of the Jacobian matrix on every Newton iteration. The default is OFF. Even without
this selector, FlexPDE will recompute the Jacobian matrix whenever the variable changes are greater
than an internal threshold.
Nonlinear time-dependent problems default to one Newton step per timestep, with timestep controls
to cut the timestep if convergence is not readily achieved. This is usually a more efficient scheme than
other alternatives. The Selector NEWTON=number is available for specifying a more strenuous
convergence policy. The Selector PREFER_STABILITY can be used to allow up to 5 Newton
iterations per timestep, with full re-computation of the Jacobian matrix on each iteration. This is the
most expensive option, but should provide the most stable operation.
Reserved Names
The names REAL and IMAG can no longer be used as user-defined values. They are now built-in
component selectors for Complex data types. See the list of Reserved Words 155 for other changes.
FEM Basis
Version 7 now uses a hierarchical basis system. Higher order components of the interpolation are now
the coefficients of higher order terms in the polynomial approximation, not additional nodal values. As
a result, the “Nodes” report in the Status panel is not directly comparable to the report in version 6.
The new "DOF" (degrees of freedom) report in version 7 is directly comparable to the version 6
"Nodes" report.
Cubic basis is now the default. To replicate the behavior of version 6, you must either specify
“quadratic” in the Select section, or use the preference panel to default to order=2. The cubic model
will run somewhat longer than a quadratic model on the same mesh. However, the cubic model can
return accurate results on a smaller mesh than the quadratic model. Actual results will be problem
dependent.
File Consolidation
Version 7 by default creates a subdirectory (<problem name>_output) for each script that is run, and
into which all the associated output files are written (this default can be changed in the Preferences
control 29 ). Scripts that TRANSFER files from other runs need to provide the proper path to find the
appropriate import files.
Solution Controls
Error estimation algorithms are somewhat different, and may result in different behavior than with
previous versions. Our goal is to make the behavior consistent across versions, but this is not always
possible for all problems.
Reserved Names
In previous versions, the names LAMBDA and MODE were activated only in eigenvalue problems.
In version 7, they are always reserved and can no longer be used as user-defined values. See the list
of Reserved Words 155 for other changes.
Part
V
Sample Problems
361 FlexP DE 7 : Sample P roblems
5 Sample Problems
The standard distribution of FlexPDE includes over one hundred example scripts, showing the
application of FlexPDE to many areas of study. These sample problems have been prepared by PDE
Solutions staff and show various applications of FlexPDE, or illustrate features or techniques.
Many of these problems contain commentary describing the derivation of the model. All are keyed for
execution in Professional mode by the Lite version of FlexPDE. These scripts are installed by the
standard installation procedure. Modifying a copy of an existing descriptor is frequently the most
efficient way to start building a descriptor for a new problem. On Windows, sample scripts are installed
in the "FlexPDE7 user" folder in the user's home folder as well as in the FlexPDE installation folder. The
copy in the installation folder can be used as master copies.
Also included in the distribution, in the "Backstrom_Books" folder, are many samples from books written
by Prof. Gunnar Backstrom showing the use of FlexPDE in a variety of fields. See Backstrom's books
online at http://www.amazon.com/Gunnar-Backstrom/e/B003B80CE2/.
5.1 Applications
5.1.1 Chemistry
5.1.1.1 chem burn
{ CHEMBURN.PDE
This problem models an extremely nonlinear chemical reaction in an open tube
reactor with a gas flowing through it. The problem illustrates the use of
FlexPDE to solve mixed boundary value - initial value problems and involves
the calculation of an extremely nonlinear chemical reaction.
While the solutions sought are the 3D steady state solutions, the problems
are mixed boundary value / initial value problems with vastly different
phenomena dominating in the radial and axial direction.
The equations model a cross-section of the reactor which flows with the
gas down the tube. There is therefore a one to one relation between the
time variable used in the equations and distance down the tube given by
z = v*t.
The chemical reaction has a reaction rate which is exponential in
temperature, and shows an explosive reaction completion, once an
'ignition' temperature is reached. The problem variable 'C' represents
the fractional conversion (with 1 representing reaction completion).
The reaction rate 'RC' is given by
RC(C,Temp) = (1-C)*exp[gamma*(1-1/Temp)]
where the parameter GAMMA is related to the activation energy of the
reaction.
The gas is initially at a temperature of 1, in our normalized units, with
convective cooling at the tube surface coupled to a cooling bath at a
temperature of 0.92.
The problem is cylindrically symmetric about the tube axis. Because of
the reaction the axis of the tube will remain hotter than the periphery,
and eventually the reaction will ignite on the tube axis, sending
completion and temperature fronts propagating out toward the wall. For
small GAMMA, these fronts are gentle, but for GAMMA greater than about
twelve the fronts becomes very steep and completion is reached rapidly
Sample P roblems : Applications 362
and sharply creating very rapid transition from a very high reaction rate
reaction rate to a zero reaction rate. The adaptive gridding and
adaptive evolution 'time' stepping capabilities of FlexPDE come into
play in this extreme nonlinear and process nonisotropic problem,
allowing a wave of dense gridding in time to accompany the completion
and temperature fronts across the tube.
In this problem we introduce a heating strip on the two vertical
faces of the tube, for a width of ten degrees of arc. These strips are
held at a temperature of 1.2, not much above the initial gas temperature.
The initial timesteps are held small while the abrupt temperature gradient
at the heating strips diffuses into the gas.
As the cross-section under study moves down the reactor, the heat generated
by the reaction combines with the heat diffusing in from the strip heater to cause
ignition at a point on the x-axis and cause the completion front and temperature
front to progate from this point across the cross-section.
We model only a quarter of the tube, with mirror planes on the X- and Y-axes.
The calculation models a cross-section of the tube, and this cross-section
flows with the gas down the tube.
The "cycle=10" plots allow us to see the flame-front propagating across
the volume, which happens very quickly, and would not be seen in a
time-interval sampling.
While the magnitudes of the numerical values used for the various
constants including gamma are representative of those found with real
reactions and real open tube reactors they are not meant to represent
a particular reaction or reactor.
}
title
'Open Tube Chemical Reactor with Strip Heater'
select
painted { make color-filled contour plots }
variables
Temp(threshold=0.1)
C(threshold=0.1)
definitions
Lz = 1
r1=1
heat=0
gamma = 16
beta = 0.2
betap = 0.3
BI = 1
T0 = 1
TW = 0.92
{ the very nasty reaction rate: }
RC = (1-C)*exp(gamma-gamma/Temp)
xev=0.96 { some plot points }
yev=0.25
initial values
Temp=T0
C=0
equations
Temp: div(grad(Temp)) + heat + betap*RC = dt(Temp)
C: div(grad(C)) + beta*RC = dt(C)
boundaries
region 1
start (0,0)
time 0 to 1
plots
for cycle=10 { watch the fast events by cycle }
grid(x,y)
contour(Temp) fixed range (0.9,2.5)
contour(C) as "Completion" fixed range(0,1.1)
for t= 0.1 by 0.05 to 0.2 by 0.01 to 0.3 0.5 endtime { show some surfaces during burn
}
contour(Temp) fixed range (0.9,2.5)
surface(Temp) fixed range (0.9,2.5)
contour(C) as "Completion" fixed range(0,1.1)
surface(C) as "Completion" fixed range(0,1.1)
histories
history(Temp) at (0,0) (xev/2,yev/2) (xev,yev) (yev/2,xev/2) (yev,xev)
history(C) at (0,0) (xev/2,yev/2) (xev,yev) (yev/2,xev/2) (yev,xev) as "Completion"
end
5.1.1.2 m elting
{ MELTING.PDE
This problem shows the application of FlexPDE to the melting of metal.
We choose as our system variables the temperature, "temp", and the
fraction of material which is solid at any point, "solid".
The temperature is given by the heat equation,
first freezes onto the disk, but after equilibrium is reached all the material
is liquid. The outer boundary is insulated.
Since the initial condition is a discontinuous distribution, we use a separate
REGION 229 to define the cold initial disk, so that the grid lines will follow the
shape. We also add a FEATURE 233 bounding the disk to help the gridder
define the abrupt transition. SELECT 183 SMOOTHINIT 183 helps minimize
interpolator overshoots.
}
TITLE
'Melting Metal'
COORDINATES
ycylinder('r','z')
SELECT
smoothinit
threads=2
VARIABLES
temp(threshold=1)
solid(threshold=0.01)
DEFINITIONS
Qm= 225000 { latent heat }
Tm=1850 { Melting temperature }
T0= 20 { Melting interval +- T0 }
temp_liq=2000 { initial liquid temperature }
temp_sol=400 { initial solid temperature }
Tinit
R_inf = 0.7 { Domain Radius m}
{ plate }
d=0.05
dd = d/5 { a defining layer around discontinuity }
R_Plate=0.15
K = 30+4.5e-5*(temp-1350)^2 { Conductivity }
rho=2500 { Density kg/m3 }
cp = 700 { heat capacity }
INITIAL VALUES
temp=Tinit
solid = 0.5*erfc((tinit-Tm)/T0)
EQUATIONS
temp: rho*cp*dt(temp) - div(K*grad(temp)) = Qm*dt(solid)
solid: solid - 1e-6*div(grad(solid)) = RAMP((temp-Tm), 1, 0, T0)
BOUNDARIES
region 'Outer'
Tinit = temp_liq
start 'outer' (0,-R_inf)
value(temp)= temp_liq arc(center=0,0) angle 180
natural(temp)=0 line to close
region 'Plate'
Tinit = temp_sol
start(0,0)
mesh_spacing=dd
line to (R_Plate,0) to (R_Plate,d) to (0,d) to close
TIME 0 by 1e-5 to 600
MONITORS
for cycle=10
grid(r,z) zoom (0,-0.1,0.25,0.25)
elevation(temp) from(0.1,-0.1) to (0.1,0.15) range=(0,2000)
elevation(solid) from(0.1,-0.1) to (0.1,0.15) range=(0,1)
PLOTS
365 FlexP DE 7 : Sample P roblems
for t= 0 1e-4 1e-3 1e-2 0.1 1 10 by 10 to 100 by 100 to 300 by 300 to endtime
contour(temp) range=(0,2000)
contour(temp) zoom (0,-0.2,0.45,0.45) range=(0,2000)
elevation(temp) from(0.1,-0.1) to (0.1,0.15) range=(0,2000)
contour(solid) range=(0,1)
contour(solid) zoom (0,-0.2,0.45,0.45) range=(0,1)
surface(solid) zoom (0,-0.2,0.45,0.45) range=(0,1) viewpoint(1,-1,30)
elevation(solid) from(0.1,-0.1) to (0.1,0.15) range=(0,1)
HISTORIES
history(temp) at (0.051,d/2) (0.075,d/2) (R_plate,d/2)
history(temp) at (0.051,d) (0.075,d) (R_plate,d)
history(solid) at (0.051,d/2) (0.075,d/2) (R_plate,d/2)
history(solid) at (0.051,d) (0.075,d) (R_plate,d)
history(integral(cp*temp+Qm*(1-solid))) as "Total Energy"
END
5.1.1.3 reaction
{ REACTION.PDE
This example shows the application of FlexPDE to the solution
of reaction-diffusion problems.
We describe three chemical components, A,B and C, which react and
diffuse, and a temperature, which is affected by the reactions.
I) A combines with B to form C, liberating heat.
II) C decomposes to A and B, absorbing heat. The decomposition rate
is temperature dependent.
III) A, B, C and Temperature diffuse with differing diffusion constants.
The boundary of the vessel is held cold, and heat is applied
to a circular exclusion patch near the center, intended to model an
immersion heater.
A, B and C cannot diffuse out the boundary.
The complete equations including the Arrhenius terms that describe
the system are:
div(Kt*grad(Temp)) + heat + K1*exp(-H1/(Temp+273))*eabs*A*B
- K2*exp(-H2/(Temp+273))*eabs*C*(Temp+273) = 0
div(Ka*grad(A)) - K1*exp(-H1/(Temp+273))*A*B
+ K2*exp(-H2/(Temp+273))*C*(Temp+273) = 0
div(Kb*grad(B)) - K1*exp(-H1/(Temp+273))*A*B
+ K2*exp(-H2/(Temp+273))*C*(Temp+273) = 0
div(Kc*grad(C)) + K1*exp(-H1/(Temp+273))*A*B
- K2*exp(-H2/(Temp+273))*C*(Temp+273) = 0
where Kt,Ka,Kb and Kc are the diffusion constants, EABS is the heat
liberated when A and B combine, and HEAT is any internal heat source.
Notice that the system is non-linear, as it contains terms involving
A*B and C*Temp.
There are an infinite number of solutions to these equations, differing
only in the total particle count. In reality, since particles are
conserved, the final solution is uniquely determined by the initial
conditions. But this fact is not embodied in the steady-state equations.
The only way to impose this condition on the steady-state system
is through an integral constraint equation, which describes the
conservation of total particle number.
}
title "Chemical Beaker"
variables { declare the system variables }
temp,a,b,c
definitions
Sample P roblems : Applications 366
5.1.2 Control
5.1.2.1 control_steady
{ CONTROL_STEADY.PDE
This example shows the use of a GLOBAL VARIABLE 199 in a control application.
It is analogous to the example USAGE/OPTIMIZATION/POWER_CONTROL.PDE 620 .
We wish to find the required power input to a heater, such that the resulting
average temperature over the domain is a specified value.
Notice that the equation nominally defining power does not explicitly reference
the power variable, but is coupled through the heat term in the temperature
equation.
}
TITLE "steady-state Control test"
VARIABLES
temp { The temperature field }
GLOBAL VARIABLES
power { a single value for input power }
DEFINITIONS
setpoint=700 { the desired average temperature }
skintemp=325 { fixed outer boundary temperature }
k=1 { conductivity }
heat=0 { the heat function for the temperature.
it is non-zero only in the heater region }
tcontrol=integral(temp)/integral(1) { the control function, average temperature }
{ tcontrol=val(temp,0,0) -- an alternative control method, unused here }
INITIAL VALUES
temp = setpoint
power= 100 { initial guess for power }
EQUATIONS
temp: div(-k*grad(temp))-heat = 0 { diffusion of temperature field }
power: tcontrol = setpoint { single equation defining power }
BOUNDARIES
REGION 'Insulation'
k=0.1
heat=0
start(-4,-4)
value(temp)=skintemp
line to (4,-4) to (4,4) to (-4,4) to close
REGION 'Heater'
k=50
heat=power
start(-1,-1) line to (1,-1) to (1,1) to (-1,1) to close
MONITORS
contour(temp)
report power
report tcontrol
PLOTS
contour(temp)
report power
report power*integral(1,'Heater') as "Total Power"
report tcontrol as "Average Temp"
elevation(temp) from(-4,0) to (4,0)
elevation(temp) from(-4,-4) to (4,4)
summary
report power*integral(1,'heater') as "Total Power needed to establish an average
temperature of 700 "
END
Sample P roblems : Applications 368
5.1.2.2 control_transient
{ CONTROL_TRANSIENT.PDE
This example shows the use of a GLOBAL VARIABLE 199 in a control application.
We wish to find the required power input to a heater, such that the resulting
average temperature over the domain is a specified value.
The temperature on the outer surface is prescribed, with a time-sinusoidal
oscillation.
The input power is driven by a time-relaxation equation. The coefficient
of the right hand side is the reciprocal of the response time of the power.
}
TITLE "Time-dependent Control test"
VARIABLES
temp { The temperature field }
GLOBAL VARIABLES
power { a single value for input power }
DEFINITIONS
setpoint = 700 { the desired average temperature }
skintemp = 325+20*sin(t) { oscillating outer boundary temperature }
responsetime = 0.1 { response time of the power input }
k=1 { conductivity }
heat=0 { the heat function for the temperature.
it is non-zero only in the heater region }
{ the control function, average temperature }
tcontrol = integral(temp)/integral(1)
{ tcontrol = val(temp,0,0) -- an alternative control method, which tracks the
temperature value at a specified point (unused here) }
{initial guess for temperature distribution }
tinit1=min(1767-400*abs(x), 1767-400*abs(y))
INITIAL VALUES
temp=min(1500,tinit1)
power=137 { initial guess for power }
EQUATIONS
temp: div(-k*grad(temp))-heat = 0 { diffusion of temperature field }
{ single equation defining power. response time is 1/100 }
power: dt(power) = (setpoint - tcontrol)/responsetime
BOUNDARIES
REGION 'Insulation'
k=0.1
heat=0
start(-4,-4)
value(temp)=skintemp
line to (4,-4) to (4,4) to (-4,4) to close
REGION 'Heater'
k=50
heat = power
start(-1,-1) line to (1,-1) to (1,1) to (-1,1) to close
TIME 0 to 20 by 1e-4
PLOTS
for cycle=10
contour(temp)
report power
report tcontrol as "Avg Temp"
HISTORIES
History(tcontrol-setpoint, skintemp-325) as "Skin Temperature and Error"
369 FlexP DE 7 : Sample P roblems
5.1.3 Electricity
5.1.3.1 3d_capacitor
{ 3D_CAPACITOR.PDE
MONITORS
CONTOUR(V) ON Y=2.5
PLOTS
GRID(X,Z) ON Y=2.5
CONTOUR(V) ON X=2.5 REPORT(C) as "Capacitance(uF)"
CONTOUR(V) ON Y=2.5 REPORT(C) as "Capacitance(uF)"
CONTOUR(V) ON Z=1.5 REPORT(C) as "Capacitance(uF)"
CONTOUR(1/K) ON Y=2.5 as "Material"
END
5.1.3.2 3d_capacitor_check
{ 3D_CAPACITOR_CHECK.PDE
This problem shows a parallel-plate capacitor, and compares the computed
capacitance to the ideal value.
}
TITLE '3D Capacitor validation'
COORDINATES
CARTESIAN3
SELECT
{ rename the axes }
alias(x) = "X(mm)"
alias(y) = "Y(mm)"
alias(z) = "Z(mm)"
{ paint all contours }
PAINTED
VARIABLES
V
DEFINITIONS
Kmetal=1e6
Kdiel = 88 { Water @ 0 C }
Kair=1
5.1.3.3 3d_dielectric
{ 3D_DIELECTRIC.PDE
variables
V
definitions
eps = 1
equations
div(eps*grad(V)) = 0 { Potential equation }
extrusion
surface "bottom" z=0
surface "dielectric_bottom" z=0.1
layer "dielectric"
surface "dielectric_top" z=0.2
surface "top" z=0.3
boundaries
surface "bottom" natural(V)=0
surface "top" natural(V)=0
region 1
start (0,0)
value(V) = 0 line to (1,0)
natural(V) = 0 line to (1,1)
value(V) = 100 line to (0,1)
natural(V) = 0 line to close
region 2
layer "dielectric" eps = 50
start (0.4,0.4)
line to (0.8,0.4) to (0.8,0.8) to (0.6,0.8)
to (0.6,0.6) to (0.4,0.6) to close
monitors
contour(V) on z=0.15 as 'Potential'
plots
contour(V) on z=0.15 as 'Potential'
vector(-dx(V),-dy(V)) on z=0.15 as 'Electric Field'
contour(V) on x=0.5 as 'Potential'
end
5.1.3.4 capacitance
{ CAPACITANCE.PDE
SELECT
errlim 1e-4
thermal_colors on
plotintegrate off
VARIABLES
v
DEFINITIONS
mm = 0.001 ! meters per millimeter
Lx = 300 * mm ! enclosing box dimensions
Ly = 150 * mm
b = 0.7 ! radius of conductor / radius of entire cable
x0 = 0.25 * Lx ! position and size of cable raised to fixed potential
y0 = 0.5 * Ly
r0 = 15 * mm
x1 = 0.9 * Lx
y1 = 0.3 * Ly
r1 = r0
epsr ! relative permittivity of any particular region
epsd = 3 ! relative permittivity of cable dielectric
373 FlexP DE 7 : Sample P roblems
energyDensity = dot( eps * grad( v), grad( v))/2 ! field energy density
EQUATIONS
div( eps * grad( v)) = 0
BOUNDARIES
region 1 'inside' epsr = 1
start 'outer' ( 0, 0) value( v) = 0
line to ( Lx, 0) line to ( Lx, Ly) line to ( 0, Ly) line to close
region 2 'diel0' epsr = epsd
start 'dieb0' ( x0 + r0, y0)
arc ( center = x0, y0) angle = 360
region 3 'cond0' epsr = 1
start 'conb0' ( x0 + b * r0, y0) value( v) = v0
arc ( center = x0, y0) angle = 360
region 4 'diel1' epsr = epsd
start 'dieb1' ( x1 + r1, y1)
arc ( center = x1, y1) angle = 360
region 5 'cond1' epsr = 1000 ! fake metallic conductor
start 'conb1' ( x1 + b * r1, y1)
arc ( center = x1, y1) angle = 360
PLOTS
grid(x,y) zoom(x0-1.1*r0, y0-1.1*r0, 2.2*r0) ! 3-term zoom generates a square
window }
contour( v) as 'Potential'
contour( v) as 'Potential Near Driven Conductor'
zoom(x0-1.1*r0, y0-1.1*r0, 2.2*r0)
contour( v) as 'Potential Near Floating Conductor'
zoom(x1-1.1*r1, y1-1.1*r1, 2.2*r1)
elevation( v) as 'Potential from Wall to Driven Conductor' from ( 0,y0) to ( x0, y0)
elevation( v) as 'Potential from Driven to Floating Conductor' from ( x0, y0) to ( x1,
y1)
vector( grad( v)) as 'Field'
contour( energyDensity) as 'Field Energy Density' png(3072,2)
contour( energyDensity) as 'Field Energy Density Near Floating Conductor'
zoom(x1-1.2*r1, y1-1.2*r1, 2.4*r1)
elevation( energyDensity) from ( x1 - 2 * r1, y1) to ( x1 + 2 * r1, y1)
as 'Field Energy Density Near Floating Conductor'
contour( epsr) paint on "inside" as 'Definition of Inside'
SUMMARY png(3072,2)
report sintegral( normal( eps * grad( v)), 'conb0', 'diel0') as 'Driven charge'
report sintegral( normal( eps * grad( v)), 'outer', 'inside') as 'Outer charge'
report sintegral( normal( eps * grad( v)), 'conb1', 'diel1') as 'Floating charge'
report sintegral( normal( eps * grad( v)), 'conb0', 'diel0') / v0 as 'Capacitance (f/
m)'
report integral( energyDensity, 'inside') as 'Energy (J/m)'
report 2 * integral( energyDensity, 'inside') / v0^2 as 'Capacitance (f/m)'
report 2 * integral( energyDensity, 'inside') / ( v0 * sintegral( normal( eps *
grad( v)), 'conb0', 'diel0'))
as 'cap_by_energy / cap_by_charge'
END
5.1.3.5 dielectric
{ DIELECTRIC.PDE
This problem shows the electrostatic potential and the electric field
in a rectangular domain with an internal region in which the dielectric
constant is fifty times that of the surrounding material.
The electric field E is -grad(V), where V is the electrostatic potential.
variables V
definitions
eps = 1
equations
div(eps*grad(V)) = 0
boundaries
region 1
start (0,0)
value(V) = 0 line to (1,0)
natural(V) = 0 line to (1,1)
value(V) = 100 line to (0,1)
natural(V) = 0 line to close
region 2
eps = 50
start (0.4,0.4)
line to (0.8,0.4) to (0.8,0.8)
to (0.6,0.8) to (0.6,0.6)
to (0.4,0.6) to close
monitors
contour(V) as 'Potential'
plots
grid(x,y)
contour(V) as 'Potential'
vector(-dx(V),-dy(V)) as 'Electric Field'
end
5.1.3.6 fieldm ap
{ FIELDMAP.PDE
This example shows the use of the adjoint equation to display Electric field
lines and to compare these to the vector plot of E.
The problem shows the electrostatic potential and the electric field
in a rectangular domain with an internal region in which the dielectric
constant is five times that of the surrounding material.
The electric field E is -grad(V), where V is the electrostatic potential.
The adjoint equation method of generating field lines will only work if there
are no internal sources (charged bodies).
title
'Electrostatic Potential and Electric Field'
variables
V
Q
definitions
eps = 1
equations
{ Potential equation }
V: div(eps*grad(V)) = 0
then
{ adjoint equation }
Q: div(grad(Q)/eps) = 0
boundaries
region 1
start (0,0)
value(V) = 0
natural(Q) = tangential(grad(V))
line to (1,0)
natural(V) = 0
natural(Q) = tangential(grad(V))
line to (1,1)
value(V) = 100
natural(Q) = tangential(grad(V))
line to (0,1)
natural(V) = 0
natural(Q) = tangential(grad(V))
line to close
region 2
eps = 5
start (0.4,0.4)
line to (0.8,0.4) to (0.8,0.8) to (0.6,0.8)
to (0.6,0.6) to (0.4,0.6) to close
end
5.1.3.7 plate_capacitor
{ PLATE_CAPACITOR.PDE
This problem computes the field around a plate capacitor.
(adapted from "Fields of Physics on the PC" by Gunnar Backstrom)
}
Sample P roblems : Applications 376
definitions
Lx=1 Ly=1
delx=0.5 d=0.2
ddy=0.2*d
Ex=-dx(u) Ey=-dy(u)
Eabs=sqrt(Ex^2+Ey^2)
eps0=8.854e-12
eps
DEx=eps*Ex DEy=eps*Ey
Dabs=sqrt(DEx^2+DEy^2)
zero=1.e-15
equations
u : div(-eps*grad(u)) = 0
boundaries
Region 1
eps=eps0
start "V0" (-Lx,-Ly)
Load(u)=0
line to (Lx,-Ly) to (Lx,Ly) to (-LX,Ly) to close
start "V1" (-delx/2,-d/2)
value(u)=0
line to (delx/2,-d/2) to (delx/2,-d/2-ddy) to (-delx/2,-d/2-ddy)
to close
start(-delx/2,d/2+ddy)
value(u)=1
line to (delx/2,d/2+ddy) to (delx/2,d/2) to(-delx/2,d/2)
to close
Region 2
eps = 7.0*eps0
start(-delx/2,-d/2)
line to (delx/2,-d/2) to (delx/2,d/2) to(-delx/2,d/2)
to close
monitors
contour(u)
plots
contour(u)
surface(u)
vector(dx(u),dy(u))
fieldmap(u) on "V1" fieldlines=40 as "Field Map"
contour fieldmap(u) on "V1" fieldlines=40 points=400 as "Potential and Field Map"
end
5.1.3.8 space_charge
{ SPACE_CHARGE.PDE
This problem describes the electric field in an insulated cardioid-like
chamber due to an electrode at the tip of the cardioid and a localized
space charge near the center of the body.
Adaptive grid refinement detects the space charge and refines
the computation mesh to resolve its shape.
}
title "Electrostatic Potential with probe and space charge"
377 FlexP DE 7 : Sample P roblems
variables
V
equations
V : div(k*grad(V)) + source = 0
boundaries
region 1
start(xc,yc-smallr)
natural(V) = 0 { -- insulated outer boundary }
arc(center=xc,yc) to (x0,y0)
arc(center=0,0) angle 270
arc(center=xc,-yc) to (xc,smallr-yc)
value(V)=1 { -- applied voltage = 1 on tip }
arc(center=xc,0) angle -180 to close
plots
grid(x,y)
contour(V) as "Potential"
contour(V) zoom(0.2,-0.2,0.4,0.4)
surface(V) viewpoint (0,10,30)
surface(V) zoom(-0.6,-0.2,0.4,0.4)
surface(source) zoom(-0.6,-0.2,0.4,0.4)
end
5.1.4 Fluids
5.1.4.1 1d_eulerian_shock
{ 1D_EULERIAN_SHOCK.PDE
Comparison with shock tube problem of G.A. Sod
gamma = 1.4
smeardist = 0.001 { a damping term to kill unwanted oscillations }
eps = sqrt(gamma)*smeardist { ~ cspeed*dist }
INITIAL VALUES
rho = 1.0 - 0.875*uramp(x-0.49, x-0.51)
u = 0
P = 1.0 - 0.9*uramp(x-0.49, x-0.51)
EQUATIONS
rho: dt(rho) + u*dx(rho) + rho*dx(u) = eps*dxx(rho)
u: dt(u) + u*dx(u) + dx(P)/rho = eps*dxx(u)
P: dt(P) + u*dx(P) + gamma*P*dx(u) = eps*dxx(P)
BOUNDARIES
REGION 1
START(0) point value(u)=0
Line to (len) point value(u)=0
TIME 0 TO 0.375
MONITORS
for cycle=5
elevation(rho) from(0) to (len)
elevation(u) from(0) to (len)
elevation(P) from(0) to (len)
history(rho) at (0.5)
history(u) at (0.48) (0.49) (0.5) (0.51) (0.52)
history(p) at (0.48) (0.49) (0.5) (0.51) (0.52)
history(deltat)
grid(x)
PLOTS
for t=0.143, 0.375
elevation(rho) from(0) to (len)
elevation(u) from(0) to (len)
elevation(P) from(0) to (len)
history(rho) at (0.48) (0.49) (0.5) (0.51) (0.52)
history(u) at (0.48) (0.49) (0.5) (0.51) (0.52)
history(p) at (0.48) (0.49) (0.5) (0.51) (0.52)
END
5.1.4.2 1d_lagrangian_shock
{ 1D_LAGRANGIAN_SHOCK.PDE
This example solves Sod's shock tube problem on a 1D moving mesh.
Mesh nodes are given the local fluid velocity, so the model is fully Lagrangian.
len = 1
gamma = 1.4
smeardist = 0.001 { a damping term to kill unwanted oscillations }
eps = sqrt(gamma)*smeardist { ~ cspeed*dist }
v = 0
rho0 = 1.0 - 0.875*uramp(x-0.49, x-0.51)
p0 = 1.0 - 0.9*uramp(x-0.49, x-0.51)
INITIAL VALUES
rho = rho0
u = 0
P = p0
EULERIAN EQUATIONS
{ equations are stated as appropriate to the Eulerian (lab) frame.
FlexPDE will convert to Lagrangian form for moving mesh }
rho: dt(rho) + u*dx(rho) + rho*dx(u) = eps*dxx(rho)
u: dt(u) + u*dx(u) + dx(P)/rho = eps*dxx(u)
P: dt(P) + u*dx(P) + gamma*P*dx(u) = eps*dxx(P)
xm: dt(xm) = u
BOUNDARIES
REGION 1
START(0) point value(u)=0 point value(xm)=0
line to (len) point value(u)=0 point value(xm)=len
TIME 0 TO 0.375
MONITORS
for cycle=5
elevation(rho) from(0) to (len) range (0,1)
elevation(u) from(0) to (len) range (0,1)
elevation(P) from(0) to (len) range (0,1)
PLOTS
for t=0 by 0.02 to 0.143, 0.16 by 0.02 to 0.375
elevation(rho) from(0) to (len) range (0,1)
elevation(u) from(0) to (len) range (0,1)
elevation(P) from(0) to (len) range (0,1)
grid(x)
END
5.1.4.3 2d_eulerian_shock
{ 2D_EULERIAN_SHOCK.PDE
Comparison with shock tube problem of G.A. Sod
INITIAL VALUES
rho = 1.0 - 0.875*uramp(x-0.49, x-0.51)
u = 0
P = 1.0 - 0.9*uramp(x-0.49, x-0.51)
EQUATIONS
rho: dt(rho)+u*dx(rho) = eps*div(grad(rho)) - rho*dx(u)
u: dt(u)+u*dx(u) = eps*div(grad(u)) - dx(P)/rho
P: dt(P)+u*dx(P) = eps*div(grad(P)) - gamma*P*dx(u)
BOUNDARIES
REGION 1
START(0,0)
Line to (len,0)
Value(u)=0 line to (len,wid)
Natural(u)=0 line to (0,wid) to close
TIME 0 TO 0.375
MONITORS
for cycle=5
elevation(rho) from(0,wid/2) to (len,wid/2)
elevation(u) from(0,wid/2) to (len,wid/2)
elevation(P) from(0,wid/2) to (len,wid/2)
history(rho) at (0.5,wid/2)
history(u) at (0.48,wid/2) (0.49,wid/2) (0.5,wid/2) (0.51,wid/2) (0.52,wid/2)
history(p) at (0.48,wid/2) (0.49,wid/2) (0.5,wid/2) (0.51,wid/2) (0.52,wid/2)
history(deltat)
PLOTS
for t=0.143, 0.375
elevation(rho) from(0,wid/2) to (len,wid/2)
elevation(u) from(0,wid/2) to (len,wid/2)
elevation(P) from(0,wid/2) to (len,wid/2)
history(rho) at (0.48,wid/2) (0.49,wid/2) (0.5,wid/2) (0.51,wid/2) (0.52,wid/2)
history(u) at (0.48,wid/2) (0.49,wid/2) (0.5,wid/2) (0.51,wid/2) (0.52,wid/2)
history(p) at (0.48,wid/2) (0.49,wid/2) (0.5,wid/2) (0.51,wid/2) (0.52,wid/2)
END
TITLE "Piston"
COORDINATES
Ycylinder
SELECT
regrid=off { disable the adaptive mesh refinement }
painted { paint all contours }
DEFINITIONS
my_ngrid = 30 { later applied to the NGRID control and smoother }
stroke = 8 { cylinder stroke cm }
rad = 4 { cylinder bore radius cm }
zraise = 1 { raised height of piston center }
rraise = 3*rad/4 { radius or raised piston center }
gap = 2 { piston/head clearance }
gamma = 1.4
rho0 = 0.001
P0 = 100 { initial pressure (dyne/cm2) = 1e-4 Atm }
visc = 0.15 { kinematic viscosity, cm^2/sec }
rpm = 1000 { compressor speed }
381 FlexP DE 7 : Sample P roblems
5.1.4.5 3d_flowbox
{ 3D_FLOWBOX.PDE
This problem demonstrates the use of FlexPDE in 3D fluid flow. It shows the flow of
fluid
through a plenum box with a circular inlet at the bottom and an offset circular outlet
at the top.
The corners of the duct are beveled to remove discontinuities in the flow, and the
inlet pressure
is arbitrarily set at 0.05 units.
The solution uses a "penalty pressure", in which the pressure variable is used merely
to guarantee
mass conservation. This technique is described in more detail in VISCOUS.PDE.
The order of interpolation is staged from linear to quadratic to cubic, which allows
FlexPDE
to solve for the general distribution with far fewer unknowns, and then solve for more
detail
in later stages.
}
title '3D flow through a plenum'
coordinates
cartesian3
variables
v(1e-6) = vector(vx,vy,vz)
p
select
order = staged(1,2,3)
regrid = off
definitions
long = 2
wide = 1
high = 1/2
xin = -1 yin = 0
xout = 1 yout = 0
rc = 0.5
duct = 0.2
{ construct beveled surface }
b = 0.05 ! duct bevel
r2 = sqrt((x-xin)^2+(y-yin)^2)
H2 = -high-(rc+b)
z2 = max(min(H2+r2,-high),-high-b)
r3 = sqrt((x-xout)^2+(y-yout)^2)
H3 = high+(rc+b)
z3 = min(max(H3-r3,high),high+b)
Pin = 0.05
Pout = 0
initial values
v = vector(0,0,0)
p = Pin+(Pout-Pin)*(z+high+duct)/(2*high+2*duct)
equations
v: dens*dot(v,grad(v)) + grad(p) - visc*div(grad(v)) = 0
p: div(grad(p)) = PENALTY*div_v
extrusion z = -high-duct,z2,z3,high+duct
boundaries
region 1 { plenum box }
surface 2 value(v) = vector(0,0,0) natural(p)=0
surface 3 value(v) = vector(0,0,0) natural(p)=0
layer 1 void
layer 3 void
start(-long,-wide)
value(v) = vector(0,0,0) natural(p)=0 { fix all side values }
line to (long,-wide)
to (long,wide)
to (-long,wide)
to close
limited region 2 { input hole }
layer 1
surface 1 natural(v) = vector(0,0,0) value(p)=Pin { input duct opening }
start(xin,yin-rc)
layer 1 value(v) = vector(0,0,0) natural(p)=0 { duct sidewall drag }
surface 2 mesh_spacing=rc/2
arc(center=xin,yin) angle=360
limited region 3 { exit hole }
layer 3
surface 4 natural(v) = vector(0,0,0) value(p)=Pout { output duct opening }
start(xout,yout-rc)
layer 3 value(v) = vector(0,0,0) natural(p)=0 { duct sidewall drag }
surface 3 mesh_spacing=rc/2
arc(center=xout,yout) angle=360
limited feature
surface 2
start(xin,yin-rc-b) arc(center=xin,yin) angle=360
limited feature
surface 3
start(xout,yout-rc-b) arc(center=xout,yout) angle=360
monitors
grid(x,z) on y=0
contour(vx) on x=0 report dens report pin
contour(vx) on y=0 report dens report pin
contour(vz) on y=0 report dens report pin
vector(vx,vz)on y=0 report dens report pin
contour(vx) on z=0 report dens report pin
contour(vy) on z=0 report dens report pin
contour(vz) on z=0 report dens report pin
vector(vx,vy)on z=0 report dens report pin
contour(p) on y=0 report dens report pin
contour(div_v) on y=0 report dens report pin
plots
grid(x,z) on y=0
contour(vx) on x=0 report dens report pin
contour(vx) on y=0 report dens report pin
contour(vz) on y=0 report dens report pin
vector(vx,vz)on y=0 report dens report pin
contour(vx) on z=0 report dens report pin
contour(vy) on z=0 report dens report pin
Sample P roblems : Applications 384
summary
report(sintegral(vz,1,2)) as "Inflow"
report(sintegral(vz,4,3)) as "Outflow"
report(sintegral(vz,4,3)/sintegral(vz,1,2)) as "Ratio"
end
5.1.4.6 airfoil
{ AIRFOIL.PDE
This example considers the laminar flow of an incompressible, inviscid
fluid past an obstruction.
end
5.1.4.7 black_oil
{ BLACK_OIL.PDE
This example considers the transport of oil and water in soil.
The model is given in Gelinas, et al, "Adaptive Forward-Inverse Modeling
of Reservoir Fluids Away from Wellbores", (Lawrence Livermore National
Laboratory report UCRL-ID-126377) and in Saad & Zhang, " Adaptive Mesh for
Two-Phase Flow in Porous Media" (in Recent Advances in Problems of Flow and
Transport in Porous Media, Crolet and El Hatri, eds., Kluwer Academic Publishers,
Boston, 1998).
The saturation of water is represented by S, with the saturation of oil defined
as 1-S. The relative permeabilities of water and oil are assumed to be S^2 and
(1-S)^2, respecitvely. The total mobility M is defined as
M = S^2/muw + (1-S)^2/muo,
where muw and muo are the viscosities of water and oil.
The total velocity, V, and the fractional flux, f, are defined as
V = - K*M grad(P)
f = [S^2/muw]/M,
where K represents the saturation-independent permeability coefficient, and
P is the pressure, assuming capillary to be zero and oil and water pressures
equal.
If the porosity Phi is taken as constant and gravity effects are negligible, the
PDE's governing the system reduce to
Phi*dt(S) + div(V*f) = 0
div(V) = 0.
Here we study the flow through a 30-meter box with an inlet pipe in the upper
left and an outlet pipe in the lower right. The box is initially filled with oil,
and water is pumped into the inlet pipe at a constant pressure. Time is measured
in seconds.
-- Submitted by Said Doss, Lawrence Livermore National Laboratory.
}
TITLE 'Black Oil Model'
SELECT
smoothinit { Smooth the initial conditions a little, to minimize
the time wasted tracking the initial discontinuity }
VARIABLES
s(1), p { Saturation and Pressure }
DEFINITIONS
muo = 4.e-3 { oil viscosity }
muw = 1.e-3 { water viscosity }
K = 1.e-12 { Saturation-independent permeability coefficient }
Pin = 1.5e6 { Inlet pressure }
Pout = 1.e6 { Outlet pressure }
M = S^2/muw + (1-S)^2/muo { Total mobility }
f = S^2/muw/M { Fractional flux }
krw = S^2/muw { Relative permeability of water }
phi =.206 { porosity }
xmax = 30 { Box dimensions }
ymax = xmax
out_ctr = 8
tfrac = 2*out_ctr
diam = 2
in_ctr = ymax-out_ctr
rad = diam/5
pipe = 2*rad {an extended inlet and outlet pipe}
epsvisc = 1.e-6 { A little artificial diffusion helps smooth the solution }
Sample P roblems : Applications 386
EQUATIONS
s: phi*dt(s) - div(K*krw*grad(p)) - epsvisc*div(grad(s)) = 0
p: div(K*M*grad(p)) = 0
BOUNDARIES
REGION 1
{ fillet the input pipe, and define
no-flow boundaries of the box }
start(-pipe,in_ctr-diam)
natural(p)=0 natural(s) = 0
line to (0,in_ctr-diam) fillet(rad)
line to (0,0) to (xmax,0)
to (xmax,out_ctr-diam) fillet(rad)
line to (xmax+pipe,out_ctr-diam)
{ set constant outlet pressure, and
"tautological" saturation flux }
value(p) = Pout
natural(s) = -K*krw*dx(p)
line to (xmax+pipe,out_ctr+diam)
{ reset no-flow box boundaries }
natural(p)=0 natural(s)=0
line to (xmax,out_ctr+diam) fillet(rad)
line to (xmax,ymax) to (0,ymax)
to (0,in_ctr+diam) fillet(rad)
line to (-pipe,in_ctr+diam)
{ set constant inlet pressure and saturation
}
value(p) = Pin value(s) = 1
line to close
TIME 0 to 120*day by 10
MONITORS
for cycle=5
contour(s) as "Saturation" range(0,1)
contour(s) zoom(xmax-tfrac+pipe,0, tfrac,tfrac) as "Outflow Saturation"
range(0,1)
contour(p) as "Pressure"
vector(-K*M*grad(p)) norm as "Flow Velocity"
PLOTS
for t = day by day to 20*day
by 10*day to 120*day
grid(x,y)
contour(s) as "Saturation" range(0,1) painted
surface(s) as "Saturation" range(0,1) painted viewpoint(60,-120,30)
contour(s) zoom(xmax-tfrac+pipe,0, tfrac,tfrac) as "Outflow Saturation"
range(0,1) painted
contour(p) as "Pressure" painted
vector(-K*M*grad(p)) norm as "Flow Velocity"
contour(K*M*magnitude(grad(p))) norm as "Flow Speed" painted
HISTORIES
history(sint) at (0,0) as "Extraction"
END
387 FlexP DE 7 : Sample P roblems
The temperature of the system may be found from the heat equation
rho*cp*[dt(T)+U.grad(T)] = div(k*grad(T)) + S
Dropping the time derivative, approximating rho by rho0,
and expanding U in terms of psi, we get
div(k*grad(T)) + S = rho0*cp*[dy(psi)*dx(temp) - dx(psi)*dy(temp)]
If we assume linear expansion of the fluid with temperature, then
rho = rho0*(1+alpha*(T-T0)) and
curl(F) = -g*rho0*alpha*dx(T)
--------------------------
In this problem, we define a trough filled with liquid, heated along a center
strip by an applied heat flux, and watch the convection pattern and the heat
distribution. We compute only half the trough, with a symmetry plane
in the center.
Along the symmetry plane, we assert w=0, since on this plane
dx(v) = 0 and u=0, so dy(u) = 0.
Applying the boundary condition psi=0 forces the stream lines to be parallel
to the boundary, enforcing no flow through the boundary.
On the surface of the bowl, we apply a penalty function to enforce a "no-slip"
Sample P roblems : Applications 388
{ on the arc of the bowl, set Psi=0, and apply a conductive loss to T.
Apply a penalty function to w to force the tangential velocity to zero }
start "outer" (0,0)
natural(temp) = -sigma_bowl*temp
value(psi) = 0
natural(w)= penalty*tangential(curl(psi))
arc (center=0,Rad) to (Lx,Ly)
{ on the top, continue the Psi=0 BC, but add the heat in put term to T,
and apply a natural=0 BC for w }
natural(w)=0
load(temp) = heatin*exp(-(10*x/Lx)^2) - sigma_top*temp
line to (0,Ly)
{ in the symmetry plane assert w=0, with a reflective BC for T }
value(w)=0
load(temp) = 0
line to close
MONITORS
contour(temp) as "Temperature"
contour(psi) as "Stream Function"
contour(w) as "Vorticity"
vector(u,v) as "Flow Velocity" norm
389 FlexP DE 7 : Sample P roblems
PLOTS
grid(x,y)
contour(temp) as "Temperature" painted
contour(psi) as "Stream Function"
contour(w) as "Vorticity" painted
vector(u,v) as "Flow Velocity" norm
contour(dens) as "Density" painted
contour(magnitude(u,v)) as "Speed" painted
elevation(magnitude(u,v)) on "outer"
elevation(temp) on "outer"
END
Here we gradually ramp up the heat input to the level given in the
steady-state problem.
At early times, a single convection cell is established, but at later
times the bottom of the bowl stagnates and establishes the two-cell
flow pattern seen in the steady problem.
}
TITLE 'Buoyant Flow by Stream Function and Vorticity - no slip'
VARIABLES
temp(100)
psi(0.001)
w(1)
DEFINITIONS
Lx = 1 Ly = 0.5
Rad = 0.5*(Lx^2+Ly^2)/Ly
Gy = 980
sigma_top = 0.01 { surface heat loss coefficient }
sigma_bowl = 1 { bowl heat loss coefficient }
k = 0.0004 { thermal conductivity }
alpha = 0.001 { thermal expansion coefficient }
visc = 1
heatin = min(10,t)
t0 = 50
rho0 = 1
rho = rho0*(1 - alpha*temp)
cp = 1
u = dy(psi)
v = -dx(psi)
penalty = 5000
EQUATIONS
temp: div(k*grad(temp)) = rho0*cp*(dt(temp) + u*dx(temp) + v*dy(temp))
psi: div(grad(psi)) + w = 0
w: dt(w) + u*dx(w) + v*dy(w) = visc*div(grad(w)) - Gy*dx(rho)
BOUNDARIES
region 1
{ on the arc of the bowl, set Psi=0, apply conduction loss to T,
and apply penalty function to w to enforce no-slip condition. }
start(0,0)
natural(temp) = -sigma_bowl*temp
value(psi) = 0
natural(w)=penalty*tangential(u,v)
arc (center=0,Rad) to (Lx,Ly)
Sample P roblems : Applications 390
END
{ CAVITY_1K.PDE
This problem computes the flow velocities in a square cavity driven by a velocity
on the top surface, with a Reynolds number of 1000.
The initial conditions are zero interior velocity and zero pressure.
We use a non-dimensional form of the Navier-Stokes equations, with a "penalty
pressure".
The pressure equation simulates a "somewhat compressible" fluid.
Because a very hard incompressibility is subject to instabilities when the
initial condition is far from equilibrium, we stage the pressure penalty,
starting with a very soft fluid and progressing to more and more strict
incompressibility.
As a visual assistance, we also display the stream function and vorticity when each
stage completes.
This is a common test problem, see for example Hendriana and Bathe, Int J Numer Meth
Engng 47, 317-340 (2000)
}
select
ngrid=20
regrid=off
busymon ! display monitors during iteration
variables
u,v
391 FlexP DE 7 : Sample P roblems
p
psi
definitions
Lx=Ly=1
Re = 1000
penalty = staged(1,10,100,1000) ! perform the computation in stages with increasing
pressure penalty
w = dx(v)-dy(u) ! report vorticity
u0 = 1
h=1/10
equations
u: div(grad(u)) - Re*dx(p) = Re*(u*dx(u) + v*dy(u))
v: div(grad(v)) - Re*dy(p) = Re*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
then
psi: div(grad(psi)) +w = 0 ! Report the Stream function
boundaries
region 1
start (0,1)
! left wall
value(u)=0 value(v)=0 ! no fluid slip on bottom and sides
value(psi)=0 ! stream function BC: no flow across walls or top
line to (0,0)
! bottom
value(p)=0 !fix the pressure at the bottom
value(psi)=0
line to(1,0)
! right wall
natural(p) = 0
natural(psi)=normal(-v,u)
line to (1,1)
! open top with imposed velocity
! since a hard shift from 0 to 1 would invite catastrophe, we ramp the driving
velocity to zero at the corners.
value(u) = (1-x)*u0/h
mesh_spacing=h/5 ! more mesh density at the corners helps define the rapid velocity
transitions
line to(1-h,1)
! full driving velocity
value(u)=u0
value(v)=0
mesh_spacing=h
line to(h,1)
! ramp down to zero
value(u) = x*u0/h
mesh_spacing=h/5
line to close
monitors
contour(u) report(Re) report(penalty)
contour(v) report(Re) report(penalty)
contour(p) report(Re) report(penalty)
plots
grid(x,y) report(Re) report(penalty)
contour(u) report(Re) report(penalty)
contour(v) report(Re) report(penalty)
contour(p) report(Re) report(penalty)
vector(u,v) report(Re) report(penalty)
contour(psi) as "Streamlines" report(Re) report(penalty)
contour(w) as "Vorticity" report(Re) report(penalty)
end
Sample P roblems : Applications 392
5.1.4.11 channel
{ CHANNEL.PDE
variables
u(0.1)
v(0.01)
p(1)
definitions
Lx = 5 Ly = 1.5
p0 = 1 { input pressure }
speed2 = u^2+v^2
speed = sqrt(speed2)
dens = 1
visc = 0.04
vxx = -(p0/(2*visc*(2*Lx)))*y^2 { open-channel x-velocity with drag at the bottom }
rball=0.4
cut = 0.1 { value for bevel at the corners of the obstruction }
penalty = 100*visc/rball^2
Re = globalmax(speed)*(Ly/2)/(visc/dens)
initial values
{ In nonlinear problems, Newton's method requires a good initial guess at the solution,
or convergence may not be achieved. You can use SELECT CHANGELIM=0.1 to
force the solver to creep toward a solution from a bad guess.
In our problem, the open channel velocity is a good place to start. }
u = vxx v = 0 p = p0*x/(2*Lx)
equations
u: visc*div(grad(u)) - dx(p) = dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
boundaries
region 1
start(-Lx,0)
value(u) = 0 value(v) = 0 load(p) = 0
line to (Lx/2-rball,0)
to (Lx/2-rball,rball) bevel(cut)
to (Lx/2+rball,rball) bevel(cut)
to (Lx/2+rball,0)
to (Lx,0)
load(u) = 0 value(v) = 0 value(p) = p0
mesh_spacing=Ly/20
line to (Lx,Ly)
mesh_spacing=100
load(p) = 0
line to (-Lx,Ly)
value(p) = 0
line to close
monitors
contour(speed) report(Re)
plots
393 FlexP DE 7 : Sample P roblems
contour(u) report(Re)
contour(v) report(Re)
contour(speed) painted report(Re)
vector(u,v) as "flow" report(Re)
contour(p) as "Pressure" painted
contour(dx(u)+dy(v)) as "Continuity Error"
elevation(u) from (-Lx,0) to (-Lx,Ly)
elevation(u) from (0,0) to (0,Ly)
elevation(u) from (Lx/2,0)to (Lx/2,Ly)
elevation(u) from (Lx,0) to (Lx,Ly)
end
rball=0.4
cut = 0.1 { value for bevel at the corners of the obstruction }
penalty = 100*visc/rball^2
Re = globalmax(speed)*(Ly/2)/(visc/dens)
Kc = 0.01 { contaminant diffusivity }
initial values
u = vxx v=0 p = p0*x/Lx
equations
u: visc*div(grad(u)) - dx(p) = dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
then
c: u*dx(c) + v*dy(c) = div(Kc*grad(c))
boundaries
region 1
start(-Lx,0)
value(u) = 0 value(v) = 0 load(p) = 0 natural(c)=0
line to (Lx/2-rball,0)
to (Lx/2-rball,rball) bevel(cut)
to (Lx/2+rball,rball) bevel(cut)
Sample P roblems : Applications 394
to (Lx/2+rball,0)
to (Lx,0)
mesh_spacing=Ly/20
load(u) = 0 value(v) = 0 value(p) = p0 value(c) = Upulse(y,y-Ly/3)
line to (Lx,Ly)
mesh_spacing = 100
load(p) = 0 natural(c)=0
line to (-Lx,Ly)
value(p) = 0
line to close
monitors
contour(speed)
contour(c)
plots
contour(c) report(Re)
contour(u) report(Re)
contour(v) report(Re)
contour(speed) painted report(Re)
vector(u,v) as "flow" report(Re)
contour(p) as "Pressure" painted
contour(dx(u)+dy(v)) as "Continuity Error"
elevation(u) from (-Lx,0) to (-Lx,Ly)
elevation(u) from (0,0) to (0,Ly)
elevation(u) from (Lx/2,0)to (Lx/2,Ly)
elevation(u) from (Lx,0) to (Lx,Ly)
end
{ COUPLED_CONTAMINANT.PDE
variables
u(0.1)
v(0.01)
p(1)
c(0.01)
definitions
Lx = 5 Ly = 1.5
p0 = 2
speed = sqrt(u^2+v^2)
dens = 1
visc0 = 0.04
visc = visc0*(1+c)
vxx = -(p0/(2*visc*(2*Lx)))*(Ly^2-y^2) { open-channel x-velocity }
rball=0.4
cut = 0.1 { value for bevel at the corners of the obstruction }
penalty = 100*visc/rball^2
Re = globalmax(speed)*(Ly/2)/(visc0/dens)
Initial Values
u=uin
v=vin
p=pin
equations
u: visc*div(grad(u)) - dx(p) = dens*dt(u) + dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*dt(v) + dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
c: dt(c) + u*dx(c) + v*dy(c) = div(Kc*grad(c))
boundaries
region 1
start(-Lx,0)
load(u) = 0 value(v) = 0 load(p) = 0 load(c)=0
line to (Lx/2-rball,0)
value(u) = 0 value(v) = 0 load(p) = 0
mesh_spacing=rball/10 ! dense mesh to resolve obstruction
line to (Lx/2-rball,rball) bevel(cut)
to (Lx/2+rball,rball) bevel(cut)
to (Lx/2+rball,0)
mesh_spacing=100
value(u)=0 value(v)=0 load(p)= 0 load(c)=0
line to(-Lx,Ly)
time 0 to 10
monitors
for cycle = 1
contour(speed) report(Re)
contour(c) range(0,1) report(Re)
elevation(cinput) from (Lx,-Ly) to (Lx,Ly) range=(0,C0)
plots
for t=0 by 0.05 to endtime
contour(u) report(Re)
contour(v) report(Re)
contour(speed) painted report(Re)
vector(u,v) as "flow" report(Re)
contour(p) as "Pressure" painted
contour(dx(u)+dy(v)) as "Continuity Error"
history(integral(c))
history(u) at (0,0.8) (2,0.8) (3,0.8) (4,0.8) (Lx,0)
history(v) at (0,0.8) (2,0.8) (3,0.8) (4,0.8)
Sample P roblems : Applications 396
end
{ COUPLED_CONTAMINANT_INITEQ.PDE
variables
u(0.1)
v(0.01)
p(1)
c(0.01)
definitions
Lx = 5 Ly = 1.5
p0 = 2
speed = sqrt(u^2+v^2)
dens = 1
visc0 = 0.04
visc = visc0*(1+c)
vxx = -(p0/(2*visc*(2*Lx)))*(Ly^2-y^2) { open-channel x-velocity }
rball=0.4
cut = 0.1 { value for bevel at the corners of the obstruction }
penalty = 100*visc/rball^2
Re = globalmax(speed)*(Ly/2)/(visc0/dens)
Initial Values
u = 0.5*vxx v = 0 p = p0*(Lx+x)/(2*Lx)
initial equations
{ solve these steady-state equations to establish initial conditions for the time-
dependent run }
u: visc*div(grad(u)) - dx(p) = dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
equations
u: visc*div(grad(u)) - dx(p) = dens*dt(u) + dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*dt(v) + dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
c: dt(c) + u*dx(c) + v*dy(c) = div(Kc*grad(c))
boundaries
region 1
start(-Lx,0)
load(u) = 0 value(v) = 0 load(p) = 0 load(c)=0
line to (Lx/2-rball,0)
value(u) = 0 value(v) = 0 load(p) = 0
mesh_spacing=rball/10 ! dense mesh to resolve obstruction
line to (Lx/2-rball,rball) bevel(cut)
397 FlexP DE 7 : Sample P roblems
to (Lx/2+rball,rball) bevel(cut)
to (Lx/2+rball,0)
mesh_spacing=100
value(u)=0 value(v)=0 load(p)= 0 load(c)=0
line to(-Lx,Ly)
time 0 to 10
monitors
for cycle = 10
contour(speed) report(Re)
contour(c) range(0,1) report(Re)
elevation(cinput) from (Lx,-Ly) to (Lx,Ly) range=(0,C0)
plots
for t=0 by 0.5 to endtime
contour(c) range(0,1) report(Re)
contour(u) report(Re)
contour(v) report(Re)
contour(speed) painted report(Re)
vector(u,v) as "flow" report(Re)
contour(p) as "Pressure" painted
contour(dx(u)+dy(v)) as "Continuity Error"
history(integral(c))
history(u) at (0,0.8) (2,0.8) (3,0.8) (4,0.8) (Lx,0)
history(v) at (0,0.8) (2,0.8) (3,0.8) (4,0.8)
end
5.1.4.15 flowslab
{ FLOWSLAB.PDE
This problem considers the laminar
flow of an incompressible, inviscid
fluid past an obstruction.
We assume that the flow can be
represented by a stream function, PSI,
such that the velocities, U in the
x-direction and V in the y-direction,
are given by:
U = -dy(PSI)
V = dx(PSI)
The flow can then be described by the
equation
div(grad(PSI)) = 0.
The contours of PSI describe the flow
trajectories of the fluid.
Sample P roblems : Applications 398
5.1.4.16 geoflow
{ GEOFLOW.PDE
In its simplest form, the nonlinear steady-state quasi-geostrophic equation
is the coupled set:
q = eps*del2(psi) + y (1)
J(psi,q) = F(x,y) - k*del2(psi) (2)
5.1.4.17 hy perbolic
{ HYPERBOLIC.PDE
This problem shows the capabilities of FlexPDE in hyperbolic systems.
We analyze a single turn of a helical tube with a programmed flow velocity.
A contaminant is introduced into the center of the flow on the input surface.
Contaminant outflow is determined from the flow equations.
The contaminant concentration should flow uniformly around the helix.
}
title 'Helical Flow: a hyperbolic system.'
select
ngrid=30
regrid=off { Fixed grid works better in hyperbolic systems }
vandenberg { most effective method for hyberbolic systems }
Sample P roblems : Applications 400
variables
u
definitions
Rin = 1
Rout = 2
R0 = 1.5
dR = 0.3 { width of the input contaminant profile }
gap = 10 { angular gap between input and output faces }
gapr = gap*pi/180 { gap in radians }
cg = cos(gapr)
sg = sin(gapr)
pin = point(Rin*cg,-Rin*sg)
pout = point(Rout*cg,-Rout*sg)
r = magnitude(x,y)
v = 1
vx = -v*y/r
vy = v*x/r
q = 0 { No Source }
sink = 0 { No Sink }
initial values
u = 0
equations
u : div(vx*u, vy*u) + sink*u + q = 0
boundaries
region 1
start (Rout,0)
value(u) = 0 { We know there should be no contaminant on walls }
arc(center=0,0) angle=360-gap { positive angle on outside }
nobc(u) { "No BC" on exit plane allows internal solution to dictate outflow }
line to pin
value(u)=0
arc(center=0,0) angle=gap-360 { negative angle on inside }
value(u)=exp(-((x-R0)/dR)^4) { programmed inflow is supergaussian }
line to (1.2,0) to (1.4,0) to (1.6,0) to (1.8,0) to close { resolve shape }
monitors
contour(u)
plots
contour(u) painted
surface(u)
elevation(u) from (Rin,0.01) to (Rout,0.01)
elevation(u) from (0,Rin) to (0,Rout)
elevation(u) from (-Rin,0.01) to (-Rout,0.01)
elevation(u) from (0,-Rin) to (0,-Rout)
elevation(u) from pout to pin
end
5.1.4.18 landfill_gas_flow
{ LANDFILL_GAS_FLOW.PDE
This script solves 2D flow of ideal gas through a porous medium combined of
2 contiguous layers of distinct permeability in elliptic coordinates. The
outermost of the two layers generates gas that flows inwards and is
collected by a pipe in the centre. When the cross-sections are ellipses of
a common focal length f, there are exact solutions available that are used
for verification. Note: the domain appears almost circular, but if the
coordinates are checked carefully, all boundaries are ellipses.
Written at:
Department of Mathematics, Thompson Rivers University (British
Columbia, Canada) by Damian Halvorsen and Yana Nec.
Reference for the geometry and all formulae: appendix B in
DOI: https://doi.org/10.1016/j.pce.2018.10.003 ;
http://faculty.tru.ca/ynec/index_papers.html
}
COORDINATES cartesian2
VARIABLES P
DEFINITIONS
C2K = 273.15 { 0 deg C in Kelvin }
g = 9.8067 { gravity constant m/s^2 }
ps = 101325 { standard atmospheric pressure at sea level Pa }
Ts = C2K+15 { standard atmospheric temperature at sea level K }
Tc = C2K+20 { standard chemical temperature K }
Latm = 0.0065 { standard atmospheric cooling rate deg/m }
R_air = 286.9 { air gas constant p = rho R T }
Ro = 8.3145 { universal gas constant, specific R = Ro/M }
i2m_p = ps/406.8 { inWc to Pa conversion factor }
{ porosity }
p_eps = array(0.6,0.4,0.7)
{ effective packing sphere diameter to represent grain size m }
sphere_diam = array(0.05,0.1,0.01) {k_b>k_a}
{ tortuosity }
tau = 100
{ temperature deg C }
Tlfg = 15+C2K
{ hole diameter m }
dh = 3/8*0.0254
{molar weights}
M_CH4 = 0.016044
M_CO2 = 0.04401
M_O2 = 0.0319988
M_N2 = 0.0280134
Mw = array(M_CH4,M_CO2,M_O2,M_N2)
{ gas composition CH4, CO2 and O2, balance N2 }
Xlfg0 = array(0.5,0.4,0.01);
Sample P roblems : Applications 402
Xlfg = array(Xlfg0[1],Xlfg0[2],Xlfg0[3],1-sum(i,1,3,Xlfg0[i]))
Rlfg = Ro/sum(i,1,4,Xlfg[i]*Mw[i])
{ Sutherland's formula }
{ base values for Sutherland's formula }
mu_CH4 = muo_CH4*(Tlfg/To_CH4)^1.5*(To_CH4+s_CH4)/(Tlfg+s_CH4);
mu_CO2 = muo_CO2*(Tlfg/To_CO2)^1.5*(To_CO2+s_CO2)/(Tlfg+s_CO2);
mu_O2 = muo_O2*(Tlfg/To_O2)^1.5*(To_O2+s_O2)/(Tlfg+s_O2);
mu_N2 = muo_N2*(Tlfg/To_N2)^1.5*(To_N2+s_N2)/(Tlfg+s_N2);
{ exponential formula }
fl = 2^a/Ylfg^2*sum(i,1,4,sum(j,1,4,
Xlfg[i]*Xlfg[j]*Mw[i]^((a+1)/2)*Mw[j]^((a+1)/2)/
(sqrt(mu[i]*mu[j])*(Mw[i]+Mw[j])^a)))
mu_lfg = 1/fl
Kp
Cp
ang_jump = pi/8
Px ! constant, to be used as a normalisation pressure value
Px2 = Px^2
f = 0.5*r_P ! focal length, common to all ellipses
fb = f^2*muRTC/(4*Px2*k[2]) ! combined constants
fc = f^2*muRT*Cp/(4*Px2*Kp)
muRTCpx = muRT*Cp/Px2
grav = 0*vector(0,-g,0) ! toggle the factor to turn gravity on and off
xiBA = xib-xia
xiAP = xia-xip
r_outx = f*cosh(xib)
r_outy = f*sinh(xib)
r_inx = f*cosh(xia)
r_iny = f*sinh(xia)
r_px = f*cosh(xip)
r_py = f*sinh(xip)
MATERIALS
'ACmat' :
Kp = k[2]
Cp = C
a0 = a0b
b0 = b0b
a1 = a1b
b1 = b1b
'ABmat' :
Kp = k[1]
Cp = 0
a0 = a0a
b0 = b0a
a1 = a1a
b1 = b1a
INITIAL VALUES
P = P_atm/Px
EQUATIONS
div(Kp*p*(grad(p)-p/RT*grav)) = -muRTCpx
BOUNDARIES
REGION 'AC'
use material 'ACmat'
start (r_outx,0)
value(P) = sqrt((pB/Px)^2 +theta_B*cos(2*phi)) ! pressure boundary condition
arc(center=0,0) to (0,r_outy) to (-r_outx,0)
to (0,-r_outy) to (r_outx,0)
start (r_px,0)
value(P) = sqrt((P_out/Px)^2 + theta_P*cos(2*phi))
arc(center=0,0) to (0,r_py) to (-r_px,0)
to (0,-r_py) to (r_px,0)
REGION 'AB'
Sample P roblems : Applications 404
PLOTS
contour(P) painted zoom(-r_px,-r_px,2*r_px)
repeat th = 0 by ang_jump to 3/8*pi
Elevation (P, P_ell) on 'Ray_'+$th as 'P on Ray_'+$th
export points=30 file = 'qpe2L_'+$round(th*10000)+'.tbl'
Elevation (P-P_ell) on 'Ray_'+$th as 'P error on Ray_'+$th
endrepeat
END
}
title 'Viscous flow in 2D channel, Re > 40'
variables
u(0.1)
v(0.01)
p(1)
psi
select
ngrid = 40
definitions
Lx = 5
Ly = 1.5
p0 = 2
speed2 = u^2+v^2
speed = sqrt(speed2)
dens = 1
visc = 0.04 vxx = -(p0/(2*visc*(2*Lx)))*(Ly^2-y^2) { open-channel x-velocity }
rball=0.4
cut = 0.1 { value for bevel at the corners of the obstruction }
penalty = 100*visc/rball^2
405 FlexP DE 7 : Sample P roblems
Re = globalmax(speed)*(Ly/2)/(visc/dens)
initial values
u = 0.5*vxx v = 0 p = p0*(Lx+x)/(2*Lx)
equations
u: visc*div(grad(u)) - dx(p) = dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
then
psi: div(grad(psi)) + w = 0 ! solve streamline equation separately from velocities
boundaries
region 1
start(-Lx,0)
load(u) = 0 value(v) = 0 load(p) = 0 value(psi) = 0
line to (Lx/2-rball,0)
value(u) = 0 value(v) = 0 load(p) = 0
mesh_spacing = rball/10 ! dense mesh to resolve obstruction
line to (Lx/2-rball,rball) bevel(cut)
to (Lx/2+rball,rball) bevel(cut)
to (Lx/2+rball,0)
mesh_spacing = 10*rball ! cancel dense mesh requirement
load(u) = 0 value(v) = 0 load(p) = 0
line to (Lx,0)
load(u) = 0 value(v) = 0 value(p) = p0 natural(psi) = 0
line to (Lx,Ly)
value(u) = 0 value(v) = 0 load(p) = 0 natural(psi) = normal(-v,u)
line to (-Lx,Ly)
load(u) = 0 value(v) = 0 value(p) = 0 natural(psi) = 0
line to close
monitors
contour(speed) report(Re)
contour(psi) as "Streamlines"
contour(max(psi,-0.003)) zoom(Lx/2-3*rball,0, 3*rball,3*rball) as "Vortex
Streamlines"
vector(u,v) as "flow" zoom(Lx/2-3*rball,0, 3*rball,3*rball) norm
plots
contour(u) report(Re)
contour(v) report(Re)
contour(speed) painted report(Re)
vector(u,v) as "flow" report(Re)
contour(p) as "Pressure" painted
contour(dx(u)+dy(v)) as "Continuity Error"
elevation(u) from (-Lx,0) to (-Lx,Ly)
elevation(u) from (0,0) to (0,Ly)
elevation(u) from (Lx/2,0) to (Lx/2,Ly)
elevation(u) from (Lx,0) to (Lx,Ly)
contour(psi) as "Streamlines"
contour(max(psi,-0.003)) zoom(Lx/2-3*rball,0, 3*rball,3*rball) as "Vortex
Streamlines"
vector(u,v) as "flow" zoom(Lx/2-3*rball,0, 3*rball,3*rball) norm
end
Sample P roblems : Applications 406
5.1.4.20 swirl
{ SWIRL.PDE
This problem addresses swirling flow in a cylindrical
vessel driven by a bottom impeller using a vector
description of the equations.
In two-dimensional cylindrical coordinates, we can
represent three velocity components (radial, axial
and tangential) as long as there is no variation of
cross-section or velocity in the azimuthal coordinate.
The Navier-Stokes equation for flow in an incompressible
fluid with no body forces can be written in FlexPDE
notation as
dens*(dt(U) + dot(U,grad(u)) = -grad(p) + visc*del2(U)
where U represents the vector fluid velocity, p is the
pressure, dens is the density and visc is the viscosity
of the fluid. Here the pressure can be considered as
the deviation from static pressure, because uniform static
forces like gravity can be cancelled out of the equation.
In two-dimensional steady-state axisymmetric form, this
equation becomes three component equations, radial (vr),
tangential (vt) and axial (vz):
dens*(vr*dr(vr) - vt^2/r + vz*dz(vr)) + dr(p) =
visc*[div(grad(vr)) - vr/r^2]
COORDINATES
407 FlexP DE 7 : Sample P roblems
ycylinder ('r','z')
VARIABLES
V(0.001) = vector(vr, vz, vt)
p(0.001) { pressure, with linear interpolation and minimum expected range }
DEFINITIONS
rad=0.01 { vial radius }
ht=0.02 { vial height }
radimp = 0.98*rad { radial impeller size }
radwall = 0.95*rad { a gridding feature to put finer mesh at vial wall }
vm=magnitude(V)
mass_balance = div_v/integral(1)
INITIAL VALUES
vr=0
vz=0
vt=0
p=0
EQUATIONS
V: dens*dot(V,grad(V)) + grad(p) - visc*div(grad(V)) = F*(V0-V)
p: div(grad(p)) = penalty*div_v
BOUNDARIES
Region 'domain'
F=0
Start 'outer' (0,0)
{ mirror conditions on bottom boundary }
natural(vr)=0 natural(vt)=0 value(vz)=0 natural(p)=0 line to (rad,0)
value(vr)=0 ! impenetrable radial wall
{ no slip on sides (ie, velocity=0) }
! value(vt)=0 value(vz)=0
{ friction on sides - generate an outward "Flux" of V (i.e. -visc*grad(V)) to
drive it toward zero }
natural(vt)=100*vt natural(vz)=100*vz natural(p)=0 line to (rad,ht)
{ zero pressure and no z-flow on top, but free vr and vt }
natural(vr)=0 natural(vt)=0 value(vz)=0 value(p)=0 line to (0,ht)
{ no radial or tangential velocity on spin axis }
value(vr)=0 value(vt)=0 natural(vz)=0 natural(p)=0 line to close
Region "impeller"
F=bf
Start(0,0) line to (radimp,0) to (radimp,band) to (0,band) to close
{ add a gridding feature to help resolve the shear layer at the wall }
Feature start(radwall,0) line to (radwall,ht)
Sample P roblems : Applications 408
MONITORS
contour(vr) as "Radial Velocity" report(rpm)
contour(vt) as "Swirling Velocity" report(rpm)
contour(vz) as "Axial Velocity" report(rpm)
elevation(vt,vt0) from(0,0) to (rad,0) as "Impeller Velocity" report(rpm)
contour(p) as "Pressure"
vector(vr,vz) as "R-Z Flow"
PLOTS
contour(vr) as "Radial Velocity" report(rpm)
contour(vt) as "Swirling Velocity" report(rpm)
contour(vz) as "Axial Velocity" report(rpm)
contour(vm) as "Velocity Magnitude" report(rpm)
contour(p) as "Pressure" report(rpm)
vector(vr,vz) norm as "R-Z Flow" report(rpm)
contour(mass_balance) report(rpm)
elevation(vr) from (0,band) to (rad,band) as "Radial Velocity" report(rpm)
elevation(vt) from (0,band) to (rad,band) as "Swirling Velocity" report(rpm)
elevation(vz) from (0,band) to (rad,band) as "Axial Velocity" report(rpm)
elevation(vt,vt0) from(0,band) to (rad,band) as "Impeller Velocity" report(rpm)
elevation(vm) from (0,band) to (rad,band) as "Velocity Magnitude" report(rpm)
elevation(vr) from (0,ht/2) to (rad,ht/2) as "Radial Velocity" report(rpm)
elevation(vt) from (0,ht/2) to (rad,ht/2) as "Swirling Velocity" report(rpm)
elevation(vz) from (0,ht/2) to (rad,ht/2) as "Axial Velocity" report(rpm)
elevation(vm) from (0,ht/2) to (rad,ht/2) as "Velocity Magnitude" report(rpm)
elevation(vr) from (0,0.9*ht) to (rad,0.9*ht) as "Radial Velocity" report(rpm)
elevation(vt) from (0,0.9*ht) to (rad,0.9*ht) as "Swirling Velocity" report(rpm)
elevation(vz) from (0,0.9*ht) to (rad,0.9*ht) as "Axial Velocity" report(rpm)
elevation(vm) from (0,0.9*ht) to (rad,0.9*ht) as "Velocity Magnitude" report(rpm)
elevation(vm) from (rad/2,0) to (rad/2,ht) as "Velocity Magnitude" report(rpm)
END
5.1.4.21 v iscous
{ VISCOUS.PDE
This example shows the application of FlexPDE to problems in
viscous flow.
The Navier-Stokes equation for steady incompressible flow in two
cartesian dimensions is
dens*(dt(U) + U*dx(U) + V*dy(U)) = visc*del2(U) - dx(P) + dens*Fx
dens*(dt(V) + U*dx(V) + V*dy(V)) = visc*del2(V) - dy(P) + dens*Fy
together with the continuity equation
div[U,V] = 0
where
U and V are the X- and Y- components of the flow velocity
P is the fluid pressure
dens is the fluid density
visc is the fluid viscosity
Fx and Fy are the X- and Y- components of the body force.
In principle, the third equation enforces incompressible mass conservation,
but the equation contains no reference to the pressure, which is nominally
the remaining variable to be determined.
In practice, we choose to solve a "slightly compressible" system by defining a
hypothetical equation of state
p(dens) = p0 + L*(dens-dens0)
where p0 and dens0 represent a reference density and pressure, and L is a large
number representing a strong response of pressure to changes of density. L is
chosen large enough to enforce the near-incompressibility of the fluid, yet not
so large as to erase the other terms of the equation in the finite precision
of the computer arithmetic.
The compressible form of the continuity equation is
dt(dens) + div(dens*U) = 0
which, together with the equation of state yields
dt(p) = -L*dens0*div(U)
In steady state, we can replace the dt(p) by -div(grad(p))
[see Help | Tech Notes | Smoothing Operators in PDEs"],
resulting in the final pressure equation:
409 FlexP DE 7 : Sample P roblems
div(grad(p)) = M*div(U)
Here M has the dimensions of density/time or viscosity/distance^2.
The problem posed here shows flow in a 2D channel blocked by a bar of square
cross-section. The channel is mirrored on the bottom face, and only the upper
half is computed.
We have chosen a "convenient" value of M, one that gives good
accuracy in reasonable time. The user can alter this value to find one
which is satisfactory for his application.
We have included three elevation plots of X-velocity, at the inlet, center
and outlet of the channel. The integrals presented on these plots show the
consistency of mass transport across the channel.
}
title 'Viscous flow in 2D channel, Re < 0.1'
variables
u(0.1)
v(0.01)
p(1)
select
ngrid = 40
definitions
Lx = 5 Ly = 1.5
Gx = 0 Gy = 0
p0 = 1
speed2 = u^2+v^2
speed = sqrt(speed2)
dens = 1
visc = 1
pfactor = staged(1,10,100,1000)
penalty = pfactor*visc/rball^2 { "equation of state" }
Re = globalmax(speed)*(Ly/2)/(visc/dens)
initial values
u = 0.5*vxx v = 0 p = p0*x/Lx
equations
u: visc*div(grad(u)) - dx(p) = dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
boundaries
region 1
start(0,0)
{ unspecified boundary conditions default to LOAD=0 }
value(v)=0 line to (Lx/2-rball,0)
value(u)=0 line to (Lx/2-rball,rball) bevel(cut)
line to (Lx/2+rball,rball) bevel(cut)
line to (Lx/2+rball,0)
load(u)=0 line to (Lx,0)
value(p)=p0 line to (Lx,Ly)
value(u)=0 load(p)=0 line to (0,Ly)
load(u)=0 value(p)=0 line to close
monitors
contour(speed) report(Re)
plots
grid(x,y)
contour(u) report(Re)
contour(v) report(Re)
contour(speed) painted report(Re)
vector(u,v) as "flow" report(Re)
contour(p) as "Pressure" painted
Sample P roblems : Applications 410
5.1.5 Groundwater
5.1.5.1 porous
{ POROUS.PDE
This problem describes the flow through an anisotropic porous foundation.
It is taken from Zienkiewicz, "The Finite Element Method in Engineering Science",
p. 305.
}
title 'Anisotropic Porous flow'
variables
pressure
definitions
ky = 1
kx = 4
equations
pressure : dx(kx*dx(pressure)) + dy(ky*dy(pressure)) = 0
boundaries
region 1
start(0,0)
natural(pressure)=0 line to (5,0) to (5,5)
value(pressure)=0 line to (2,2)
natural(pressure)=0 line to (2.5,2) to (2.5,1.95) to (1.95,1.95)
value(pressure)=100 line to close
monitors
contour(pressure)
plots
contour(pressure)
surface(pressure)
end
5.1.5.2 richards
{ RICHARDS.PDE
coordinates
cartesian1('y')
variables
h (1)
definitions
411 FlexP DE 7 : Sample P roblems
thr = 0.2
ths = 0.58
alpha = .08
n = 1.412
ks = 10
{Using Van Genuchten parameters for water content (wc),
water capacitance (C=d(wc)/dh), effecive saturation (se),
and hydraulic Conductivity (k) }
m = 1-1/n
wc = if h<0 then thr+(ths-thr)*(1+(abs(alpha*h))^n)^(-m) else ths
C = ((1-n)*abs(-alpha*h)^n*(1+abs(-alpha*h)^n)^((1/n)-2)*(ths-thr))/h
se = (wc-thr)/(ths-thr)
k = ks*sqrt(se)*(1-(1-se^(1/m))^m)^2
initial values
h = 199*exp(-(y-100)^2)-200
equations
h : dy(k*(dy(h)+1)) = C*dt(h)
boundaries
region 1
start(0)
line to (100) point value(h) = -1
front(h+150,1)
time 0 to 2
monitors
for cycle=10
elevation(h) from (0) to (100) as "pressure"
elevation(c) from (0) to (100) as "capacitance"
elevation(k) from (0) to (100) log as "conductivity"
grid(y)
plots
for t=0.001 by 0.001 to 0.01 0.1 by 0.1 to endtime
elevation(h) from (0) to (100) as "pressure"
elevation(c) from (0) to (100) as "capacitance"
elevation(k) from (0) to (100) log as "conductivity"
grid(y)
end "IE3vuxq/blOMIRLitV++FYgmXZuPz8D1+wvzXgpATJSsnTmsgWgSZOaLi+YOaMBsdxHjOXQUBxLPMVWceTZ
+tzU0r6xbZ0Y9YaEBD8IG48nPCNezshKtEYPOYKh4ucdlKJWvPO8XzbScXAA9wKDowS86YuXXbtMkiY/S4U2KCpa"
5.1.5.3 water
{ WATER.PDE
This problem shows the flow of water to two wells, through soil regions of
differing porosity. It also displays the ability of FlexPDE to grid features
of widely varying size.
}
title 'Groundwater flow to two wells'
definitions
k { no value is required, as long as it appears later }
s = 0 { no volumetric source }
k1 = 0.1 { high porosity value }
k2 = 1.0e-7 { low porosity value }
sx1 = 0.7 sy1 = 0.4{ well 1 location }
sx2 = 0.5 sy2 = 0.2{ well 2 location }
srad = 0.001 { well radius = one thousandth of domain size }
w = 0.05 { a zoom window size }
px = 0.4 py = 0.4 { percolation pond center }
Sample P roblems : Applications 412
5.1.6 Heatflow
5.1.6.1 1d_float_zone
{ 1D_FLOAT_ZONE.PDE
title
"Float Zone in 1D Cartesian geometry"
select
cell_limit=100
coordinates
cartesian1
variables
temp(threshold=100)
definitions
k = 10 {thermal conductivity}
cp = 1 { heat capacity }
long = 18
H = 0.4 {free convection boundary coupling}
Ta = 25 {ambient temperature}
A = 4500 {amplitude}
source = A*exp(-((x-1*t)/.5)^2)*(200/(t+199))
initial value
temp = Ta
equations
temp : div(k*grad(temp)) + source -H*(temp - Ta) = cp*dt(temp)
boundaries
region 1
start(0) point value(temp) = Ta
line to (long) point value(temp) = Ta
time -0.5 to 19 by 0.01
monitors
for t = -0.5 by 0.5 to (long + 1)
elevation(temp) from (0) to (long) range=(0,1800) as "Surface Temp"
plots
for t = -0.5 by 0.5 to (long + 1)
elevation(temp) from (0) to (long) range=(0,1800) as "Axis Temp"
elevation(source) from(0) to (long)
elevation(-k*grad(temp)) from(0) to (long)
histories
history(temp) at (0) (1) (2) (3) (4) (5) (6) (7) (8) (9)
(10) (11) (12) (13) (14) (15) (16) (17) (18)
end
Sample P roblems : Applications 414
5.1.6.2 3d_bricks
{ 3D_BRICKS.PDE
}
title 'steady-state 3D heat conduction'
select
regrid=off { use fixed grid }
coordinates
cartesian3
variables
Tp
definitions
long = 1
wide = 1
K { thermal conductivity -- values supplied later }
Q = 10*exp(-x^2-y^2-z^2) { thermal source }
initial values
Tp = 0.
equations
Tp : div(k*grad(Tp)) + Q = 0 { the heat equation }
extrusion z = -long,0,long { divide Z into two layers }
boundaries
Surface 1 value(Tp)=0 { fix bottom surface temp }
Surface 3 value(Tp)=0 { fix top surface temp }
Region 1 { define full domain boundary in base plane }
layer 1 k = 1.0 { bottom right brick }
layer 2 k = 0.1 { top right brick }
start(-wide,-wide)
value(Tp) = 0 { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
Region 2 { overlay a second region in left half }
layer 1 k = 0.2 { bottom left brick }
layer 2 k = 0.4 { top left brick }
start(-wide,-wide)
line to (0,-wide) { walk left half boundary in base plane }
to (0,wide)
to (-wide,wide)
to close
monitors
contour(Tp) on z=0 as "XY Temp"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "XZ Temp"
elevation(Tp) from (-wide,0,0) to (wide,0,0) as "X-Axis Temp"
elevation(Tp) from (0,-wide,0) to (0,wide,0) as "Y-Axis Temp"
elevation(Tp) from (0,0,-long) to (0,0,long) as "Z-Axis Temp"
plots
contour(Tp) on z=0 as "XY Temp"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "XZ Temp"
415 FlexP DE 7 : Sample P roblems
end
5.1.6.3 3d_bricks+tim e
{ 3D_BRICKS+TIME.PDE
This problem demonstrates the application of FlexPDE to time-dependent
three dimensional heat conduction. An assembly of bricks of differing
conductivities has a gaussian internal heat source, with all faces held
at zero temperature. After a time, the temperature reaches a stable
distribution.
This is the time-dependent analog of example problem 3D_BRICKS.PDE 414 .
}
title 'time-dependent 3D heat conduction'
select
regrid=off { use fixed grid }
ngrid=5 { smaller grid for quicker run }
coordinates
cartesian3
variables
Tp(threshold=0.1) { the temperature variable, with approximate size }
definitions
long = 1
wide = 1
K { thermal conductivity -- values supplied later }
Q = 10*exp(-x^2-y^2-z^2) { thermal source }
tmax = 6 { plot range control }
initial values
Tp = 0.
equations
Tp : div(k*grad(Tp)) + Q = dt(Tp) { the heat equation }
extrusion z = -long,0,long { divide Z into two layers }
boundaries
Surface 1 value(Tp)=0 { fix bottom surface temp }
Surface 3 value(Tp)=0 { fix top surface temp }
Region 1 { define full domain boundary in base plane }
k = bylayer (1.0, 0.1) { bottom and top right brick }
start(-wide,-wide)
value(Tp) = 0 { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
Region 2 { overlay a second region in left half }
k = bylayer (0.2, 0.4) { bottom and top left brick }
start(-wide,-wide)
line to (0,-wide) { walk left half boundary in base plane }
to (0,wide)
to (-wide,wide)
to close
time 0 to 3 by 0.01 { establish time range and initial timestep }
monitors
for cycle=1
contour(Tp) on z=0 as "XY Temp" range=(0,tmax)
contour(Tp) on x=0 as "YZ Temp" range=(0,tmax)
contour(Tp) on y=0 as "XZ Temp" range=(0,tmax)
elevation(Tp) from (-wide,0,0) to (wide,0,0) as "X-Axis Temp" range=(0,tmax)
elevation(Tp) from (0,-wide,0) to (0,wide,0) as "Y-Axis Temp" range=(0,tmax)
Sample P roblems : Applications 416
to (0,6)
natural(Temp)= 0 { define the left symmetry boundary }
line to (0,5)
end
5.1.6.5 float_zone
{ FLOAT_ZONE.PDE
This example illustrates time-dependent axi-symmetric heat flow with a
moving source.
A rod of conductive material of unit radius and "long" units length
is clamped to a heat sink at either end. An RF coil passes the
length of the rod, creating a moving heat source of gaussian profile.
This produces a moving melt zone which carries impurities with it as it moves.
A cam adjusts the source amplitude by 200/(t+199) to produce an approximately
constant maximum temperature.
}
title
"Float Zone"
coordinates
xcylinder('Z','R')
select
cubic { Use Cubic Basis }
variables
temp(threshold=100)
definitions
k = 0.85 { thermal conductivity }
cp = 1 { heat capacity }
long = 18
H = 0.4 { free convection boundary coupling }
Ta = 25 { ambient temperature }
A = 4500 { amplitude }
source = A*exp(-((z-1*t)/.5)^2)*(200/(t+199))
initial value
temp = Ta
equations
temp : div(k*grad(temp)) + source = cp*dt(temp)
boundaries
region 1
start(0,0)
natural(temp) = 0 line to (long,0)
value(temp) = Ta line to (long,1)
natural(temp) = -H*(temp - Ta) line to (0,1)
value(temp) = Ta line to close
feature
start(0.01*long,0) line to (0.01*long,1)
time -0.5 to 19 by 0.01
monitors
for t = -0.5 by 0.5 to (long + 1)
Sample P roblems : Applications 418
5.1.6.6 heat_boundary
{ HEAT_BOUNDARY.PDE
This problem shows the use of natural boundary conditions to model
insulation, reflection, and convective losses.
The heatflow equation is
div(K*grad(Temp)) + Source = 0
The Natural boundary condition specifies the value of the surface-normal
component of the argument of the divergence operator, ie:
Natural Boundary Condition = normal <dot> K*grad(Temp)
Insulating boundaries and symmetry boundaries therefore require the
boundary condition:
Natural(Temp) = 0
At a convective boundary, the heat loss is proportional to the temperature
difference between the surface and the coolant. Since the heat flux is
F = -K*grad(Temp) = b*(Temp - Tcoolant)
the appropriate boundary condition is
Natural(Temp) = b*(Tcoolant - Temp).
In this problem, we define a quarter of a circle, with reflective
boundaries on the symmetry planes to model the full circle. There is a
uniform heat source of 4 units throughout the material. The outer
boundary is insulated, so the natural boundary condition is used to
specify no heat flow.
Centered in the quadrant is a cooling hole. The temperature of the
coolant is Tzero, and the heat loss to the coolant is (Tzero - Temp)
heat units per unit area.
equations
Temp : div(K*grad(Temp)) + source = 0
5.1.6.7 radiation_flow
{ RADIATION_FLOW.PDE
This problem demonstrates the use of FlexPDE
in the solution of problems in radiative transfer.
Briefly summarized, we solve a Poisson equation
for the radiation energy density, assuming that
at every point in the domain the local
temperature has come into equilibrium with the
impinging radiation field.
We further assume that the spectral character-
istics of the radiation field are adequately
described by three average cross-sections:
the emission average, or "Planck Mean", sigmap;
the absorption average, sigmaa; and the transport
average, or "Rosseland Mean-Free-Path", lambda.
These averages may, of course, differ in various
regions, but they must be estimated by facilities
outside the scope of FlexPDE.
And finally, we assume that the radiation field
is sufficiently isotropic that Fick's Law, that
the flux is proportional to the gradient of the
energy density, is valid.
The problems shows a hot slab radiating across an
air gap and heating a distant dense slab.
}
variables
erad { Radiation Energy Density }
definitions
source { declare the parameters, values will follow }
lambdar { Rosseland Mean Free Path }
sigmap { Planck Mean Emission cross-section }
sigmaa { absorption average cross-section }
beta = 1/3 { Fick's Law proportionality factor }
materials
'air' : source=0 sigmap=2 sigmaa=1 lambdar=10
'hot slab' : source=100 sigmap=10 sigmaa=10 lambdar=1
'dense slab' : source=0 sigmap=10 sigmaa=10 lambdar=1
boundaries
monitors
contour(erad)
plots
contour(erad) as 'Radiation Energy'
surface(erad) as 'Radiation Energy'
vector(-beta*lambdar*grad(erad)) as 'Radiation Flux'
end
end
5.1.6.9 slider
{ SLIDER.PDE
This problem represents a cross section of a wood-frame sliding window.
-- submitted by Elizabeth Finleyson, Lawrence Berkeley Labs
}
title
"NFRC Wood Slider"
variables
Temp
definitions
K = 0.97 {Thermal Conductivity}
B1 = 1.34 {Film coefficients interior wood}
B2 = 1.41 { '' interior glass}
B3 = 5.11 { '' exterior glass}
Tin = 70.0 {Ambient Temperature Inside}
Tout= 0.0 { '' Outside}
equations
Temp : dx(K*dx(Temp)) + dy(K*dy(Temp)) = 0
boundaries
region 1 {Defines the maximum extent of the system (wood)}
start(6.813,1.813)
natural(Temp) = B1*(Tin - Temp)
line to (6.813,3.001) to (6.344,3.001) to (6.344,3.323)
line to (6.183,3.323) to (6.183,4.885) to (5.988,4.885)
line to (5.988,5.104) to (5.678,5.104)
natural(Temp) = B2*(Tin - Temp)
line to (5.678,7.604)
natural(Temp) = 0.0
line to (5.153,7.604)
natural(Temp) = B3*(Tout- Temp)
line to (5.153,5.104) to (5.012,5.104) to (5.012,4.889)
line to (4.871,4.889) to (4.871,3.323) to (4.248,3.323)
line to (4.248,2.845) to (3.233,2.845) to (3.233,3.323) to (2.906,3.323)
line to (2.906,3.001) to (2.250,3.001) to (2.250,2.501) to (1.156,2.501)
natural(Temp) = 0.0
line to (1.156,1.813) to close
{Rigid PVC}
region 2 K = 1.18
start(6.516,2.800)
line to (6.516,2.845) to (6.344,2.845) to (6.344,3.323)
line to (5.737,3.323) to (5.737,3.278) to (6.017,3.278)
line to (6.017,2.845) to (5.002,2.845) to (5.002,3.278)
line to (5.317,3.278) to (5.317,3.323)
line to (4.248,3.323) to (4.248,2.845) to (3.233,2.845)
line to (3.233,3.323) to (2.906,3.323) to (2.906,2.845)
line to (2.547,2.845) to (2.547,2.800) to close
{Air cavity overlays}
region 3 K = 0.59
start(4.293,2.845)
line to (4.957,2.845) to (4.957,3.278) to (4.293,3.278) to close
region 4 k = 0.31
start(2.951,2.800)
line to (3.188,2.800) to (3.188,3.278) to (2.951,3.278) to close
region 5 k = 0.51
start(2.547,2.501)
line to (3.188,2.501) to (3.188,2.800) to (2.547,2.800) to close
region 6 k = 0.81
423 FlexP DE 7 : Sample P roblems
start(5.002,2.845)
line to (6.017,2.845) to (6.017,3.278) to (5.002,3.278) to close
region 7 k = 0.39
start(5.317,3.278)
line to (5.737,3.278) to (5.737,3.551) to (5.317,3.551) to close
region 8 k = 0.31
start(6.062,2.800)
line to (6.299,2.800) to (6.299,3.278) to (6.062,3.278) to close
region 9 k = 0.41
start(6.062,2.501)
line to (6.516,2.501) to (6.516,2.800) to (6.062,2.800) to close
{Silicon sealant}
region 10 k = 2.5
start(5.133,4.573)
line to (5.153,4.573) to (5.153,5.104) to (5.133,5.104) to close
region 11 k = 2.5
start(5.678,4.573)
line to (5.698,4.573) to (5.698,5.104) to (5.678,5.104) to close
{Glass layers}
region 12 k = 6.93
start(5.153,4.573)
line to (5.678,4.573) to (5.678,7.604) to (5.153,7.604) to close
{Eurythane spacer seal}
region 13 k = 2.5
start(5.278,4.573)
line to (5.553,4.573) to (5.553,4.771) to (5.278,4.771) to close
{Spacer}
region 14 k = 18.44
start(5.278,4.771)
line to (5.553,4.771) to (5.553,5.012) to (5.278,5.012) to close
{Gas gap}
region 15 k = 0.32
start(5.278,5.012)
line to (5.553,5.012) to (5.553,7.604) to (5.278,7.604) to close
{Frame fill}
region 16 k = 0.21
start(3.188,2.501)
line to (6.062,2.501) to (6.062,2.800) to (3.188,2.800) to close
{Spacer air gap}
region 17 k = 0.28
start(5.133,4.479)
line to (5.698,4.479) to (5.698,4.573) to (5.133,4.573) to close
monitors
contour(Temp)
plots
grid(x,y)
contour(Temp)
contour(Temp) zoom(4.6,4.2,1.8,1.8)
elevation(Temp) from (5.416,1.813) to (5.416,7.604)
vector((K*(-dx(Temp))),(K*(-dy(Temp)))) as "HEAT FLUX"
end
5.1.7 Lasers
5.1.7.1 laser_heatflow
{ LASER_HEATFLOW.PDE
This problem shows a complex heatflow application.
Sample P roblems : Applications 424
contour(temp) zoom(-(Rod+Ur)/4,-(Rod+Ur),(Rod+Ur)/2,(Rod+Ur)/2)
vector(-k*dx(temp),-k*dy(temp)) as "heat flow"
surface(temp)
end
5.1.7.2 self_focus
{ SELF_FOCUS.PDE
This problem considers the self-focussing of a laser beam of Gaussian profile.
-- Submitted by John Trenholme, LLNL
}
title "2D GAUSSIAN BEAM PROFILE"
select
elevationgrid = 300
variables
realf (threshold=0.1) { real (in-phase) part of field envelope }
imagf (threshold=0.1) { imaginary (quadrature) part of field envelope }
definitions
radX = 2 { X "radius" of beam }
radY = 2 { Y "radius" of beam }
bMax = 2.25 { maximum B integral (= Time)}
zm = 5 { zoom-in factor for plots }
xHi = 7.17 * SQRT( radX * radY) { size of calculation domain... }
yHi = 7.17 * SQRT( radX * radY) { set for field = 0.001 at edge }
x45 = xHi * 0.7071 { point on boundary at 45 degrees }
y45 = yHi * 0.7071
tn =1e-30 { tiny number to force zero on plot scales }
power = PI * radX * radY * 2.73 ^ 2 / 8 { analytic integral }
inten = realf * realf + imagf * imagf { definition for later use }
time { "time" is really B integral }
0 to bMax by 0.03 * bMax
initial values
realf = EXP( - ( x / ( radX * 2.73)) ^ 2 - ( y / ( radY * 2.73)) ^ 2)
imagf = 0
equations { normalized, low-secular-phase nonlinear propagation }
realf: DEL2( imagf) + imagf * ( inten - 1) = -DT( realf)
imagf: DEL2( realf) + realf * ( inten - 1) = DT( imagf)
boundaries
region 1
start ( 0, 0) { bump is at center; only do one quadrant }
natural( realf) = 0 { set slope to zero on boundary }
natural( imagf) = 0 { if boundary value too big, move boundary out }
line to ( xHi, 0)
arc ( center = 0, 0) to ( 0, yHi)
line to ( 0, 0)
to close
monitors
for cycle = 1 { do this every cycle }
elevation( inten) from ( 0, 0) to ( xHi, 0) as "INTENSITY"
range( 0, tn)
contour( inten) as "INTENSITY" zoom ( 0, 0, xHi / zm, yHi / zm)
plots
for t = starttime { at the beginning only }
grid( x, y)
surface( inten) as "INTENSITY" range( 0, tn) viewpoint( 1000, 200, 40)
elevation( LOG10( inten)) from ( 0, 0) to ( xHi, 0) as "LOG10 INTENSITY"
for t = endtime { at the end only }
grid( x, y)
grid( x, y) zoom ( 0, 0, xHi / zm, yHi / zm)
surface( inten) as "INTENSITY" range( 0, tn) viewpoint( 1000, 200, 40)
zoom ( 0, 0, xHi / zm, yHi / zm)
elevation( LOG10( inten)) from ( 0, 0) to ( xHi, 0) as "LOG10 INTENSITY"
Sample P roblems : Applications 426
end
5.1.8 Magnetism
5.1.8.1 3d_helm holtz_coil
{ HELMHOLTZ_COIL.PDE
DEFINITIONS
{ Defining parameters of the Coil }
coil_current=200 {Amps in 1 turn}
Lsep=6.89 {Layer separation - cm}
Cthick=2.36 {Coil thickness - cm}
{ Regional Current Definition }
CurrentControl=1
Current=CurrentControl*coil_current
{ Circulating Current Density in Coil }
J0=Current/Cthick^2 {A/cm^2}
theta=atan2(y,x)
Jx=-J0*sin(theta)
Jy=J0*cos(theta)
{ Magnetic Permeability }
m0=4*3.1415e-2 {dynes/A^2}
{ Coil Radii }
Rcoil_inner=Lsep {cm}
Rcoil_outer=Lsep+Cthick {cm}
Rmax=1.5*Lsep {cm}
{ Z Surfaces }
za=2*Lsep {cm}
zb=za+Cthick {cm}
zc=zb+Lsep {cm}
427 FlexP DE 7 : Sample P roblems
zd=zc+Cthick {cm}
zmax=zd+2*Lsep {cm}
zmiddle=(zd+za)/2 {cm}
{ Magnetic Field }
H=curl(A)/m0 {AT}
Hxx = Xcomp(H)
Hyy = Ycomp(H)
Hzz = Zcomp(H)
MONITORS
grid(y,z) on x=0
grid(x,y) on surface 'Coil1T'
contour(Ax) on x=0
PLOTS
grid(y,z) on x=0
grid(x,y) on surface 'Coil1T'
contour(Ax) on x=0
vector(Hxx,Hyy) on surface 'Coil1T' norm
vector(Hyy,Hzz) on x=0 norm
contour(magnitude(H)) on z=zmiddle
contour(magnitude(H)) on x=0
contour(H_Error) on Layer 'Middle_Air' on x=0
END
Sample P roblems : Applications 428
SELECT
ngrid=25
alias(x) = "X(cm)"
alias(y) = "Y(cm)"
alias(z) = "Z(cm)"
VARIABLES
Ax,Ay { assume Az is zero! }
DEFINITIONS
MuMag=1.0 ! Permeabilities:
MuAir=1.0
MuSST=1000
MuTarget=1.0
Mu=MuAir ! default to Air
MzMag = 10000 ! permanent magnet strength
Mz = 0 ! global magnetization variable
Nx = vector(0,Mz,0)
Ny = vector(-Mz,0,0)
B = curl(Ax,Ay,0) ! magnetic induction vector
Bxx= -dz(Ay)
Byy= dz(Ax) ! unfortunately, "By" is a reserved word.
Bzz= dx(Ay)-dy(Ax)
EQUATIONS
Ax: div(grad(Ax)/mu+Nx) = 0
Ay: div(grad(Ay)/mu+Ny) = 0
EXTRUSION
SURFACE "Boundary Bottom" Z=-5
SURFACE "Magnet Plate Bottom" Z=0
LAYER "Magnet Plate"
SURFACE "Magnet Plate Top" Z=1
LAYER "Magnet"
SURFACE "Magnet Top" Z=2
SURFACE "Boundary Top" Z=8
BOUNDARIES
Surface "boundary bottom" value (Ax)=0 value(Ay)=0
Surface "boundary top" value (Ax)=0 value(Ay)=0
REGION 1 {Air bounded by conductive box }
START (20,-10)
value(Ax)=0 value(Ay)=0
arc(center=20,0) ANGLE=180
Line TO (-20,10)
arc(center=-20,0) ANGLE=180
LINE TO CLOSE
LIMITED REGION 2 { Magnet Plate }
LAYER "Magnet Plate" Mu=MuSST
LAYER "Magnet" Mu=MuMag Mz = MzMag
START (20,-8)
ARC(center=20,0) ANGLE=180
LINE TO (-20,8)
ARC(center=-20,0) ANGLE=180
LINE TO CLOSE
429 FlexP DE 7 : Sample P roblems
MONITORS
grid(y,z) on x=0
grid(x,z) on y=0
grid(x,y) on z=1.01
contour(Ax) on x=0
contour(Ay) on y=0
PLOTS
grid(y,z) on x=0
grid(x,z) on y=0
grid(x,y) on z=1.01
contour(Ax) on x=0
contour(Ay) on y=0
vector(Bxx,Byy) on z=2.01 norm
vector(Byy,Bzz) on x=0 norm
vector(Bxx,Bzz) on y=4 norm
contour(magnitude(Bxx,Byy,Bzz)) on z=2
END
The development of this model is described in the Magnetostatics 316 chapter of the
Electromagnetic Applications 297 section.
}
TITLE 'Oval Magnet'
COORDINATES
CARTESIAN3
SELECT
ngrid=25
alias(x) = "X(cm)"
alias(y) = "Y(cm)"
alias(z) = "Z(cm)"
VARIABLES
A = vector (Ax,Ay) { assume Az is zero! }
DEFINITIONS
MuMag=1.0 ! Permeabilities:
MuAir=1.0
MuSST=1000
MuTarget=1.0
Mu=MuAir ! default to Air
MzMag = 10000 ! permanent magnet strength
Mx=0 My=0 Mz=0
M = vector(Mx,My,Mz) ! global magnetization variable
N = tensor((0,Mz,0),(-Mz,0,0),(0,0,0))
B = curl(Ax,Ay,0) ! magnetic induction vector
Bxx= xcomp(B)
Sample P roblems : Applications 430
BOUNDARIES
Surface "boundary bottom" value (Ax)=0 value(Ay)=0
Surface "boundary top" value (Ax)=0 value(Ay)=0
REGION 1 {Air bounded by conductive box }
START (20,-10)
value(A)=vector(0,0,0)
ARC(center=20,0) angle=180
LINE TO (-20,10)
ARC(center=-20,0) angle=180
LINE TO CLOSE
LIMITED REGION 2 { Magnet Plate }
LAYER "Magnet Plate" Mu=MuSST
LAYER "Magnet" Mu=MuMag Mz = MzMag
START (20,-8)
ARC(center=20,0) angle=180
LINE TO (-20,8)
ARC(center=-20,0) angle=180
LINE TO CLOSE
LIMITED REGION 3 { Inner Gap }
LAYER "Magnet"
START (20,-6)
ARC(center=20,0) angle=180
LINE TO (-20,6)
ARC(center=-20,0) angle=180
LINE TO CLOSE
LIMITED REGION 4 {Inner Magnet }
LAYER "Magnet" Mu=MuMag Mz = -MzMag
START (20,-2)
ARC(center=20,0) angle=180
LINE TO (-20,2)
ARC(center=-20,0) angle=180
LINE TO CLOSE
MONITORS
grid(y,z) on x=0
grid(x,z) on y=0
grid(x,y) on z=1.01
contour(Ax) on x=0
contour(Ay) on y=0
PLOTS
grid(y,z) on x=0
grid(x,z) on y=0
grid(x,y) on z=1.01
contour(Ax) on x=0
contour(Ay) on y=0
vector(Bxx,Byy) on z=2.01 norm
vector(Byy,Bzz) on x=0 norm
vector(Bxx,Bzz) on y=4 norm
contour(magnitude(Bxx,Byy,Bzz)) on z=2
END
5.1.8.4 m agnet_coil
{ MAGNET_COIL.PDE
AXI-SYMMETRIC MAGNETIC FIELDS
431 FlexP DE 7 : Sample P roblems
initial values
Aphi = 2 { unimportant unless mu varies with H }
equations
{ FlexPDE expands CURL in proper coordinates }
Aphi : curl(rmu*curl(Aphi)) = J
boundaries
region 1
start(-10,0)
value(Aphi) = 0 { specify A=0 along axis }
line to (10,0)
natural(Aphi) = 0 { H<dot>n = 0 on distant sphere }
arc(center=0,0) angle 180 to close
region 2
J = current { override source value in the coil }
start (-0.25,1)
line to (0.25,1) to (0.25,1.5) to (-0.25,1.5) to close
monitors
contour(Bz) zoom(-2,0,4,4) as 'FLUX DENSITY B'
contour(Aphi) as 'Potential'
plots
grid(z,r)
contour(Bz) as 'FLUX DENSITY B'
contour(Bz) zoom(-2,0,4,4) as 'FLUX DENSITY B'
elevation(Aphi,dr(Aphi),Aphi/r,dr(Aphi)+Aphi/r,Aphi+r*dr(Aphi))
from (0,0) to (0,1) as 'Bz'
vector(dr(Aphi)+Aphi/r,-dz(Aphi)) as 'FLUX DENSITY B'
vector(dr(Aphi)+Aphi/r,-dz(Aphi)) zoom(-2,0,4,4) as 'FLUX DENSITY B'
contour(Aphi) as 'MAGNETIC POTENTIAL'
contour(Aphi) zoom(-2,0,4,4) as 'MAGNETIC POTENTIAL'
surface(Aphi) as 'MAGNETIC POTENTIAL' viewpoint (-1,1,30)
end
Definitions
mu = 1
S = 0 { current density }
Px = 0 { Magnetization components }
Py = 0
P = vector(Px,Py) { Magnetization vector }
H = (curl(A)-P)/mu { Magnetic field }
y0 = 8 { Size parameter }
Materials
433 FlexP DE 7 : Sample P roblems
'Magnet' : Py = 10
'Other' : mu = 5000
Initial values
A = 0
Equations
A : curl(H) + S = 0
Boundaries
Region 1
start(-40,0)
natural(A) = 0 line to (80,0)
value(A) = 0 line to (80,80) to (-40,80) to close
Region 2
use material 'Other'
start(0,0)
line to (15,0) to (15,20) to (30,20) to (30,y0) to (40,y0) to (40,40)
to (0,40) to close
Region 3 { the permanent magnet }
use material 'Magnet'
start (0,0) line to (15,0) to (15,10) to (0,10) to close
Monitors
contour(A)
Plots
grid(x,y)
vector(dy(A),-dx(A)) as 'FLUX DENSITY B'
vector((dy(A)-Px)/mu, (-dx(A)-Py)/mu) as 'MAGNETIC FIELD H'
contour(A) as 'Az MAGNETIC POTENTIAL'
surface(A) as 'Az MAGNETIC POTENTIAL'
End
5.1.8.6 saturation
{ SATURATION.PDE
A NONLINEAR MAGNETOSTATIC PROBLEM
This example considers the problem of determining the magnetic vector
potential A in a cyclotron magnet.
The problem domain consists of
1) a ferromagnetic medium - the magnet core,
2) the surrounding air medium,
3) a current-carrying copper coil.
Variables
A
Definitions
rmu = 1
rmu0 = 1
mu0core = 5000
mu1core = 200
mucore = mu0core/(1+0.05*grad(A)^2) + mu1core
rmucore = 1/mucore
S = 0
current = 2
y0 = 8
Initial Value
{ In nonlinear problems, a good starting value
is sometimes essential for convergence }
A = current*(400-(x-20)^2-(y-20)^2)
Equations
A : curl(rmu*curl(A)) = S
Boundaries
Region 1 { The IRON core }
rmu = rmucore rmu0 = 1/mu0core
435 FlexP DE 7 : Sample P roblems
start(0,0)
natural(A) = 0 line to (40,0)
value(A) = 0 line to (40,40) to (0,40) to close
5.1.9 Misc
5.1.9.1 diffusion
{ DIFFUSION.PDE
This problem considers the thermally driven diffusion of a dopant into
a solid from a constant source. Parameters have been chosen to be those
typically encountered in semiconductor diffusion.
surface concentration = 1.8e20 atoms/cm^2
diffusion coefficient = 3.0e-15 cm^2/sec
The natural tendency in this type of problem is to start with zero
concentration in the material, and a fixed value on the boundary. This
implies an infinite curvature at the boundary, and an infinite transport
velocity of the diffusing particles. It also generates over-shoot
in the solution, because the Finite-Element Method tries to fit a step
function with quadratics.
definitions
concs = 1.8e8 { surface concentration atom/micron^3}
D = 1.1e-2 { diffusivity micron^2/hr}
conc = concs*u
uexact1d = erfc(x/(2*sqrt(D*t))) { analytic solution to corresponding 1D problem }
cexact1d = concs*uexact1d
M = upulse(y-0.3,y-0.7) { masked surface flux multiplier }
initial values
Sample P roblems : Applications 436
u = 0
equations
u : div(D*grad(u)) = dt(u)
boundaries
region 1
start(0,0)
natural(u) = 0
line to (1,0) to (1,1) to (0,1)
natural(u) = 10*M*(1-u)
line to close
feature { a "gridding feature" to help localize the activity }
start (0.02,0.3) line to (0.02,0.7)
time 0 to 1 by 0.001
plots
for t=1e-5 1e-4 1e-3 1e-2 0.05 by 0.05 to 0.2 by 0.1 to endtime
contour(u)
surface(u)
elevation(u,uexact1d) from (0,0.5) to (1,0.5)
elevation(u-uexact1d) from (0,0.5) to (1,0.5)
histories
history(u) at (0.05,0.5) (0.1,0.5) (0.15,0.5) (0.2,0.5)
end
For the function U to have minimal surface area, it must satisfy the
Euler equation
dx(dF/dUx) + dy(dF/dUy) - dF/dU = 0
where
F = sqrt[1 + (dU/dx)^2 + (dU/dy)^2]
dF/dUx = (dU/dx)/F
dF/dUy = (dU/dy)/F
dF/dU = 0
The equation for the minimizing surface is therefore (in FlexPDE notation):
dx((1/F)*dx(U)) + dy((1/F)*dy(U)) = 0
This is analogous to a heatflow problem
div(K*grad(T)) = 0
where the conductivity has the value
K = 1/F
This is a highly nonlinear problem, in that the conductivity, K, becomes
small in regions of high gradient, which tends to increase the gradient
even more.
437 FlexP DE 7 : Sample P roblems
5.1.9.3 surface_fit
{ SURFACE_FIT.PDE
This problem illustrates the use of FlexPDE in a data fitting
application.
THE NUMERICAL SOLUTION OF THE BIHARMONIC EQUATION WITH A DISCONTINUOUS
LINEAR SOURCE TERM USING FlexPDE.
STATEMENT OF THE PROBLEM:
Find the solution U of the fourth order elliptic PDE
(dxx + dyy)(dxx + dyy) (U) = -beta*(U - C) in O, (1)
where in the usual FlexPDE notation, dxx indicates 2nd partial derivative
with respect to x, and where O is a given connected domain. Equation (1)
arises from the minimization of the strain energy function of a thin plate
which is constrained to nearly pass thru a given set of discrete set of
points specified by C and beta. Namely, a given set of n data values
[C(i)] is assigned at locations [(x(i), y(i))], i=1,..n ,
and the factor beta has its support only at the locations (x(i), y(i)).
Along with equation (1), we must prescribe a set of boundary conditions
involving U and its derivatives which must be satisfied everywhere on the
domain boundary.
}
title " The Biharmonic Equation in Surface Fitting Designs and Visualization"
variables
U
Sample P roblems : Applications 438
V
definitions
eps = .001
beta0 = 1.e7
beta = 0.0
a = 1/sqrt(2.)
two = 2.5
b = two*a
xbox = array (0, 1, -1, 0, 0, a, -a, a, -a, two, -two, 0, 0, b, -b, b, -b )
ybox = array (0, 0, 0, 1, -1, a, -a, -a, a, 0, 0, two, -two, b, -b, -b, b )
xi = .05 eta = .05
r0 = x*x + y*y
C = exp(-r0/1.)*sin(pi*((x^2-y^2)/64.))
initial values
U = 0
V = .001
equations
U: del2(U) = V
V: del2(V) = -beta*(U-C)
boundaries
region 1
start (-4,0)
value(U) = C value(V) = 0.
arc(center=0.,0.) angle -360 to
close
region 2 beta = beta0
repeat i=1 to 17
start (xbox[i]-xi,ybox[i]-eta)
line to (xbox[i]+xi,ybox[i]-eta)
to (xbox[i]+xi,ybox[i]+eta)
to (xbox[i]-xi,ybox[i]+eta) to close
endrepeat
monitors
contour(U)
contour(C)
contour(C-U) as "Error C - U"
plots
contour (U) as "Potential"
surface(U) as "Potential"
surface(C) as " Expected Surface"
contour(beta)
surface(beta)
surface(U-C)
end
5.1.10 Quantun_Mechanics
5.1.10.1 1d_finite_potential_well
{ 1D_FINITE_POTENTIAL_WELL.PDE
Submitted by Ali Reza Ghaffari, 07/22/2016.
This script solves the Schrodinger equation for a one dimensional finite potential well
and finds energy levels for bound states plus unnormalaized wave functions.
}
TITLE '1D Finite Potential Well'
COORDINATES CARTESIAN1
VARIABLES Phi
SELECT
439 FlexP DE 7 : Sample P roblems
modes=3
NGRID=30
ERRLIM=1e-3
DEFINITIONS
volt { in eV}
hbar=1.05457e-34
e0=1.6022e-19
m0=9.11e-31
v0=64
a=1.8e-10
EQUATIONS
Phi: (-hbar^2/2/m0/e0)*(dx(dx(Phi)))+volt*Phi-LAMBDA*Phi=0
BOUNDARIES
REGION 1
volt=v0
START (-3*a) point value(phi)=0
LINE TO (-a/2)
REGION 2
volt=0
START (-a/2) LINE TO (a/2)
REGION 3
volt=v0
START (a/2)
LINE TO (3*a ) point value(phi)=0
!MONITORS
! no monitors since problem solves so fast
PLOTS
elevation(phi*5+lambda,volt) from (-3e-10) to (3e-10)
SUMMARY
REPORT(LAMBDA)
END
5.1.10.2 2d_finite_potential_well
{ 2D_FINITE_POTENTIAL_WELL.PDE
Submitted by Ali Reza Ghaffari, 07/22/2016.
This script solves the Schrodinger equation for a two dimensional finite potential
well.
This script finds energies and wave functions of a wire with rectangle cross section.
The wire is made up of GA As which is placed in a AlGalAs medum.
}
TITLE 'infinitely deep rectangular wires'
COORDINATES cartesian2
SELECT
modes=4
NGRID=13
ERRLIM=1e-3
painted { show colour-filled contours }
thermal_colors = on { red is minimum }
DEFINITIONS
mass{default value}
volt { in eV}
Sample P roblems : Applications 440
hbar=1.05457e-34
m0=9.11e-31
e0=1.6e-19
xx=200e-10
yy=200e-10
x1=50e-10
y1=50e-10
x2=150e-10
y2=150e-10
v0=.228
mass_shell=0.067*m0 {mhh}!0.067 {GaAs}
mass_core=0.1*m0! {Al0.5Ga0.5As}
N=integral(phi^2)
EQUATIONS
Phi: ((-1)* hbar^2/(2*mass*e0))*div(grad(Phi))+volt*Phi-LAMBDA*Phi =0
BOUNDARIES
Region 1
mass= mass_shell, volt=v0
start(0,0)
point value (phi)=0 line to (xx,0)
value (phi)=0 line to (xx,yy)
value (phi)=0 line to (0,yy)
to close
Region 2
mass= mass_core, volt=0
start(x1,y1)
line to (x2,y1) to (x2,y2) to (x1,y2)
to close
!MONITORS
! no monitors since problem solves so fast
PLOTS
CONTOUR(Phi^2/sqrt(N))
SUMMARY
REPORT(LAMBDA*1000) as "Energy Level (meV)" !in milielectron volt
END
5.1.10.3 m orse_potential
{ MORSE_POTENTIAL.PDE
Submitted by Ali Reza Ghaffari, 07/21/2016.
This is a Quantum Mechanic example that shows the power of Flexpde to solve such
examples.
We want to solve the Schrodinger equation for Morse Potential V(x)=V0(1-exp(-alpha*x))
^2 and
find the Eigen values and functions. The exact energies can be extracted from the
formula below.
E[n] := h*2^(1/2)*(V0*alpha^2/m0)^(1/2)*(n+1/2)-1/2*alpha^2*h^2/m0*(n+1/2)^2
For n=0 to 4 :
E[0] := 3.037277660
E[1] := 8.361832980
E[2] := 12.68638830
E[3] := 16.01094362
E[4] := 18.33549894
You can compare the results of this script with above energies.
}
COORDINATES CARTESIAN1
VARIABLES Phi
SELECT
modes=6
NGRID=30
ERRLIM=1e-3
DEFINITIONS
volt
hbar=1
m0=1
v0=20
a=10 ! the renge of integrals
alpha=1
volt=v0*(1-exp(-alpha*x))^2
N=integral(phi^2)
EQUATIONS
Phi : (-hbar^2/2/m0)*(dx(dx(Phi)))+volt*Phi-LAMBDA*Phi=0
BOUNDARIES
REGION 1
START (-3*a) point value(phi)=0
LINE TO (3*a) point value(phi)=0
!MONITORS
! no monitors since problem solves so fast
PLOTS
ELEVATION(Phi+lambda,volt) FROM (-1) to (6) zoom (-1,0,6,10)
SUMMARY
REPORT(LAMBDA)
END
5.1.11 Stress
5.1.11.1 3d_bim etal
{ 3D_BIMETAL.PDE
}
title 'Bimetal Part'
coordinates
cartesian3
select
painted { show color-filled contours }
biprecon { use the Block-Inverse
preconditioner - it works better than the
default ICCG }
variables
Tp { temperature difference from
stress-free state }
U { X displacement }
V { Y displacement }
W { Z displacement }
materials
'iron' :
K = 0.11 { thermal conductivity
}
E = 20e11 { Youngs modulus }
nu = 0.28 { expansion
coefficient }
alpha = 1.7e-6 { Poisson's Ratio }
'aluminum' :
K = 0.5
E = 6e11
nu = 0.25
alpha = 2*(2.6e-6) !
Exaggerate expansion
'default' :
K = 1
E = 1e11
nu = 0.1
alpha = 1e-6
definitions
long = 1
wide = 0.3
high = 1
tabx = 0.2
taby = 0.4
Q = 0 { Thermal source }
Ta = 0. { define the ambient thermal sink temperature }
{ define the constitutive relations }
G = E/((1+nu)*(1-2*nu))
C11 = G*(1-nu)
C12 = G*nu
C13 = G*nu
C22 = G*(1-nu)
C23 = G*nu
C33 = G*(1-nu)
C44 = G*(1-2*nu)/2
b = G*alpha*(1+nu)
{ Strains }
ex = dx(U)
ey = dy(V)
ez = dz(W)
gxy = dy(U) + dx(V)
gyz = dz(V) + dy(W)
gzx = dx(W) + dz(U)
{ Stresses }
Sx = C11*ex + C12*ey + C13*ez - b*Tp
Sy = C12*ex + C22*ey + C23*ez - b*Tp
Sz = C13*ex + C23*ey + C33*ez - b*Tp
Txy = C44*gxy
443 FlexP DE 7 : Sample P roblems
Tyz = C44*gyz
Tzx = C44*gzx
{ find mean translation and rotation }
Vol = Integral(1)
Tx = integral(U)/Vol { X-motion }
Ty = integral(V)/Vol { Y-motion }
Tz = integral(W)/Vol { Z-motion }
Rz = 0.5*integral(dx(V) - dy(U))/Vol { Z-rotation }
Rx = 0.5*integral(dy(W) - dz(V))/Vol { X-rotation }
Ry = 0.5*integral(dz(U) - dx(W))/Vol { Y-rotation }
{ displacements with translation and rotation removed }
{ This is necessary only if all boundaries are free }
Up = U - Tx + Rz*y - Ry*z
Vp = V - Ty + Rx*z - Rz*x
Wp = W - Tz + Ry*x - Rx*y
{ scaling factors for displacement plots }
Mx = 0.2*globalmax(magnitude(y,z))/globalmax(magnitude(Vp,Wp))
My = 0.2*globalmax(magnitude(x,z))/globalmax(magnitude(Up,Wp))
Mz = 0.2*globalmax(magnitude(x,y))/globalmax(magnitude(Up,Vp))
Mt = 0.4*globalmax(magnitude(x,y,z))/globalmax(magnitude(Up,Vp,Wp))
initial values
Tp = 5.
U = 1.e-5
V = 1.e-5
W = 1.e-5
equations
Tp: div(k*grad(Tp)) + Q = 0. { the heat equation }
U: dx(Sx) + dy(Txy) + dz(Tzx) = 0 { the U-displacement equation }
V: dx(Txy) + dy(Sy) + dz(Tyz) = 0 { the V-displacement equation }
W: dx(Tzx) + dy(Tyz) + dz(Sz) = 0 { the W-displacement equation }
extrusion z = 0,long
boundaries
surface 1 value(Tp)=100 { fixed temp bottom }
surface 2 natural(Tp)=0.01*(Ta-Tp) { poor convective cooling top }
Region 1 { Iron }
use material 'iron'
start(0,0)
natural(Tp) = 0.1*(Ta-Tp) { better convective cooling on vertical sides }
line to (wide,0)
to (wide,(high-taby)/2)
to (wide+tabx,(high-taby)/2)
to (wide+tabx,(high+taby)/2)
to (wide,(high+taby)/2)
to (wide,high)
to (0,high)
to close
Region 2 { Aluminum }
use material 'aluminum'
start(wide,(high-taby)/2)
line to (wide+tabx,(high-taby)/2)
to (wide+tabx,(high+taby)/2)
to (wide,(high+taby)/2)
to close
monitors
contour(Tp) on y=high/2 as "Temperature"
contour(Up) on y=high/2 as "X-displacement"
contour(Vp) on x=4*wide/5 as "Y-displacement"
contour(Wp) on y=high/2 as "Z-displacement"
grid(x+My*Up,z+My*Wp) on y=high/2 as "XZ Shape"
grid(y+Mx*Vp,z+Mx*Wp) on x=wide/2 as "YZ Shape"
grid(x+Mz*Up,y+Mz*Vp) on z=long/4 as "XY Shape"
grid(x+Mt*Up,y+Mt*Vp,z+Mt*Wp) as "Shape"
plots
contour(Tp) on y=high/2 as "XZ Temperature"
contour(Up) on y=high/2 as "X-displacement"
contour(Vp) on x=4*wide/5 as "Y-displacement"
Sample P roblems : Applications 444
5.1.11.2 anisotropic_stress
{ ANISOTROPIC_STRESS.PDE
This example shows the application of FlexPDE to an extremely complex
problem in anisotropic thermo-elasticity. The equations of thermal
diffusion and plane strain are solved simultaneously to give the
thermally-induced stress and deformation in a laser application.
-- Submitted by Steve Sutton
Lawrence Livermore National Laboratory
}
Tb = 0.
Q = Q0*(exp(-2*(x^2+y^2)/ro^2)) { Gaussian heat distribution }
end
Sample P roblems : Applications 446
ycylinder('R','Z')
variables
U { declare U and V to be the system variables }
V
definitions
nu = 0.3 { define Poisson's Ratio }
E = 20 { Young's Modulus x 10^-11 }
alpha = 0 { define the thermal expansion coefficient }
G = E/(1+nu)
C1 = G*(1-nu)/(1-2*nu) { define the constitutive relations }
C2 = G*nu/(1-2*nu)
b = alpha*G*(1+nu)/(1-2*nu)
Fr = 0 { define the body forces }
Fz = 0
Temp = 0 { define the temperature }
Sr = C1*dr(U) + C2*(U/r + dz(V)) - b*Temp
St = C1*U/r + C2*(dr(U) + dz(V)) - b*Temp
Sz = C1*dz(V) + C2*(dr(U) + U/r) - b*Temp
Trz = G*(dz(U) + dr(V))/2
r1 = 2 { define the inner and outer radii of a doughnut }
r2 = 5
q21 = r2/r1
L = 1.0 { define the height of the doughnut }
initial values
U = 0
V = 0
equations { define the axi-symmetric displacement equations }
U: dr(r*Sr)/r - St/r + dz(Trz) + Fr = 0
V: dr(r*Trz)/r + dz(Sz) + Fz = 0
boundaries
region 1
start(r1,0)
load(U) = 0 { define a free boundary along bottom }
load(V) = 0
line to (r2,0)
value(U) = 0 { constrain R-displacement on right }
load(V) = -E/100 { apply a downward shear load }
line to (r2,L)
load(U) = 0 { define a free boundary along top }
load(V) = 0
line to (r1,L)
5.1.11.4 bentbar
{ BENTBAR.PDE
This is a test problem from Timoshenko: Theory of Elasticity, pp41-46
A cantilever is loaded by a distributed shearing force on the free end,
Sample P roblems : Applications 448
region 1
start (0,-hW)
load(U)=0 { free boundary on bottom, no normal stress }
load(V)=0
line to (L,-hW)
value(U) = Uexact { clamp the right end }
mesh_spacing=hW/10
line to (L,0) point value(V) = 0
line to (L,hW)
load(U)=0 { free boundary on top, no normal stress }
load(V)=0
mesh_spacing=10
line to (0,hW)
load(U) = 0
load(V) = dist { apply distributed load to Y-displacement equation }
line to close
plots
grid(x+mag*U,y+mag*V) as "deformation" { show final deformed grid }
elevation(V,Vexact) from(0,0) to (L,0) as "Center Y-Displacement(M)"
elevation(V,Vexact) from(0,hW) to (L,hW) as "Top Y-Displacement(M)"
elevation(U,Uexact) from(0,hW) to (L,hW) as "Top X-Displacement(M)"
elevation(Sx,Sxexact) from(0,hW) to (L,hW) as "Top X-Stress"
elevation(Txy,Txyexact) from(0,0) to (L,0) as "Center Shear Stress"
end
{ BENTBAR_MOVING.PDE
This problem is a moving mesh variant of BENTBAR.PDE
}
variables
U(1e-6) { X-displacement }
V (1e-6) { Y-displacement }
Xm = move(x)
Ym = move(y)
definitions
L = 1 { Bar length }
hL = L/2
W = 0.1 { Bar thickness }
hW = W/2
eps = 0.01*L
I = 2*hW^3/3 { Moment of inertia }
initial values
U = 0
V = 0
boundaries
region 1
start (0,-hW)
load(U) = 0
load(V) = dist { apply distributed load to Y-displacement equation }
line to close
plots
for cycle=1
! x and y have already been moved by u and v, but this is small compared to mag*u,
etc.
grid(x+mag*U,y+mag*V) as "deformation" { show final deformed grid }
elevation(V,Vexact) from(0,0) to (L,0) as "Center Y-Displacement(M)"
elevation(V,Vexact) from(0,hW) to (L,hW) as "Top Y-Displacement(M)"
elevation(U,Uexact) from(0,hW) to (L,hW) as "Top X-Displacement(M)"
elevation(Sx,Sxexact) from(0,hW) to (L,hW) as "Top X-Stress"
elevation(Txy,Txyexact) from(0,0) to (L,0) as "Center Shear Stress"
end "JqARWPEgsA1HmFOIXNmCNfb+qWfQGus/TmzjXhVHKZ2Q6NnpPJOCREi6wK8g8g
+Pnvy7DriMhUjFAl1qcBgg5yF+MkmYxGJoetheissilVHa1rvSKiA1A0QLkuYpmTaJG2+/v5g68e
+flbisgxXY2m4KBHCsFJGbJsy2FFnplf6"
5.1.11.6 elasticity
{ ELASTICITY.PDE
This example shows the application of FlexPDE to a complex problem in
thermo-elasticity. The equations of thermal diffusion and
plane strain are solved simultaneously to give the thermally-induced
stress and deformation in a laser application.
451 FlexP DE 7 : Sample P roblems
We wish to calculate the effect of the thermal load on the laser rod.
'left' :
natural(Tp) = 0. { no heat loss }
natural(Up) = 0. { zero X-load }
natural(Vp) = 0. { zero Y-load }
initial values
Tp = 5. { give FlexPDE an estimate of variable range }
Up = 1.e-5
Vp = 1.e-5
equations
{ the heat equation }
Tp: dx(k*dx(Tp)) + dy(k*dy(Tp)) + Q = 0.
{ the U-displacement equation }
Up: dx(C11*dx(Up)+C12*dy(Vp)-b*Tp) + dy(C33*(dy(Up)+dx(Vp))) = 0.
{ the V-displacement equation }
Vp: dx(C33*(dy(Up)+dx(Vp))) + dy(C12*dx(Up)+C22*dy(Vp)-b*Tp) = 0.
constraints { prevent rigid-body motion: }
integral(up) = 0 { cancel X-motion }
453 FlexP DE 7 : Sample P roblems
use bc 'main'
line to (5,-5) to (5,5) to (0,5)
use bc 'left'
line to close
region 2 { region two overlays an Indium potting layer }
k = 0.083
Q = 0.
E = 60.0e3
nu = 0.4
alpha = 16e-6
start (0,-0.6)
line to (0.6,-0.6) to (0.6,0.6) to (0,0.6) to (0,0.5) to (0,-0.5) to close
region 3 { region three overlays the laser rod }
k = 0.0098
Q = Qrodp
E = 282.0e3
nu = 0.28
alpha = 7e-6
start (0,-0.5)
line to (0.5,-0.5) to (0.5,0.5) to (0,0.5) to close
monitors
contour(Tp) as "Temperature"
contour(Tp) as "Temperature" zoom(0,0,1,1)
contour(Q) as "Heat deposition" zoom(0,0,1,1)
contour(Up) as "X-displacement" zoom(0,0,1,1)
contour(Vp) as "Y-displacement" zoom(0,0,1,1)
grid(x+10000*Up,y+10000*Vp) as "deformation"
plots
grid(x,y)
contour(Tp) as "Temperature"
contour(Tp) as "Temperature" zoom(0,0,1,1)
contour(Q) as "Heat deposition" zoom(0,0,1,1)
contour(Up) as "X-displacement" !zoom(0,0,1,1)
contour(Vp) as "Y-displacement" !zoom(0,0,1,1)
contour(Sx) as "X-Stress" zoom(0,-0.75,1.5,1.5)
contour(Sy) as "Y-Stress" zoom(0,-0.75,1.5,1.5)
contour(Txy) as "Shear Stress" zoom(0,-0.75,1.5,1.5)
vector(Up,Vp) as "displacement"
vector(Up,Vp) as "displacement" zoom(0,0,1,1)
grid(x+10000*Up,y+10000*Vp) as "deformation"
end
D = E*h^3/(12*(1-nu^2))
E is Young's Modulus
nu is Poisson's ratio
and h is the plate thickness.
(See FREE_PLATE.PDE 455 for the solution with a simply supported edge.)
Note: Care must be exercised when extending this formulation to more complex
problems. In particular, in the equation del2(U) = V, V acts as a source
in the boundary-value equation for U. Imposing a value boundary condition
on U does not enforce V = del2(U).
}
Variables
U(0.1)
V(0.1)
Definitions
xslab = 11.2
yslab = 8
h = 0.0598 {16 ga}
L = 1.0e4
E = 29e6
Q = 14.7
nu = .3
D = E*h^3/(12*(1-nu^2))
Initial Values
U = 0
V = 0
Equations
U: del2(U) = V
V: del2(V) = Q/D
Boundaries
Region 1
start (0,0)
natural(U) = 0
natural(V) = L*U
line to (xslab,0)
to (xslab,yslab)
to (0,yslab)
to close
455 FlexP DE 7 : Sample P roblems
Monitors
contour(U)
Plots
contour (U) as "Displacement"
elevation(U) from (0,yslab/2) to (xslab,yslab/2) as "Displacement"
surface(U) as "Displacement"
End
5.1.11.8 free_plate
{ FREE_PLATE.PDE
This example considers the bending of a thin rectangular plate under a
distributed transverse load.
For small displacements, the deflection U is described by the Biharmonic
equation of plate flexure
del2(del2(U)) + Q/D = 0
where
Q is the load distribution,
D = E*h^3/(12*(1-nu^2))
E is Young's Modulus
nu is Poisson's ratio
and h is the plate thickness.
The boundary conditions to be imposed depend on the way in which the
plate is mounted. Here we consider the case of a simply supported
boundary, for which the correct conditions are
U = 0
Mn = 0
where Mn is the tangential component of the bending moment, which in turn
is related to the curvature of the plate. An approximation to the second
boundary condition is then
del2(U) = 0.
FlexPDE cannot directly solve the fourth order equation, but if we
define V = del2(U), then the deflection equation becomes
del2(U) = V
del2(V) + Q = 0
with the boundary conditions
U = 0
V = 0.
The particular problem addressed here is a plate of 16-gauge steel,
8 x 11.2 inches, covering a vacuum chamber, with atmospheric pressure
loading the plate. The edges are simply supported. Solutions to this
problem are readily available, for example in Roark's Formulas for Stress
& Strain, from which the maximum deflection is Umax = 0.746, as compared
with the FlexPDE result of 0.750.
L = 1.0e6
E = 29e6
Q = 14.7
nu = .3
D = E*h^3/(12*(1-nu^2))
Initial Values
U = 0
V = 0
Equations
U: del2(U) = V
V: del2(V) = Q/D
Boundaries
Region 1
start (0,0)
value(U) = 0
value(V) = 0
line to (xslab,0)
to (xslab,yslab)
to (0,yslab)
to close
Monitors
contour(U)
Plots
contour (U) as "Displacement"
elevation(U) from (0,yslab/2) to (xslab,yslab/2) as "Displacement"
surface(U) as "Displacement"
End
boundaries
region 1
start (0,-hW)
load(Ur)=0 { free boundary on bottom, no normal stress }
load(Ui)=0
load(Vr)=0
load(Vi)=0
line to (L,-hW)
load(Vr) = force { Apply oscillatory vertical load on end. }
line to (L,hW)
load(Vr)=0 { free boundary on top, no normal stress }
line to (0,hW)
value(Ur) = 0 { clamp the left end }
value(Ui) = 0
value(Vr) = 0
value(Vi) = 0
line to close
monitors
elevation(Vr,Vi) from(0,0) to (L,0)
report(omega) report(mu)
plots
grid(x+mag*Ur,y+mag*Vr) as "Real displacement" { show final deformed grid }
report(omega) report(mu)
grid(x+mag*Ui,y+mag*Vi) as "Imag
displacement"
report(omega) report(mu)
elevation(Vr,Vi) from(0,0) to (L,0)
report(omega) report(mu)
contour(Ur) as "Real X-displacement(M)"
report(omega) report(mu)
contour(Vr) as "Real Y-displacement(M)"
report(omega) report(mu)
contour(Ui) as "Imag X-displacement(M)"
report(omega) report(mu)
contour(Vi) as "Imag Y-displacement(M)"
report(omega) report(mu)
contour(Sxm) as "X-Stress amplitude"
report(omega) report(mu)
contour(Sym) as "Y-Stress amplitude"
report(omega) report(mu)
contour(Txym) as "Shear Stress amplitude"
report(omega) report(mu)
end
5.1.11.10 prestube
{ PRESTUBE.PDE
This example models the stress in a tube with an internal pressure.
- from "Fields of Physics on the PC" by Gunnar Backstrom
}
459 FlexP DE 7 : Sample P roblems
title
' Tube With Internal Pressure'
variables
u
v
definitions
mm = 1e-3
r1 = 3*mm
r2 = 10*mm
q21= r2/r1
mu = 0.3
E = 200e9 {Steel}
c = E/(1-mu^2)
G = E/2/(1+mu)
dabs= sqrt(u^2+ v^2)
ex= dx(u)
ey= dy(v)
exy= dx(v)+ dy(u)
sx= c*(ex+ mu*ey)
sy= c*(mu*ex+ ey)
sxy= G*exy
p1= 1e8 { the internal pressure }
{ Exact expressions }
rad= sqrt(x^2+ y^2)
sr_ex= -p1*((r2/rad)^2 - 1)/(q21^2 - 1)
st_ex= p1*((r2/rad)^2 + 1)/(q21^2 - 1)
dabs_ex= abs( rad/E*(st_ex- mu*sr_ex))
equations { Constant temperature, no volume forces }
u: dx( c*(dx(u) + mu*dy(v)) ) + dy( G*(dx(v)+ dy(u)) )= 0
v: dx( G*( dx(v)+ dy(u)) )+ dy( c*(dy(v) + mu*dx(u)) )= 0
constraints { Since all boundaries are free, it is necessary
to apply constraints to eliminate rigid-body motions }
integral(u) = 0
integral(v) = 0
integral(dx(v)-dy(u)) = 0
boundaries
region 1
start (r2,0)
load(u)= 0 { Outer boundary is free }
load(v)= 0
arc to (0,r2) to (-r2,0) to (0,-r2) to close
start (r1,0) { Cut-out }
load(u)= p1*x/r1 { Normal component of x-stress }
load(v)= p1*y/r1 { Normal component of y-stress }
arc to (0,-r1) to (-r1,0) to (0,r1) to close
monitors
contour(dabs)
plots
grid(x+200*u, y+200*v)
elevation(sx, sr_ex) from (r1,0) to (r2,0)
elevation(sy, st_ex) from (r1,0) to (r2,0)
contour(dabs) contour((dabs-dabs_ex)/dabs_ex)
contour(u) contour(v)
vector(u,v) vector(u/dabs, v/dabs)
contour(sx) contour(sy) contour(sxy)
end
5.1.11.11 tension
{ TENSION.PDE
This example shows the deformation of a tension bar with a hole.
The equations of Stress/Strain arise from the balance of forces in a
material medium, expressed as
dx(Sx) + dy(Txy) + Fx = 0
dx(Txy) + dy(Sy) + Fy = 0
Sample P roblems : Applications 460
G = E/(1-nu^2)
C11 = G
C12 = G*nu
C22 = G
C33 = G*(1-nu)/2
p1 = (1-nu)/2
initial values
U = 1
V = 1
equations { define the Plane-Stress displacement equations }
U: dx(dx(U) + nu*dy(V)) + p1*dy(dy(U) + dx(V)) = 0
V: dy(dy(V) + nu*dx(U)) + p1*dx(dy(U) + dx(V)) = 0
boundaries
region 1
start (0,0)
load(U)=0 { free boundary, no normal stress }
load(V)=0
line to (3,0) { walk bottom }
load(U)=0.1 { define an X-stress of 0.1 unit on right edge}
load(V) = 0
line to (3,1)
load(U)=0 { free boundary top }
load(V)=0
line to (0,1)
value(U)=0 { fixed displacement on left edge }
value(V)=0
line to close
{ Cut out a hole }
load(U) = 0
load(V) = 0
start(1,0.25)
arc(center=1,0.5) angle=-360
monitors
grid(x+U,y+V) { show deformed grid as solution progresses }
plots { hardcopy at to close: }
grid(x+U,y+V) { show final deformed grid }
vector(U,V) as "Displacement" { show displacement field }
contour(U) as "X-Displacement"
contour(V) as "Y-Displacement"
contour((C11*dx(U) + C12*dy(V))) as "X-Stress"
contour((C12*dx(U) + C22*dy(V))) as "Y-Stress"
surface((C11*dx(U) + C12*dy(V))) as "X-Stress"
surface((C12*dx(U) + C22*dy(V))) as "Y-Stress"
end
5.1.11.12 v ibrate
{ VIBRATE.PDE
This example shows the use of FlexPDE in transient Stress problems.
The equations of Stress/Strain in a material medium can be given as
dx(Sx) + dy(Txy) + Fx = 0
dx(Txy) + dy(Sy) + Fy = 0
where Sx and Sy are the stresses in the x- and y- directions,
Txy is the shear stress, and
Fx and Fy are the body forces in the x- and y- directions.
In a time-dependent problem, the material acceleration and viscous force
act as body forces, and are included in a new body force term
Fx1 = Fx0 - rho*dtt(Ux) + mu*del2(dt(Ux))
Fy1 = Fy0 - rho*dtt(Uy) + mu*del2(dt(Uy))
where rho is the material mass density, mu is the viscosity, and Ux and Uy
are the material displacements.
Sample P roblems : Applications 462
In the problem considered here, we have an aluminum bar one meter long and
5 cm thick suspended on the left, and driven on the right by an oscillatory
load. The load frequency is chosen to be near the resonant frequency of
the bar.
}
title "Transient Stress analysis"
select
deltat=1.0e-7 { Start out at careful timestep, it will grow. }
ngrid=21 { Grid a little more densely than default }
regrid = off { Cell splitting causes instantaneous changes in the
effective material properties. These changes act
like small earthquakes in the material, and propagate
high-frequency noise. To avoid these effects, we
supress grid refinement. }
variables { Recall that the declared variable range, if too large,
will affect the interpretation of error, and thus the
timestep and solution accuracy }
Ux (threshold=1e-7) { Displacements }
Uy (threshold=1e-7)
Vx (threshold=1e-5) { Velocities }
Vy (threshold=1e-5)
definitions
L = 1 { the bar length, in Meters }
hL = L/2
W = 0.05 { the bar thickness, in Meters }
hW = W/2
eps = 0.01*L
boundary conditions
'no load' : load(Vx)=0 load(Vy)=0
'Y load' : load(Vx)=0 load(Vy)=jiggle
'freeze' : value(Ux)=0 value(Uy)=0 value(Vx)=0 value(Vy)=0
initial values
Ux = 0 { start at rest }
Uy = 0
Vx = 0
Vy = 0
equations { define the displacement equations }
Ux: Vx + smoother*div(grad(Ux)) = dt(Ux)
Uy: Vy + smoother*div(grad(Uy)) = dt(Uy)
Vx: dx(Sx) + dy(Txy) + mu*div(grad(Vx)) = rho*dt(Vx)
Vy: dx(Txy) + dy(Sy) + mu*div(grad(Vy)) = rho*dt(Vy)
boundaries
region 1
start (0,-hW)
monitors
for cycle=5
elevation(Uy) from(0,0) to (L,0) range=(-amplitude,amplitude)
plots
for t= period/2 by period/2 to endtime
grid(x+mag*Ux,y+mag*Uy) as "deformation" { show final deformed grid }
vector(Ux,Uy) as "displacement" { show displacement field }
vector(Vx,Vy) as "velocity" { show velocity field }
contour(Ux) as "X-displacement(M)"
contour(Uy) as "Y-displacement(M)"
contour(Vx) as "X-velocity(M/s)"
contour(Vy) as "Y-velocity(M/s)"
contour(Sx) as "X-Stress"
contour(Sy) as "Y-Stress"
contour(Txy) as "Shear Stress"
histories
history(Ux) at (L,0) (0.8*L,0) (hL,0) as "Horizontal Displacement(M)"
history(Vx) at (L,0) (0.8*L,0) (hL,0) as "Horizontal Velocity(M/s)"
history(Sx) at (eps,hW-eps) (eps,-hW+eps) (L-eps,hW-eps) (L-eps,-hW+eps)
as "Horizontal Stress"
history(Uy) at (L,0) (0.8*L,0) (hL,0) as "Vertical Displacement(M)"
history(Vy) at (L,0) (0.8*L,0) (hL,0) as "Vertical Velocity(M/s)"
history(Sy) at (eps,hW-eps) (eps,-hW+eps) (L-eps,hW-eps) (L-eps,-hW+eps)
as "Vertical Stress"
Sample P roblems : Applications 464
5.2 Usage
5.2.1 1D
5.2.1.1 1d_cy linder
{ 1D_CYLINDER.PDE
This problem tests the implementation of 1D cylindrical coordinates in FlexPDE.
A distributed source is applied to a heatflow equation. The source is chosen as
the analytic derivative of an assumed Gaussian solution. The numerical solution
is then compared to the analytical solution.
}
title '1D Cylinder Test -- Gaussian'
coordinates
cylinder1 { default coordinate name is 'R' }
variables
u
definitions
k = 1
w=0.1
{ assume a gaussian solution }
u0 = exp(-r^2/w^2)
{ apply the correct analytic source for cylindrical geometry (we could use
div(k*grad(u0)) here, but that would not test the 1D Cylinder expansions) }
s = -(4/w^2)*(r^2/w^2-1)*u0
left=point(0)
right=point(1/10)
equations
U: div(K*grad(u)) +s = 0
boundaries
region 1
start left point value(u)=u0
line to right point load(u)=(-2*k*r*u0/w^2)
monitors
elevation(u) from left to right
plots
elevation(u,u0) from left to right
elevation(u-u0) from left to right as "Error"
elevation(-div(grad(u)),s) from (0.01) to right
elevation(-grad(u),-grad(u0)) from (0.01) to right
end
C
definitions
D = 1
source = 0
b = 1
a = 2
C0 = 10
diss = 0.01 ! dissolution coefficient
Cext = 0 ! external sink concentration
Flux = -D*dr(C)
initial values
C = C0
equations
C: div(D*grad(C)) + source = dt(C)
boundaries
region 1
start (b) point load(C)=0
line to (a) point load(C)=diss*(Cext-C) !outer leakage rate
time 0 to 10
monitors
for cycle=1
elevation(C) from (b) to (a)
plots
for cycle=10
elevation(C) from (b) to (a)
elevation(Flux) from (b) to (a) range=(0,0.01) {minimum plot range}
history(C) at (b) ((b+a)/2) (a)
history(Flux) at (b) ((b+a)/2) (a)
end
5.2.1.3 1d_float_zone
{ 1D_FLOAT_ZONE.PDE
5.2.1.4 1d_slab
{ 1D_SLAB.PDE
This problem analyzes heat flow in a slab using 1D cartesian coordinates.
}
TITLE 'Heat flow through an Insulating layer in 1D'
COORDINATES
Cartesian1 { default coordinate is 'X' }
VARIABLES
Phi { the temperature }
DEFINITIONS
K = 1 { default conductivity }
R = 0.5 { insulator thickness }
EQUATIONS
Phi: Div(-k*grad(phi)) = 0
BOUNDARIES
REGION 1 { the total domain }
START(-1) POINT VALUE(Phi)=0
LINE TO (1) POINT VALUE(Phi)=1
{ note: no 'close'! }
REGION 2 'blob' { the embedded layer }
k = 0.001
START (-R) LINE TO (R)
PLOTS
ELEVATION(Phi) FROM (-1) to (1)
END
5.2.1.5 1d_sphere
{ 1D_SPHERE.PDE
This problem demonstrates the use of 1D spherical coordinates.
}
title '1D Sphere Test -- Gaussian'
coordinates
sphere1 { default coordinate name is "R" }
variables
u
definitions
k = 1
w=0.1
{ assume a gaussian solution }
u0 = exp(-r^2/w^2)
{ apply the correct analytic source for spherical geometry
(we could use div(k*grad(u0)) here, but that would not test the 1D Sphere
expansions) }
s = -(2/w^2)*(2*r^2/w^2-3)*u0
467 FlexP DE 7 : Sample P roblems
left=point(0)
right=point(1/10)
equations
U: div(K*grad(u)) +s = 0
boundaries
region 1
start left point value(u)=u0
line to right point load(u)=(-2*k*r*u0/w^2)
monitors
elevation(u) from left to right
plots
elevation(u,u0) from left to right
elevation(u-u0) from left to right as "Error"
elevation(-div(grad(u)),s) from (0.01) to right
end
5.2.2 3D_domains
5.2.2.1 2d_sphere_in_cy linder
{ 2D_SPHERE_IN_CYLINDER.PDE
2D cylindrical (axi-symmetric) model of an empty sphere in a cylindrical box.
}
title '2D sphere in a can'
coordinates
ycylinder("R","Z") { vertical coordinate is cylinder axis }
variables
u
definitions
k = 1
R0 = 1
box = 2*R0
equations
U: div(k*grad(u)) = 0
boundaries
region 1
start(0,-box)
value(u)=0 line to (box,-box)
natural(u)=0 line to (box,box)
value(u)=1 line to (0,box)
natural(u)=0 line to (0,R0) { cylindrical axis }
arc(center=0,0) angle=-180 { spherical cutout }
line to close { cylindrical axis }
monitors
grid(r,z)
contour(u)
plots
grid(r,z)
contour(u)
end
Select
regrid = off { for quicker completion }
ngrid = 16
variables
u
definitions
R0 = 1 { sphere radius }
hbox = R0/4 { box half-size }
{ Make the box-bounding circle slightly bigger than box, or corner
intersections will confuse the mesh generator. }
Rbox = 1.1*sqrt(2)*hbox
rho = sqrt(x^2+y^2) { 2d radius - don't use 'R', it's 3D radius! }
zsphere = SPHERE ((0,0,0),R0) { hemisphere shape }
zbottom = -zsphere { bottom of sphere }
ztop = zsphere { top of sphere }
zboxbottom = -hbox { default box-bounding surfaces - patched later in outer sphere }
zboxtop = hbox
zcone = hbox*(R0-rho)/(R0-Rbox) { cone shape for bringing box top to sphere
diameter }
K = 1 { Define all parameter defaults for non-box volume}
source = 0
equations
U: div(K*grad(u)) + source = 0
extrusion
surface z = zbottom { the bottom hemisphere and plane }
surface z = zboxbottom
surface z = zboxtop
surface z = ztop { the top hemisphere and plane }
boundaries
surface 1 value(u)=0 { for demonstration purposes }
surface 4 value(u)=0
region 1 { The sphere }
zboxbottom = -zcone
zboxtop = zcone
start (R0,0)
arc(center=0,0) angle=360 to close
limited region 2 { smaller circle overlays sphere }
layer 2 { ... and exists only in layer 2 }
start(Rbox,0)
arc(center=0,0) angle=360 to close
limited region 3 { the box outline }
layer 2 { box exists only in layer 2 }
source = 1
K = 0.1
start(-hbox,-hbox) line to (hbox,-hbox) to (hbox,hbox) to (-hbox,hbox) to close
plots
grid(x,y,z) as "outer sphere"
grid(x,z) on y=0 nolines as "cross-section showing box"
469 FlexP DE 7 : Sample P roblems
end
5.2.2.3 3d_cocktail
{ 3D_COCKTAIL.PDE
This problem constructs a cocktail glass.
It is the geometric construction only, there are no variables or equations.
LIMITED 232 regions are used to remove parts of the extruded shape.
COORDINATES cartesian3
DEFINITIONS
rad=sqrt( x^2+ y^2)
router = 0.3 { outer radius of glass }
zglass = 0.5 { glass height }
rbase = 0.2 { radius of the base }
zbase = 0.02 { thickness of the base and cone}
rstem = 0.02 { radius of the stem }
zstem = 0.3 { height of the stem }
zslope = (zglass-zstem)/(router-rstem){ slope of conic surface }
glassangle = arctan(zslope) { slope of conic surface }
zcone = max(0,(rad-rstem)*zslope) { conic surface of the glass }
EXTRUSION
surface 'bottom' z=0
layer 'base layer'
surface 'stem1' z=zbase
layer 'stem layer'
surface 'lower' z = zstem + zcone
layer 'cone layer'
surface 'upper' z = zbase*cos(glassangle) + min(zglass, zstem + zcone)
BOUNDARIES
limited region 'outer'
layer 'cone layer' { outer region exists only in cone }
start (router,0) arc( center=0,0) angle=360
limited region 'base'
layer 'base layer' { base region exists only in base }
start(rbase,0) arc(center=0,0) angle=360
limited region 'stem'
layer 'stem layer' { stem region exists in the stem and the bottom of the cone }
layer 'cone layer'
start(rstem,0) arc(center=0,0) angle=360
PLOTS
grid(x,y,z) paintregions as "final mesh"
grid(y,z) on x=0 nolines paintregions as "Region Map"
END
{ 3D_CYLSPEC.PDE
This problem considers the construction of a cylindrical domain in 3D.
}
coordinates
Sample P roblems : Usage 470
cartesian3
variables
u
definitions
K = 0.1 { thermal conductivity }
R0 = 1 { radius of the cylinder }
Heat = 1 { total heat generation }
theta = 45 { axis direction in degrees }
c = cos(theta degrees) { direction cosines of the axis direction }
s = sin(theta degrees)
axis = vector(c,s) { the axis direction vector }
len = 3 { cylinder length }
x0 = -(len/2)*c { beginning point of the cylinder axis }
y0 = -(len/2)*s
zoff = 10 { a z-direction offset for the entire figure }
{ the cylinder function constructs the top surface of a cylinder with azis
along z=0.5. The positive and negative values of this surface will be
separated by a distance of one unit at the diameter. }
zs = cylinder((x0,y0,0.5), (x0+len*c,y0+len*s, 0.5), R0)
equations
U: div(K*grad(u)) + heat = 0
extrusion
surface z = zoff-zs { the bottom half-surface }
surface z = zoff+zs { the top half-surface }
boundaries
surface 1 value(u) = 0 { fixed value on cylinder surfaces }
surface 2 value(u) = 0
region 1
start (x0,y0)
value(u)=0 { fixed value on sides and end planes }
line to (x0+R0*c,y0-R0*s)
to (x0+len*c+R0*c,y0+len*s-R0*s)
to (x0+len*c-R0*c,y0+len*s+R0*s)
to (x0-R0*c,y0+R0*s)
to close
definitions
s2 = sqrt(2)
plots
grid(x,y,z)
grid(y*s2,z) on x+y=s2
contour(u) on x=0 as "U on X=0"
contour(u) on x-y=0 as "U on vertical plane through cylinder axis"
contour(u) on x+y=s2 as "U on plane normal to axis"
vector(flux-DOT(flux,axis)*flux) on x=0 as "Flux in X=0 plane"
contour(DOT(flux,axis)) on x+y=s2 as "Flux normal to cross-axis plane"
contour(DOT(flux,axis)) on x+y=s2 zoom(0.6,11,0.3,0.3) as "Flux normal to cross-
axis plane"
contour(magnitude(flux)) on x+y=s2 as "Total flux in cross-axis plane"
contour(magnitude(flux)) on y=0 as "Total flux in Y=0 plane"
end
5.2.2.5 3d_ellipsoid
{ 3D_ELLIPSOID.PDE
This problem constructs an ellipsoid.
It is the geometric construction only, there are no variables or equations.
}
471 FlexP DE 7 : Sample P roblems
definitions
a=3 b=2 c=1 { x,y,z radii }
xc=1 yc=1 zc=1 { coordinates of ellipsoid center }
{ top half of ellipsoid surface :
the MAX function is used to ensure the surface is defined throughout all
x,y space - essentially placing an x=0 'skirt' on the ellipsoid surface }
ellipsoid = c*sqrt( max(0,1-(x-xc)^2/a^2-(y-yc)^2/b^2) )
extrusion
surface 'bottom' z = zc - ellipsoid
surface 'top' z = zc + ellipsoid
boundaries
region 'ellipse'
start(xc+a,yc)
arc(center=xc,yc) to (xc,yc+b) to (xc-a,yc) to (xc,yc-b) to close
plots
grid(x,y,z)
grid(x,y) on z=zc
grid(y,z) on x=xc
grid(x,z) on y=yc
end
5.2.2.6 3d_ellipsoid_shell
{ 3D_ELLIPSOID_SHELL.PDE
This problem constructs an elliptical shell.
It is the geometric construction only, there are no variables or equations.
}
grid(x,y,z)
grid(x,y) on z=zc paintregions
grid(y,z) on x=xc paintregions
grid(x,z) on y=yc paintregions
end
See the sample problem "3D_Capacitor" 369 for a somewhat more complicated
and interesting version.
}
EQUATIONS
V: DIV(K*GRAD(V)) = 0
EXTRUSION
SURFACE "Bottom" Z=0
LAYER "Bottom Air"
SURFACE "Bottom Air - Metal" Z=0.9
LAYER "Bottom Metal"
SURFACE "Bottom Metal - Dielectric" Z=1
LAYER "Dielectric"
SURFACE "Top Metal - Dielectric" Z=2
LAYER "Top Metal"
SURFACE "Top Metal - Air" Z=2.1
LAYER "Top Air"
SURFACE "Top" Z=3
BOUNDARIES
SURFACE "Bottom" VALUE(V)=0
SURFACE "Top" VALUE(V)=1
REGION 1 { this is the outer boundary of the system }
LAYER "Dielectric" K = Kdiel { all other layers default to Kair }
START(0,0)
LINE TO (5,0) TO (5,5) TO(0,5) to close
LIMITED REGION 2 { this region exists only in the "bottom metal" layer,
and describes the larger plate }
LAYER "Bottom Metal" K = Kmetal
START(1,0)
LAYER "Bottom Metal" VALUE(V)=V0
LINE TO (4,0)
LAYER "Bottom Metal" NATURAL(V)=0
LINE TO (4,5) TO (1,5) to close
LIMITED REGION 3 { this region exists only in layer "Top Metal",
and describes the smaller plate }
LAYER "Top Metal" K = Kmetal
START(2,0)
473 FlexP DE 7 : Sample P roblems
END
5.2.2.8 3d_fillet
{ 3D_FILLET.PDE
This problem demonstrates the use of the FILLET 235 and BEVEL 235 commands.
Both controls act in the 2D layout, and are extruded into the z dimension.
}
title 'fillet test'
coordinates
cartesian3
variables
u
definitions
k = 1
u0 = 1-x^2-y^2
s = 2*3/4+5*2/4
equations
U: div(K*grad(u)) +s = 0
extrusion z=0,1
boundaries
region 1
start(-1,-1)
value(u)=u0 line to (1,-1) FILLET(0.1)
to (-0.25,-0.25) FILLET(0.1)
to (-1,1) BEVEL(0.1)
to close
monitors
grid(x,y,z)
contour(u) on z=0.5
plots
grid(x,y) on z=0.005
grid(x,y) on z=0.5
contour(u) on z=0.5
contour(u) on z=0.5 zoom(0.6,-1, 0.2,0.2)
contour(u) on z=0.5 zoom(-0.3,-0.3, 0.1,0.1)
end
5.2.2.9 3d_guitar
{ 3D_GUITAR.PDE
This example only constructs a domain. There are no variables or equations.
It does demonstrate the use of the MATERIALS section.
}
TITLE "3D Guitar Body"
COORDINATES cartesian3
Sample P roblems : Usage 474
MATERIALS
"Default" : d = 1.0 k = 1.0
"Air" : d = 100 k = 0.07
"Maple" : d = 0.9 k = 7
"Spruce" : d = 0.7 k = 13
"Plastic" : d = 10 k = 0.22
"Composite" : d = 3 k = 1.3
DEFINITIONS
{------------- SIZE POSITION PARAMETERS -------------}
dface = 0.3, dback = 0.5, dbody = 10 ! some basic depths
dside = 0.7, dsaddle = 0.4, dnut = 0.8 ! some basic depths
slen = 11, swid = 3, spos = 19 ! saddle size and
positions
fpos = 50, fwid = 10, flen = 5 ! fretboard size and
positions
orad = 6, opos = 36 ! sound hole radius and
position
hrad = 0.7 ! string radius
h6 = 5, h5 = 3, h4 = 1, h1 = -h6, h2 = -h5, h3 = -h4 ! saddle hole radius and
positions
{------------- SPLINE POINTS -------------}
x0 = 0, x1 = 0, x2 = 18, x3 = 30, x4 = 40, x5 = 46, x6 = 60, x7 = 60
y0 = 0, y1 = 1, y2 = 19, y3 = 15, y4 = 12, y5 = 14, y6 = 2, y7 = 0
{------------- LAYER DEPTHS -------------}
origin = 0
inback = origin + dback
inface = inback + dbody
outface = inface + dface
outtool = outface + dsaddle
EXTRUSION
surface 'OUTSIDE BOTTOM' z = origin
layer 'BOTTOM'
surface 'INSIDE BOTTOM' z = inback
layer 'BODY'
surface 'INSIDE TOP' z = inface
layer 'TOP'
surface 'OUTSIDE TOP' z = outface
layer 'TOOL'
surface 'OUTSIDE TOOL' z = outtool
BOUNDARIES
{------------- OUTTER BODY -------------}
limited region 'OUTER BODY'
layer 'TOOL' VOID
layer 'BOTTOM' use material "Maple"
layer 'BODY' use material "Composite"
layer 'TOP' use material "Spruce"
start (x1,y0)
spline to (x1, y1) to (x2, y2) ! NW arc
to (x3, y3) to (x4, y4) !N arc
to (x5, y5) to (x6, y6) ! NE arc
!to (x6, y6) to (x6+flen, y6) !top of fretboard
to (x6, y7) ! top of neck
!to (x6+flen,-y6) to (x6,-y6) !bott of fretboard
to (x6, -y6) to (x5, -y5) ! SE arc
to (x4, -y4) to (x3, -y3) ! S arc
to (x2, -y2) to (x1, -y1) ! SW arc
to close
}
title '3D layered helix'
coordinates
cartesian3
variables
Tp
definitions
xwide = 1 { width of coil band }
zhigh = 1 { height of coil band }
zhaf = zhigh/2
pitch = 2*zhigh { z rise per turn }
x0 = 3 { center radius }
xin = x0-xwide/2 { inner radius }
xout = x0+xwide/2 { outer radius }
{ cut layers with reverse-helix. choose a steep cutpitch to avoid overlapping cut
regions: }
cutpitch = 4*pitch { z fall per turn of layer-cutting ribbon }
{ Compute the half-angle of the baseplane projection of the intersection between the
helix ribbon and the cut ribbon. This determines the size of the Regions
necessary
to describe the intersections. }
thetai = 2*pi*zhaf/(pitch+cutpitch)
ci = cos(thetai)
si = sin(thetai)
twist = pitch/(2*pi) { z-offset per radian }
cuttwist = cutpitch/(2*pi) { " }
{ measure angles from positive x-axis for right arcs and from negative x-axis for
left arcs, to avoid jumps in the atan2 function. NOTE: these definitions were
changed between v6 and v7 due to changes in the atan2 function itself. }
alphar = atan2(y,x) ! angular position (-pi,pi) relative to positive x-axis
alphal = atan2(-y,-x) ! angular position (-pi,pi) relative to negative x-axis
{ calculate layer-cut surfaces for left and right arcs (relative to the arc center) }
rlo = -(1/4)*pitch - cuttwist*(alphar+pi/2) ! floor value for right arc
rhi = (1/4)*pitch - cuttwist*(alphar-pi/2) ! ceiling value for right arc
llo = -(1/4)*pitch - cuttwist*(alphal+pi/2) ! floor value for left arc
lhi = (1/4)*pitch - cuttwist*(alphal-pi/2) ! ceiling value for left arc
{Define functions to generate the z position of turn n offset by h*zhaf : }
zr(n,h) = max(rlo, min(rhi, twist*alphar + h*zhaf)) + n*pitch
zl(n,h) = max(llo, min(lhi, twist*alphal + h*zhaf)) + n*pitch
{ Thermal source }
Q = 10*exp(-x^2-(y-x0)^2-(z-pitch/4)^2)
{ Thermal conductivity }
K = 1
initial values
Tp = 0.
equations
Tp: div(k*grad(Tp)) + Q = 0
extrusion
surface z=zr(-2,-1) { right arc bottom, turn -2 }
surface z=zr(-2,1) { right arc top, turn -2 }
surface z=zl(-3/2,-1) { left arc bottom, turn -2 }
surface z=zl(-3/2,1) {left arc top, turn -2 }
surface z=zr(-1,-1) { right arc bottom, turn -1 }
surface z=zr(-1,1) { right arc top, turn -1 }
surface z=zl(-1/2,-1) { left arc bottom, turn -1 }
surface z=zl(-1/2,1) { left arc top, turn -1 }
surface z=zr(0,-1) { right arc bottom, turn 0 }
surface z=zr(0,1) { right arc top, turn 0 }
surface z=zl(1/2,-1) { left arc bottom, turn 0 }
surface z=zl(1/2,1) { left arc top, turn 0 }
surface z=zr(1,-1) { right arc bottom, turn 1 }
surface z=zr(1,1) { right arc top, turn 1 }
477 FlexP DE 7 : Sample P roblems
variables
Tp
definitions
zlong = 60
turns = 4
pitch = zlong/turns { z rise per turn }
xwide = 4.5
zhigh = 4.5
Rc = 22 - xwide/2 { center radius }
alpha = y/Rc
zstub = 5*zhigh { rod pieces at each end }
sturn = Rc*2*pi { arc length per turn }
yolap = pi*Rc*zhigh/pitch
slong = turns*sturn { arc length of spring }
stot = slong + 2*sturn { add one turn at each end for rod }
xin = Rc-xwide/2
xout = Rc+xwide/2
xbore = Rc/2
{ transformations }
rise = pitch/(2*pi) { z-rise per radian }
c = cos(alpha)
479 FlexP DE 7 : Sample P roblems
s = sin(alpha)
xt = x*c
yt = x*s
zt = z-zlong/2
end
5.2.2.12 3d_lenses
{ 3D_LENSES.PDE
This problem considers the flow of heat in a lens-shaped body
of square outline. It demonstrates the use of FlexPDE in problems
with non-planar extrusion surfaces.
Layer 1 consists of a flat bottom with a paraboloidal top.
Layer 2 is a paraboloidal sheet of uniform thickness.
Plots on various cut planes show the ability of FlexPDE to
detect intersection surfaces.
}
title '3D Test - Lenses'
coordinates
cartesian3
Variables
u
definitions
k = 0.1
heat = 4
equations
U: div(K*grad(u)) + heat = 0
extrusion
surface z = 0
surface z = 0.8-0.3*(x^2+y^2)
surface z = 1.0-0.3*(x^2+y^2)
boundaries
{ implicit natural(u) = 0 on top and bottom faces }
Region 1
layer 2 k = 1 { layer specializations must follow regional defaults }
start(-1,-1)
value(u) = 0 { Fixed value on sides }
line to (1,-1) to (1,1) to (-1,1) to close
select painted
plots
contour(u) on x=0.51 as "YZ plane"
contour(u) on y=0.51 as "XZ plane"
contour(u) on z=0.51 as "XY plane cuts both layers and part of outline"
contour(u) on z=0.75 as "XY plane cuts both layers, but not the outline"
contour(u) on z=0.8 as "XY plane cuts only layer 2"
contour(u) on z=0.95 as "XY plane cuts small patch of layer 2"
contour(u) on z=0.95 zoom as "small cut patch, zoomed to fill frame"
contour(u) on surface 1 as "on bottom surface"
contour(u) on surface 2 as "on paraboloidal layer interface"
contour(u) on x=y as "oblique plot plane"
contour(u) on x+y=0 as "another oblique plot plane"
end
In this problem, we have a heat equation with a small cubical heated box in the middle
layer.
}
definitions
K = 0.1
h=0
Lx=3 Ly=3 Lz=3
w = 0.15 { box size }
x0=Lx/2-w y0=Ly/2-w z0=Lz/2-w { box coords }
x1=Lx/2+w y1=Ly/2+w z1=Lz/2+w
materials 'insert' : K=9 h=1
equations
U: div(K*grad(u)) + h = 0
extrusion z=0, z0, z1, Lz
boundaries
Region 1
start(0,y0)
value(u)=0
line to (Lx,y0) to (Lx,Ly) to (0,Ly) to close
limited region 2 { insert exists only on layer 2 }
layer 2 use material 'insert'
start(x0,y0)
line to (x1,y0) to (x1,y1) to (x0,y1) to close
monitors
grid(x,z) on y=Ly/2
contour(u) on z=Lz/2
plots
grid(x,z) on y=Ly/2
contour(u) on z=Lz/2 painted
contour(u) on y=Ly/2 painted
end
5.2.2.14 3d_pinchout
{ 3D_PINCHOUT.PDE
This problem demonstrates the merging
of extrusion surfaces and the
'Pinch-Out' of a layer.
}
definitions
long = 1
Sample P roblems : Usage 482
wide = 1
K = 1 { thermal conductivity default -- other values supplied later: }
Q = 10*exp(-x^2-y^2-z^2) { thermal source }
z1 = 0
z2 { surface will be defined later in each region: }
z3 = 1
initial values
Tp = 0.
equations
Tp: div(k*grad(Tp)) + Q = 0 { the heat equation }
extrusion z = z1,z2,z3 { divide Z into two layers }
boundaries
surface 1 value(Tp)=0 { fix bottom surface temp }
surface 3 value(Tp)=0 { fix top surface temp }
Region 1 { define full domain boundary in base plane }
z2 = 1 { surface 2 merges with surface 3 in this region }
start(-wide,-wide)
value(Tp) = 0 { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
Region 2 { Overlay a second region in left half.
This region delimits the area in which surfaces 2 and 3 differ.
Surfaces meet at the region boundary. }
z2 = 1 + x/2
layer 2 k=0.1 { redefine conductivity in layer 2 of region 2 }
start(-wide,-wide)
line to (0,-wide) { walk left half boundary in base plane }
to (0,wide)
to (-wide,wide)
to close
monitors
grid(x,z) on y=0
plots
grid(x,z) on y=0
contour(Tp) on y=0 as "ZX Temp"
end
5.2.2.15 3d_planespec
{ 3D_PLANESPEC.PDE
This problem demonstrates the use of the PLANE 224 generating function in
3D domain specifications.
We construct a hexahedron using two PLANE 224 statements. One from explicit
points and another from named points in the definitions section.
}
title 'PLANE surface generation'
coordinates
cartesian3
variables
Tp
select
ngrid=5 { reduce mesh size for example }
definitions
long = 1
wide = 1
K = 1
Q = 10*exp(-x^2-y^2-z^2)
483 FlexP DE 7 : Sample P roblems
Note that FEATURE 233 paths are used to delineate discontinuities in the
extrusion surfaces.
The outer edge is used as a heat source, so it is clipped to form an edge wall.
}
title '3D Test - Pyramid'
coordinates
cartesian3
select
regrid=off
ngrid=5 { reduce mesh size for example }
variables
u
definitions
k = 0.1
heat = 4
equations
U: div(K*grad(u)) + heat = 0
Sample P roblems : Usage 484
extrusion
surface z = 0
surface z = min(1.1- abs(x),1.1-abs(y))
boundaries
{ implicit natural(u) = 0 on top and bottom faces }
Region 1
start(-1,-1)
value(u) = 0 { Fixed value on short vertical sides }
line to (1,-1) to (1,1) to (-1,1) to close
{ Features delineate hidden discontinuities in surface slope.
This forces gridding nodes along break lines. }
feature start(-1,-1) line to (1,1)
feature start(-1,1) line to (1,-1)
plots
contour(u) on x=0 as "YZ plane intersects peak"
contour(u) on y=0 as "XZ plane intersects peak"
contour(u) on z=0.1 as "XY plane intersects full outline"
contour(u) on x=0.51 as "YZ plane near midpoint of side slope"
contour(u) on x+y=0.51 as "Oblique plane cuts corner"
contour(u) on z=0.8 as "XY plane near tip"
contour(u) on z=0.8 zoom as "XY plane near tip - zoomed"
end
5.2.2.17 3d_shell
{ 3D_SHELL.PDE
This problem considers heatflow in a
spherical shell.
We solve a heatflow equation with
fixed temperatures on inner and outer
shell surfaces.
}
title '3D Test - Shell'
coordinates
cartesian3
variables
u
definitions
k = 10 { conductivity }
heat =6*k { internal heat source }
rad=sqrt(x^2+y^2)
R1 = 1
thick = staged(0.1,0.03,0.01)
R2 = R1-thick
equations
U: div(K*grad(u)) + heat = 0
extrusion
surface z = -SPHERE ((0,0,0),R1) { the bottom hemisphere }
surface z = -SPHERE ((0,0,0),R2)
surface z = SPHERE ((0,0,0),R2)
surface z = SPHERE ((0,0,0),R1) { the top hemisphere }
boundaries
surface 1 value(u) = 0 { fixed values on outer sphere surfaces }
surface 4 value(u) = 0
Region 1 { The outer boundary in the base projection }
layer 1 k=0.1 mesh_spacing=10*thick { force resolution of shell curve }
layer 2 k=0.1
layer 3 k=0.1 mesh_spacing=10*thick
start(R1,0)
485 FlexP DE 7 : Sample P roblems
Limited Region 2 { The inner cylinder shell boundary in the base projection }
surface 2 value(u) = 1 { fixed values on inner sphere surfaces }
surface 3 value(u) = 1
layer 2 void { empty center }
start(R2,0)
arc(center=0,0) angle=180
nobc(u) line to close
monitors
grid(x,y,z)
grid(x,z) on y=0
grid(rad,z) on x=y
contour(u) on x=0 { YZ plane through diameter }
contour(u) on y=0 { XZ plane through diameter }
contour(u) on z=0 { XY plane through diameter }
contour(u) on x=0.5 { YZ plane off center }
contour(u) on y=0.5 { XZ plane off center }
definitions
yp = 0.5
R0 = (R1+R2)/2
Rin = sqrt((R0-0.1)^2-yp^2)
Rout = sqrt((R0+0.1)^2-yp^2)
xin = Rin/sqrt(2)
xout = Rout/sqrt(2)
plots
grid(x,y,z)
grid(x,z) on y=0
grid(x,z) on y=yp
contour(u) on x=0 as "Temp on YZ plane through diameter"
contour(u) on y=0 as "Temp on XZ plane through diameter"
contour(u) on z=0 as "Temp on XY plane through diameter"
contour(u) on z=0.001 as "Temp on XY plane through diameter"
contour(u) on x=0.5 as "Temp on YZ plane off center"
contour(u) on y=0.5 as "Temp on XZ plane off center"
report(Rin,Rout,xin,xout)
contour(magnitude(grad(u))) on y=yp
zoom(xin,xin, xout-xin,xout-xin)
as "Flux on XZ plane off center"
report(yp)
end
5.2.2.18 3d_shells
{ 3D_SHELLS.PDE
This problem demonstrates the construction
of multiple nested spherical shells.
We solve a heatflow equation with fixed
temperatures on inner and outer
shell surfaces.
}
title 'Nested 3D Shells'
coordinates
cartesian3
variables
u
definitions
k = 10
heat =6*k
rad=sqrt(x^2+y^2)
R1 = 1
thick = 0.1
R2 = R1-thick
R3 = R2-thick
Sample P roblems : Usage 486
R4 = R3-thick
R5 = R4-thick
equations
U: div(K*grad(u)) + heat = 0
extrusion
surface 'SB1' z = -SPHERE ((0,0,0),R1) { the bottom hemisphere }
layer 'LB1'
surface 'SB2' z = -SPHERE ((0,0,0),R2)
layer 'LB2'
surface 'SB3' z = -SPHERE ((0,0,0),R3)
layer 'LB3'
surface 'SB4' z = -SPHERE ((0,0,0),R4)
layer 'LB4'
surface 'SB5' z = -SPHERE ((0,0,0),R5)
layer 'LB5'
surface 'ST5' z = SPHERE ((0,0,0),R5)
layer 'LT4'
surface 'ST4' z = SPHERE ((0,0,0),R4)
layer 'LT3'
surface 'ST3' z = SPHERE ((0,0,0),R3)
layer 'LT2'
surface 'ST2' z = SPHERE ((0,0,0),R2)
layer 'LT1'
surface 'ST1' z = SPHERE ((0,0,0),R1) { the top hemisphere }
boundaries
surface 'SB1' value(u) = 0 { fixed values on outer sphere surfaces }
surface 'ST1' value(u) = 0
Region 1
layer 'LB1' k=1
layer 'LT1' k=1
start(R1,0)
value(u) = 0
arc(center=0,0) angle=180
natural(u)=0 line to close
Limited Region 2
layer 'LB2' k=2
layer 'LT2' k=2
! include the region in all layers that must merge out:
layer 'LB3' layer 'LB4' layer 'LB5' layer 'LT4' layer 'LT3'
start(R2,0)
arc(center=0,0) angle=180
nobc(u) line to close
Limited Region 3
layer 'LB3' k=3
layer 'LT3' k=3
! include the region in all layers that must merge out:
layer 'LB4' layer 'LB5' layer 'LT4'
start(R3,0)
arc(center=0,0) angle=180
nobc(u) line to close
Limited Region 4
layer 'LB4' k=4
layer 'LT4' k=4
! include the region in all layers that must merge out:
layer 'LB5'
start(R4,0)
arc(center=0,0) angle=180
nobc(u) line to close
Limited Region 5
surface 'SB5' value(u) = 1 { fixed values on inner sphere surfaces }
surface 'ST5' value(u) = 1
layer 'LB5' void { empty center }
start(R5,0)
arc(center=0,0) angle=180
nobc(u) line to close
monitors
487 FlexP DE 7 : Sample P roblems
grid(x,y,z)
grid(x,z) on y=0
grid(rad,z) on x=y
contour(u) on x=0 { YZ plane through diameter }
contour(u) on y=0 { XZ plane through diameter }
contour(u) on z=0 { XY plane through diameter }
contour(u) on x=0.5 { YZ plane off center }
contour(u) on y=0.5 { XZ plane off center }
definitions
yp = 0.5
rp = sqrt(R2^2-yp^2)
xp = rp/sqrt(2+thick)
plots
grid(x,y,z)
grid(x,z) on y=0
contour(u) on x=0 as "Temp on YZ plane through diameter"
contour(u) on y=0 as "Temp on XZ plane through diameter"
contour(u) on z=0 as "Temp on XY plane through diameter"
contour(u) on z=0.001 as "Temp on XY plane through diameter"
contour(u) on x=0.5 as "Temp on YZ plane off center"
contour(u) on y=0.5 as "Temp on XZ plane off center"
contour(magnitude(grad(u))) on y=0.5 as "Flux on XZ plane off center"
contour(magnitude(grad(u))) on y=yp
zoom(xp,xp, thick*sqrt(2+thick),thick*sqrt(2+thick))
as "Flux on XZ plane off center"
end
5.2.2.19 3d_sphere
{ 3D_SPHERE.PDE
This problem considers the construction of a spherical domain in 3D.
The heat equation is Div(-K*grad(U)) = h, wth U the temperature and
h the volume heat source.
A sphere with uniform heat source h will generate a total amount of heat
H = (4/3)*Pi*R^3*h, from which h = 3*H/(4*Pi*R^3).
The normal flux at the surface will be Fnormal = -K*grad(U) <dot> Normal,
where Normal is the surface-normal unit vector. On the sphere, the unit
normal is [x/R,y/R,z/R].
At the surface, the flux will be uniform, so the surface integral of flux is
TOTAL = 4*pi*R^2*normal(-K*grad(U)) = H
or normal(-K*grad(u)) = H/(4*pi*R^2) = R*h/3.
In the following, we set R=1 and H = 1, from which
h = 3/(4*pi)
normal(-k*grad(u)) = 1/(4*pi)
}
title '3D Sphere'
coordinates
cartesian3
variables
u
definitions
K = 0.1 { conductivity }
R0 = 1 { radius }
H0 = 1 { total heat }
{ volume heat source }
heat =3*H0/(4*pi*R0^3)
equations
U: div(K*grad(u)) + heat = 0
extrusion
surface z = -SPHERE ((0,0,0),R0) { the bottom hemisphere }
surface z = SPHERE ((0,0,0),R0) { the top hemisphere }
Sample P roblems : Usage 488
boundaries
surface 1 value(u) = 0 { fixed value on sphere surfaces }
surface 2 value(u) = 0
Region 1
start(R0,0)
arc(center=0,0) angle=360
plots
grid(x,y,z)
grid(x,z) on y=0
contour(u) on x=0
contour(4*pi*magnitude(k*grad(u))) on x=0
contour(4*pi*magnitude(k*grad(u))) on y=0
contour(-4*pi*k*(x*dx(u)+y*dy(u)+z*dz(u))/sqrt(x^2+y^2+z^2)) on x=0 as "normal flux"
5.2.2.20 3d_spherebox
{ 3D_SPHEREBOX.PDE
An empty 3D sphere inside a box.
}
title 'Empty 3D Sphere in a box'
coordinates
cartesian3
variables
u
definitions
K = 0.1 { conductivity }
R0 = 1 { radius }
box = 2*R0
zsphere = SPHERE ((0,0,0),R0) { hemisphere shape }
equations
U: div(K*grad(u)) = 0
extrusion
surface z=-box
surface z = -zsphere { the bottom hemisphere and plane }
surface z = zsphere { the top hemisphere and plane }
surface z=box
boundaries
surface 1 value(u) = 0 { fixed value on box surfaces }
surface 4 value(u) = 1
Region 1 { the bounding box - defaults to insulating sidewalls }
start(-box,-box)
line to (box,-box) to (box,box) to (-box,box) to close
489 FlexP DE 7 : Sample P roblems
plots
grid(x,y,z)
grid(x,z) on y=0
contour(u) on x=0
end
5.2.2.21 3d_spherespec
{ 3D_SPHERESPEC
This problem demonstrates the use of the SPHERE 224 function for construction
of a spherical domain in 3D. It is a modification of the example problem 3D_SPHERE.PDE
487 .
}
title '3D Sphere'
coordinates
cartesian3
variables
u
definitions
K = 0.1 { conductivity }
R0 = 1 { radius }
H0 = 1 { total heat input }
heat =3*H0/(4*pi*R0^3) { volume heat source }
zs = sphere((0,0,0),R0) { the top hemisphere }
equations
U: div(K*grad(u)) + heat = 0
extrusion
surface z = -zs { the bottom hemisphere }
surface z = zs { the top hemisphere }
boundaries
surface 1 value(u) = 0 { fixed value on sphere surfaces }
surface 2 value(u) = 0
Region 1
start (R0,0)
arc(center=0,0) angle=360
plots
grid(x,y,z)
grid(x,z) on y=0
contour(u) on x=0
contour(4*pi*magnitude(k*grad(u))) on x=0
contour(4*pi*magnitude(k*grad(u))) on y=0
contour(-4*pi*k*(x*dx(u)+y*dy(u)+z*dz(u))/sqrt(x^2+y^2+z^2)) on x=0 as "normal flux"
contour(-4*pi*k*(x*dx(u)+y*dy(u)+z*dz(u))/sqrt(x^2+y^2+z^2)) on y=0 as "normal flux"
vector(-grad(u)) on x=0
vector(-grad(u)) on y=0
contour(4*pi*normal(-k*grad(u))) on surface 1 as "4*pi*Normal Flux=1" { bottom
surface }
contour(4*pi*normal(-k*grad(u))) on surface 2 as "4*pi*Normal Flux=1" { top surface }
surface(4*pi*normal(-k*grad(u))) on surface 1 as "4*pi*Normal Flux=1" { bottom
surface }
surface(4*pi*normal(-k*grad(u))) on surface 2 as "4*pi*Normal Flux=1" { top surface }
summary
report(sintegral(normal(-k*grad(u)),1)) as "Bottom current :: 0.5 "
Sample P roblems : Usage 490
end
5.2.2.22 3d_spool
{ 3D_SPOOL.PDE
This example shows the use of LIMITED REGIONS 232 to construct a spool in a box in 3D.
The core of the spool has a section of low conductivity at the center.
The LAYER 95 structure is as follows:
Layers 1 and 7 are the sections of the box above and below the spool
Layers 2 and 6 are the flanges of the spool and the box area surrounding the
flanges.
Layers 3 and 5 are the high-conductivity portions of the core and the surrounding box
area.
Layer 4 is the low-conductivity portion of the core and the surrounding box area.
Click "Controls|Domain Review" 10 or the "Domain Review" 14 tool to watch the mesh
construction.
}
title '3D LIMITED REGION EXAMPLE'
coordinates
cartesian3
Variables
U
definitions
K
K1 = 1
K2 = 10
K3 = 0.01
Lx = 1 Ly = 1 Lz = 1
{extrusion values}
t = 0.25
m = 0.05
h = 0.25
z0 = t/2
z1 = t/2 + m
z2 = t/2 + m + h
z3 = t/2 + m + h + 2*m
z4 = t/2 + m + h + 2*m + h
z5 = t/2 + m + h + 2*m + h + m
{radii}
rad = 0.5 - h/2
rad1 = 0.5 - h/1
{boundary values}
U0 = 0
U1 = 1
equations
U: DIV(K*GRAD(U)) = 0
extrusion
surface "bottom of box" z=0
layer "bottom gap"
surface "spool bottom" z=z0
layer "bottom flange"
surface "top of bottom flange" z=z1
layer "bottom core section"
surface "bottom of core insert" z=z2
layer "core insert"
surface "top of core insert" z=z3
layer "top core section"
surface "bottom of top flange" z=z4
layer "top flange"
surface "top of spool" z=z5
layer "top gap"
surface "top of box" z=1
491 FlexP DE 7 : Sample P roblems
boundaries
Surface 1 Value(U)=U0
Surface 8 Value(U)=U1
Region 1 "Box"
K = K1
start(0,0)
line to (1,0) to (1,1) to (0,1) to close
limited region 2 "Flanges"
layer 2 K =K2
layer 6 K =K2
START (1/2,rad1)
ARC(CENTER=1/2,1/2) ANGLE=360
TO CLOSE
limited Region 3 "Core"
layer 3 K =K2
layer 4 K =K3
layer 5 K =K2
START (1/2,rad)
ARC(CENTER=1/2,1/2) ANGLE=360
TO CLOSE
MONITORS
plots
grid(x,z) on y=0.5 paintregions
contour(U) on y=0.5
contour(U) on z=0.5
contour(K) on x=0.5 painted
end
5.2.2.24 3d_toggle
{ 3D_TOGGLE.PDE
This problem shows the use of curved extrusion surfaces and VOID 233 layers
to construct a transverse cylindrical hole in an upright cylinder.
The domain consists of three layers:
1) the cylinder below the hole
2) the hole
3) the cylinder above the hole.
Layer 2 has zero thickness outside the
hole region, and is VOID 233 (excluded
from the mesh) inside the hole.
cylinder projection: }
Yc = sqrt(Ro^2-Ri^2)
Z4 = L { Z-height of the cylinder top }
{ the Z-shape function for the hole top (zero beyond +-Ri): }
Z3 = CYLINDER ((0,1,0), (0,-1,0), Ri)
{ the Z-shape function for the hole bottom (zero beyond +-Ri): }
Z2 = -Z3
Z1 = -L { Z-height of the cylinder bottom }
equations
U: div(K*grad(u)) + h = 0 { a heat equation for demonstration purposes }
extrusion z=Z1,Z2,Z3,Z4 { short-form specification of the extrusion surfaces }
boundaries
5.2.2.25 3d_torus
{ 3D_TORUS.PDE
This problem constructs a torus.
The top surface and bottom surface meet along the diameter of the torus.
}
equations
U: del2(u) + 1 = 0
extrusion
Surface "Bottom" z = -ZTorus
Surface "Top" z = ZTorus
boundaries
surface 1 value(u)=0
surface 2 value(u) = 0
region 1
start(Raxis+Rtube, 0)
value(u) = 0
arc(center=0,0) angle=360 { the outer boundary }
start(Raxis-Rtube, 0)
value(u) = 0
arc(center=0,0) angle=360 { the inner boundary }
monitors
grid(x,y,z)
contour(u) on surface z=0
contour(u) on surface y=0
plots
grid(x,y,z)
contour(u) on surface z=0
contour(u) on surface y=0
end
5.2.2.26 3d_torus_tube
{ 3D_TORUS_TUBE.PDE
This problem constructs a "U" of pipe by connecting two cylindrical stubs to the
ends of a 180-degree arc of a torus.
There are three layers:
1) the bottom half of the outer pipe
2) the inner fluid
3) the top half of the outer pipe.
Layers 1 and 3 wrap around layer 3 and meet on the center plane.
There are six regions, the inside and outside parts of the torus and the two stubs.
}
extrusion
Surface "Bottom1" z = z1
Surface "Bottom2" z = z2
Surface "Top2" z = z3
Surface "Top1" z = z4
boundaries
surface "Bottom1" value(u)=0
surface "Top1" value(u) = 0
region 1 "Outside Toroid"
mesh_spacing = Rt/2
layer 1 s = 1 k = 10
layer 3 s = 1 k = 10
start(Ra+Rt, 0)
value(u) = 0
arc(center=0,0) angle=180 { the outer boundary }
natural(u) = 0
line to (-Ra+Rt, 0)
value(u) = 0
arc(center=0,0) angle=-180 { the inner boundary }
natural(u) = 0
line to close
limited region 2 "Inside Toroid"
z2 = -ZTorus2
z3 = ZTorus2
mesh_spacing = Ri/2
layer 2 s = 100 k = 1
start(Ra+Ri, 0)
arc(center=0,0) angle=180 { the outer boundary }
line to (-Ra+Ri, 0)
arc(center=0,0) angle=-180 { the inner boundary }
line to close
region 3 "Outside TubeA"
z1 = -ZTube1a
z4 = ZTube1a
mesh_spacing = Rt/2
layer 1 s = 1 k = 10
layer 3 s = 1 k = 10
start (Ra+Rt,0)
line to (Ra+Rt,-Len)
line to (Ra-Rt,-Len)
line to (Ra-Rt,0)
line to close
limited region 4 "Inside TubeA"
z1 = -ZTube1a
z2 = -ZTube2a
z3 = ZTube2a
z4 = ZTube1a
mesh_spacing = Ri/2
layer 2 s = 100 k = 1
start (Ra+Ri,0)
line to (Ra+Ri,-Len)
line to (Ra-Ri,-Len)
line to (Ra-Ri,0)
line to close
region 5 "Outside TubeB"
z1 = -ZTube1b
Sample P roblems : Usage 496
z4 = ZTube1b
mesh_spacing = Rt/2
layer 1 s = 1 k = 10
layer 3 s = 1 k = 10
start (-Ra-Rt,0)
line to (-Ra-Rt,-Len)
line to (-Ra+Rt,-Len)
line to (-Ra+Rt,0)
line to close
limited region 6 "Inside TubeB"
z2 = -ZTube2b
z3 = ZTube2b
mesh_spacing = Ri/2
layer 2 s = 100 k = 1
start (-Ra-Ri,0)
line to (-Ra-Ri,-Len)
line to (-Ra+Ri,-Len)
line to (-Ra+Ri,0)
line to close
monitors
grid(x,y,z)
contour(u) on surface z=0
contour(u) on surface y=0
plots
grid(x,y,z)
contour(u) on surface z=0
contour(u) on surface y=0
end
5.2.2.27 3d_twist
{ 3D_TWIST.PDE
This problem shows the use of the function definition facility of FlexPDE to create a
twisted shaft in 3D.
The mesh generation facility of FlexPDE extrudes a 2D figure along a straight path in
Z,
so that it is not possible to directly define a screw-thread shape.
However, by defining a coordinate transformation, we can build a straight rod in 3D and
interpret the coordinates in a rotating frame.
Define the twisting coordinates by the transformation
xt = x*cos(a) - y*sin(a); x = xt*cos(a) + yt*sin(a)
yt = x*sin(a) + y*cos(a); y = yt*cos(a) - xt*sin(a)
zt = z
with
a = 2*pi*z/Length = twist*z (for a total twist of 2*pi radians over the length )
In this transformation, x and y are the coordinates FlexPDE believes it is working
with,
and they are the coordinates that move with the twisting, so that the cross section is
constant in x,y. xt and yt are the "lab coordinates" of the twisted figure.
The chain rule then gives
dF/d(xt) = (dx/dxt)*(dF/dx) + (dy/dxt)*(dF/dy) + (dz/dxt)*(dF/dz)
(with similar rules for yt and zt).
and dx/dzt = twist*[-xt*sin(a) + yt*cos(a)] = y*twist, etc.
In FlexPDE notation, this becomes
dxt(F) = cos(a)*dx(F) - sin(a)*dy(F)
dyt(F) = sin(a)*dx(F) + cos(a)*dy(F)
dzt(F) = twist*[y*dx(F) - x*dy(F)] + dz(F)
These relations are defined in the definitions section, and used in the equations
section, perhaps nested as in the heat equation shown here.
}
497 FlexP DE 7 : Sample P roblems
The VOID 233 statement appears inside a REGION 229 section, in the position of a
layer parameter definition.
Sample P roblems : Usage 498
boundaries
region 1
start(-1,-1)
value(u)=0 { Force U=0 on perimeter }
line to (1,-1)
arc(center=-1,0) to (1,1)
line to (-1,1)
arc(center= -3,0) to close
limited region 2 { void exists only on layer 2 }
layer 2 VOID
start(x0,y0)
layer 2 value(u)=1
line to (x1,y0) to (x1,y1) to (x0,y1) to close
monitors
elevation(u) from (-0.8,0,0.5) to (1.25,0,0.5)
elevation(u) from (-0.8,0,0.8) to (1.25,0,0.8)
contour(u) on z=0
contour(u) on z=0.5
contour(u) on z=1
contour(u) on y=0
plots
elevation(u) from (-0.8,0,0.5) to (1.25,0,0.5)
elevation(u) from (-0.8,0,0.8) to (1.25,0,0.8)
contour(u) on z=0 painted
contour(u) on z=0.5 painted
contour(u) on z=0.499 painted
contour(u) on z=1 painted
contour(u) on y=0 painted
end
499 FlexP DE 7 : Sample P roblems
5.2.2.29 regional_surfaces
{ REGIONAL_SURFACES.PDE
This problem demonstrates the use of regional definition of 3D extrusion surfaces.
There are three "REGIONS" 229 defined, the cubical body of the domain, and two circular
patches. The circular patches each exist only on a single surface, and in no volumes.
The patch regions are used to define alternate extrusion surface shapes, and
insert two parabolic depressions in the top and bottom faces of the cube.
coordinates
cartesian3
variables
Tp
definitions
long = 1 { domain size }
wide = 1
z1 = -1 { bottom surface default shape }
z2 = 1 { top surface default shape }
xc = wide/3 {some locating coordinates }
yc = wide/3
rc = wide/2
h = 0.8
K = 1 { heat equation parameters }
Q = exp(-(x^2+y^2+z^2))
initial values
Tp = 0.
equations
Tp: div(k*grad(Tp)) + Q = 0
extrusion z = z1,z2
boundaries
surface 1 value(Tp)=0
surface 2 value(Tp)=0
{ define full domain boundary in base plane }
Region 1
start(-wide,-wide)
value(Tp) = 0
line to (wide,-wide)
to (wide,wide)
to (-wide,wide)
to close
Limited region 2
{ redefine bottom surface shape in region 2 }
{ note that this shape must meet the default shape at the edge of the region }
z1 = -1+h*(1-((x+xc)^2+(y+yc)^2)/rc^2) { a parabolic dent }
surface 1 { region exists only on surface 1 }
start(-xc,-yc-rc) arc(center=-xc,-yc) angle=360
Limited region 3
{ redefine top surface shape in region 3 }
{ note that this shape must meet the default shape at the edge of the region }
z2 = 1-h*(1-((x-xc)^2+(y-yc)^2)/rc^2)
surface 2 { region exists only on surface 2 }
start(xc,yc-rc) arc(center=xc,yc) angle=360
plots
grid(x,y,z)
contour(Tp) on x=y
Sample P roblems : Usage 500
end
5.2.2.30 tabular_surfaces
{ TABULAR_SURFACES.PDE
This problem demonstrates the use of tabular input and regional definition
for 3D extrusion surfaces.
The bottom surface of a brick is read from a table.
Note: Tables by default use bilinear interpolation. Mesh cell boundaries do NOT
automatically follow table boundaries, and sharp slope breaks in table data
can result in ragged surfaces. You should always make surface tables dense
enough to avoid sharp breaks, or put domain boundaries or features along
breaks in the table slope. You should also specify mesh density controls
sufficiently dense to resolve table features.
The top surface is defined by different functions in two regions.
Note: the regional surface definitions must coincide at the region boundaries
where they meet. Surfaces must be continuous and contain no jumps.
}
title 'tabular surface definition'
coordinates
cartesian3
variables
Tp
definitions
long = 1
wide = 1
K = 1
Q = 10*exp(-x^2-y^2-z^2)
{ read the table file for surface 1 definition: }
z1 = table('surf.tbl')
{ use regional parameters for surface 2
definition: }
z2
initial values
Tp = 0.
equations
Tp: div(k*grad(Tp)) + Q = 0
plots
grid(x,z) on y=0
contour(Tp) on y=0 as "ZX Temp"
contour(Tp) on x=0 as "YZ Temp"
end
5.2.2.31 two_spheres
{ TWO_SPHERES.PDE
This problem constructs two spheres inside a box. The centers of the spheres lie
on a single z-plane, which simplifies the domain construction.
The domain consists of three layers.
layer 1 is the space below the spheres
layer 2 contains the sphere bodies, and is of zero thickness outside the spheres
layer 3 is the space above the spheres
The sphere interiors are Void, and are thus excluded from analysis. They could just as
well be filled with material if one wanted to model the insides.
The bounding surfaces of layer 2 are specified as a default, over-ridden by regional
expressions within the (X,Y) extent of each sphere.
See TWOZ_PLANAR.PDE 506 , TWOZ_DIRECT.PDE 502 , TWOZ_EXPORT.PDE 505 and TWOZ_IMPORT.PDE 503
for methods of treating spheres with centers on differing Z coordinates.
}
title 'Two Spheres in 3D'
coordinates
cartesian3
variables
u
definitions
K = 1 { dielectric constant of box filler (vacuum?) }
box = 1 { bounding box size }
5.2.2.32 twoz_direct
{ TWOZ_DIRECT.PDE
This problem constructs two non-coplanar spheres inside a box by constructing
a single dividing surface to delimit both spheres.
The domain consists of three layers.
layer 1 is the space below the spheres
layer 2 contains the sphere bodies, and is of zero thickness outside the spheres
layer 3 is the space above the spheres
The sphere interiors are Void, and are thus excluded from analysis. You could
just as well fill them with material if you wanted to model the insides.
The bounding surfaces of layer 2 are specified as a slope perpendicular to the
centerline of the spheres and over-ridden by regional expressions within
the (X,Y) extent of each sphere.
See TWOZ_PLANAR.PDE 506 , TWOZ_EXPORT.PDE 505 and TWOZ_IMPORT.PDE 503 for other methods of
treating spheres with centers on differing Z coordinates.
}
title 'Two Spheres in 3D - direct surface matching'
coordinates
cartesian3
Variables
u
definitions
K = 1 { dielectric constant of box filler (vacuum?) }
box = 1 { bounding box size }
{ read sphere specs from file, to guarantee that they are the same as those in
surfgen }
#include "sphere_spec.inc"
{ sphere shape functions }
sphere1_shape = SPHERE ((x1,y1,0),R1)
sphere2_shape = SPHERE ((x2,y2,0),R2)
{ construct an extrusion surface running through both sphere diameters
503 FlexP DE 7 : Sample P roblems
equations
U: div(K*grad(u)) = 0
extrusion
surface "box_bottom" z=-box
surface "sphere_bottoms" z = zbottom
surface "sphere_tops" z = ztop
surface "box_top" z=box
boundaries
surface "box_bottom" natural(u) = 0 {insulating boundaries top and bottom }
surface "box_top" natural(u) = 0
Region 1 { The bounding box }
start(-box,-box) line to (box,-box) to (box,box) to (-box,box) to close
limited region 2 { sphere 1 }
mesh_spacing = R1/5 { force a dense mesh on the sphere }
zbottom = Z1-sphere1_shape { shape of surface 2 in sphere 1}
ztop = Z1+sphere1_shape { shape of surface 3 in sphere 1}
layer 2 void
surface 2 value(u)=V1 { specify sphere1 voltage on top and bottom }
surface 3 value(u)=V1
start (x1+R1,y1)
arc(center=x1,y1) angle=360
limited region 3 { sphere 2 }
mesh_spacing = R2/5 { force a dense mesh on the sphere }
zbottom = Z2-sphere2_shape { shape of surface 2 in sphere 2}
ztop = Z2+sphere2_shape { shape of surface 3 in sphere 2}
layer 2 void
surface 2 value(u)=V2 { specify sphere2 voltage on top and bottom }
surface 3 value(u)=V2
start (x2+R2,y2)
arc(center=x2,y2) angle=360
plots
grid(x,y,z)
grid(x,z) on y=y1 paintregions as "Y-cut through lower sphere"
contour(u) on y=y1 as "Solution on Y-cut through lower sphere"
grid(x,z) on y=y2 paintregions as "Y-cut through upper sphere"
contour(u) on y=y2 as "Solution on Y-cut through upper sphere"
grid(x*sqrt(2),z) on x-y=0 paintregions as "Diagonal cut through both spheres"
contour(u) on x-y=0 as "Solution on Diagonal cut through both spheres"
end
well fill them with material if you wanted to model the insides.
The bounding surfaces of layer 2 are specified as a default surface read from a
TRANSFER 213 , over-ridden by regional expressions within the (X,Y) extent of each
sphere.
See TWOZ_DIRECT.PDE 502 and TWOZ_PLANAR.PDE 506 for other methods of treating spheres
with centers on differing Z coordinates.
}
title 'Two Spheres in 3D'
coordinates
cartesian3
variables
u
definitions
{ dielectric constant of box filler (vacuum?) }
K = 1
box = 1 { bounding box size }
{ read sphere specs from file, to guarantee
that they are the same as those in surfgen }
#include "sphere_spec.inc"
{ sphere shape functions }
sphere1_shape = SPHERE ((x1,y1,0),R1)
sphere2_shape = SPHERE ((x2,y2,0),R2)
{ read dividing surface generated by surfgen
script }
TRANSFER("twoz_export_output/
two_sphere.xfr",zbottom)
ztop = zbottom
equations
U: div(K*grad(u)) = 0
extrusion
surface "box_bottom" z=-box
surface "sphere_bottoms" z = zbottom
surface "sphere_tops" z = ztop
surface "box_top" z=box
boundaries
{insulating boundaries top and bottom }
surface "box_bottom" natural(u) = 0
surface "box_top" natural(u) = 0
grid(x,y,z)
grid(x,z) on y=y1 paintregions as "Y-cut through lower sphere"
contour(u) on y=y1 as "Solution on Y-cut through lower sphere"
grid(x,z) on y=y2 paintregions as "Y-cut through upper sphere"
contour(u) on y=y2 as "Solution on Y-cut through upper sphere"
grid(x*sqrt(2),z) on x-y=0 paintregions as "Diagonal cut through both spheres"
contour(u) on x-y=0 as "Solution on Diagonal cut through both spheres"
end
boundaries
Region 1 { The bounding box }
start(-box,-box)
line to (box,-box) to (box,box) to (-box,box) to close
Region 2 { sphere 1 }
ztable = Z1 { force a clean table value inside sphere }
start (x1+1.01*R1,y1)
mesh_spacing = R1/5 { force a dense mesh on the sphere }
load(U) = 0 load(V) = big*(U-Z1)
arc(center=x1,y1) angle=360
Region 3 { sphere 2 }
ztable = Z2
start (x2+1.01*R2,y2)
mesh_spacing = R2/5 { force a dense mesh on the sphere }
load(U) = 0 load(V)= big*(U-Z2)
arc(center=x2,y2) angle=360
plots
elevation(U) from(-box,-box) to (box,box)
elevation(ztable) from(-box,-box) to (box,box)
contour(U)
surface(U)
contour(ztable) zoom(x1-1.3*R1, y1-1.3*R1, 2.6*R1,2.6*R1)
contour(ztable) zoom(x2-1.3*R2, y2-1.3*R2, 2.6*R2,2.6*R2)
transfer(ztable) file = "two_sphere.xfr"
end
Sample P roblems : Usage 506
5.2.2.35 twoz_planar
{ TWOZ_PLANAR.PDE
This problem constructs two spheres inside a box by constructing multiple planar
extrusion layers.
It presents an alternate method for comparison to that of TWOZ_EXPORT.PDE 505 and
TWOZ_IMPORT.PDE 503 .
The domain consists of five layers.
layer 1 is the space below the lower sphere
layer 2 contains the lower sphere body, and is of zero thickness outside the sphere
layer 3 is the space between the spheres
layer 4 contains the upper sphere body, and is of zero thickness outside the sphere
layer 5 is the space above the upper sphere
The sphere interiors are Void, and are thus excluded from analysis. You could just as
well fill them with material if you wanted to model the insides.
The bounding surfaces of layers 2 and 4 are specified as planes at the level of the
sphere
center, over-ridden by regional expressions within the (X,Y) extent of each sphere.
equations
U: div(K*grad(u)) = 0
extrusion
surface "box_bottom" z = -box
surface "sphere1_bottom" z = zbottom1
surface "sphere1_top" z = ztop1
surface "sphere2_bottom" z = zbottom2
surface "sphere2_top" z = ztop2
surface "box_top" z = box
boundaries
surface "box_bottom" natural(u) = 0 {insulating boundaries top and bottom }
surface "box_top" natural(u) = 0
Region 1 { The bounding box }
start(-box,-box) line to (box,-box) to (box,box) to (-box,box) to close
limited region 2 { sphere 1 }
mesh_spacing = R1/5 { force a dense mesh on the sphere }
zbottom1 = Z1-sphere1_shape { shape of surface 2 in sphere 1}
ztop1 = Z1+sphere1_shape { shape of surface 3 in sphere 1}
layer 2 void
surface 2 value(u)=V1 { specify sphere1 voltage on top and bottom }
surface 3 value(u)=V1
start (x1+R1,y1)
507 FlexP DE 7 : Sample P roblems
arc(center=x1,y1) angle=360
limited region 3 { sphere 2 }
mesh_spacing = R2/5 { force a dense mesh on the sphere }
zbottom2 = Z2-sphere2_shape { shape of surface 2 in sphere 2}
ztop2 = Z2+sphere2_shape { shape of surface 3 in sphere 2}
layer 4 void
surface 4 value(u)=V2 { specify sphere2 voltage on top and bottom }
surface 5 value(u)=V2
start (x2+R2,y2)
arc(center=x2,y2) angle=360
plots
grid(x,y,z)
grid(x,z) on y=y1 paintregions as "Y-cut through lower sphere"
contour(u) on y=y1 as "Solution on Y-cut through lower sphere"
grid(x,z) on y=y2 paintregions as "Y-cut through upper sphere"
contour(u) on y=y2 as "Solution on Y-cut through upper sphere"
grid(x*sqrt(2),z) on x-y=0 paintregions as "Diagonal cut through both spheres"
contour(u) on x-y=0 as "Solution on Diagonal cut through both spheres"
end
5.2.3 Accuracy
5.2.3.1 forev er
{ FOREVER.PDE
This problem displays the behaviour of FlexPDE in time dependent problems.
We posit a field with paraboloidal shape and with amplitude sinusoidal
in time. We then derive the source function necessary to achieve this
solution, and follow the integration for ten cycles, comparing the solution
to the known analytic solution.
}
title 'A forever test'
variables
Temp (threshold=0.1)
definitions
K = 1
eps = 0
shape = (1-x^2-y^2)
Texact = shape*sin(t)
source = shape*cos(t) - div(K*grad(shape))*sin(t)
initial values
Temp = Texact
equations
Temp : div(K*grad(Temp)) + source = dt(Temp)
boundaries
Region 1
start(-1,-1)
value(Temp)=Texact
line to (1,-1) to (1,1) to (-1,1) to close
time 0 to 20*pi by 0.01
monitors
for cycle=5
contour(Temp) { show the Temperature during solution }
plots { write these plots to the .PGX file }
for t = pi/2 by pi to endtime
contour(Temp)
surface(Temp)
contour(Temp-Texact) as "Error"
vector(-dx(Temp),-dy(Temp)) as "Heat Flow"
histories
Sample P roblems : Usage 508
5.2.3.2 gaus1d
{ GAUS1D.PDE
This test solves a 1D heat equation with a Gaussian solution and compares
actual deviations from the exact solution with the error estimates made by
FlexPDE.
The problem runs a set of ERRLIM 187 levels and plots the history of the comparison.
}
title '1D Accuracy Test - Gaussian'
select
ngrid=10
errlim = staged(1e-2, 1e-3, 1e-4, 1e-5, 1e-6)
coordinates
cartesian1
Variables
u
definitions
k = 1
w=0.25
u0 = exp(-x^2/w^2)
s = -dxx(u0)
RMS_error = sqrt(integral((u-u0)^2)/sqrt(integral(u0^2)))
left=point(-1)
right=point(1)
equations
U: div(K*grad(u)) +s = 0
boundaries
Region 1
start left point value(u)=u0
line to right point value(u)=u0
monitors
elevation(u) from left to right
plots
elevation(u,u0) from left to right report(errlim)
elevation(u-u0) from left to right as "absolute error" report(errlim)
elevation(-div(grad(u)),s) from left to right report(errlim)
histories
history(RMS_error, errlim) log
end
5.2.3.3 gaus2d
{ GAUS2D.PDE
This test solves a 2D heat equation with a Gaussian solution and compares
actual deviations from the exact solution with the error estimates made by
FlexPDE.
The problem runs a set of ERRLIM 187 levels and plots the history of the comparison.
}
title '2D Accuracy Test - Gaussian'
509 FlexP DE 7 : Sample P roblems
variables
u
select
ngrid=5
errlim = staged(1e-2, 1e-3, 1e-4, 1e-5)
definitions
k = 1
h = 0.1
w = 0.2 ! gaussian width
u0 = exp(-(x^2+y^2)/w^2)
source = -(dxx(u0)+dyy(u0))
uxx_exact = dxx(u0)
RMS_error = sqrt(integral((u-u0)^2)/sqrt(integral(u0^2)))
fx = -2*x*u0/w^2
fy = -2*y*u0/w^2
equations
U: div(K*grad(u)) + source = 0
boundaries
Region 1
start(-1,-1) natural(u)=-fy line to (1,-1)
value(u)=u0 line to (1,1)
natural(u)=fy line to (-1,1)
value(u) = u0 line to close
monitors
grid(x,y)
contour(u)
plots
grid(x,y)
contour(u)
elevation(u,u0) from(-1,0) to (1,0)
elevation(u-u0) from(-1,0) to (1,0)
elevation(dxx(u),uxx_exact) from(-1,0) to (1,0)
elevation(dxx(u)+dyy(u),-source) from(-1,0) to (1,0)
contour(dxx(u)) contour(dxy(u)) contour(dyy(u))
contour(space_error(u))
contour(u-u0)
histories
history(RMS_error, errlim) LOG
end
5.2.3.4 gaus3d
{ GAUS3D.PDE
This test solves a 3D heat equation with a known Gaussian solution and compares
actual deviations from the exact solution with the error estimates made by
FlexPDE.
The problem runs a set of ERRLIM 187 levels and plots the history of the comparison.
The equation is solved in two forms, letting FlexPDE compute the correct source,
and imposing analytic derivatives for the source.
}
title '3D Accuracy Test - Gaussian'
coordinates
cartesian3
select
ngrid = 5
errlim = staged(1e-2, 1e-3, 1e-4, 1e-5)
variables
u
definitions
long = 1
wide = 1
Sample P roblems : Usage 510
z1 = -1
z2 = 1
w = 0.25 ! gaussian width
uexact = exp(-(x^2+y^2+z^2)/w^2)
source = -(dxx(uexact)+dyy(uexact)+dzz(uexact)) ! let FlexPDE do the differentials
flux = -grad(u)
RMS_error = sqrt(integral((u-uexact)^2)/sqrt(integral(uexact^2)))
initial values
u = 0.
equations
U: div(flux) = source
extrusion z = z1,z2
boundaries
surface 1 value(u)=uexact { fix bottom surface temp }
surface 2 value(u)=uexact { fix top surface temp }
Region 1 { define full domain boundary in base plane }
start(-wide,-wide)
value(u) = uexact { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
monitors
grid(x,z) on y=0
contour(uexact) on y=0
contour(u) on y=0
contour(u-uexact) on y=0
plots
grid(x,z) on y=0 as "Grid on X-Z cut"
contour(uexact) on y=0 as "Exact Solution Uexact"
contour(u) on y=0 as "Numerical Solution U"
contour(u-uexact) on y=0 as "Actual error U-Uexact"
elevation(u,uexact) from(-wide,0,0) to (wide,0,0)
elevation(dx(u),dx(uexact)) from(-wide,0,0) to (wide,0,0)
elevation(div(flux),source) from(-wide,0,0) to (wide,0,0)
summary
report(errlim)
report(RMS_error)
histories
history(RMS_error, errlim) log
end
5.2.3.5 sine1d
{ SINE1D.PDE
This problem compares the solution accuracy for four different levels of ERRLIM 187 .
}
title '1D Accuracy test - Sine'
select
ngrid=10
errlim = staged(1e-2, 1e-3, 1e-4, 1e-5)
coordinates
cartesian1
variables
u
definitions
511 FlexP DE 7 : Sample P roblems
k = 1
h = 0.1
w=0.1
rs = abs(x)/w
u0 = sin(rs)/max(rs,1e-18)
s = -dxx(u0)
RMS_error = sqrt(integral((u-u0)^2)/sqrt(integral(u0^2)))
equations
U: div(K*grad(u)) +s = 0
boundaries
Region 1
start(-1) point value(u)=u0
line to (1) point value(u)=u0
monitors
elevation(u) from (-1) to (1)
plots
elevation(u,u0) from (-1) to (1)
elevation(u-u0) from (-1) to (1)
elevation(dx(u),dx(u0)) from (-1) to (1)
elevation(-div(grad(u)),s) from (-1) to (1)
histories
history(RMS_error,errlim) LOG
end
5.2.3.6 sine2d
{ SINE2D.PDE
This problem compares the solution accuracy for four different levels of ERRLIM 187 .
}
title '2D Accuracy Test - Sine'
select
ngrid = 5
errlim = staged(1e-2, 1e-3, 1e-4, 1e-5)
variables
u
definitions
k = 1
h = 0.1
w=0.1
rs = r/w
u0 = sin(rs)/rs
s = -dxx(u0)-dyy(u0)
RMS_error = sqrt(integral((u-u0)^2)/sqrt(integral(u0^2)))
equations
U: div(K*grad(u)) +s = 0
boundaries
Region 1
start(-1,-1) value(u)=u0
line to (1,-1) to (1,1) to (-1,1) to close
monitors
grid(x,y)
contour(u)
plots
grid(x,y)
contour(u)
elevation(u,u0) from(-1,0) to (1,0)
Sample P roblems : Usage 512
5.2.3.7 sine3d
{ SINE3D.PDE
This problem compares the solution accuracy for three different levels of ERRLIM 187 .
}
extrusion z = z1,z2
boundaries
surface 1 value(u)=uex { fix bottom surface temp }
surface 2 value(u)=uex { fix top surface temp }
Region 1 { define full domain boundary in base plane }
start(-wide,-wide)
value(u) = uex { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
monitors
grid(x,z) on y=0 as "Grid on X-Z cut"
contour(uex) on y=0 as "Exact Solution Uex"
contour(u) on y=0 as "Numerical Solution U"
contour(u-uex) on y=0 as "Actual error U-Uex"
plots
grid(x,z) on y=0 as "Grid on X-Z cut"
contour(uex) on y=0 as "Exact Solution Uex"
contour(u) on y=0 as "Numerical Solution U"
contour(u-uex) on y=0 as "Actual error U-Uex"
summary
report(errlim) as "Requested error"
report(RMS_error)
histories
513 FlexP DE 7 : Sample P roblems
end
5.2.4 Arrays+Matrices
5.2.4.1 array s
{ ARRAYS.PDE
Variables
u
definitions
a = 1
! literal data specification
v = array(0,1,2,3,4,5,6,7,8,9,10)
! literal data specification with incrementation
w = array(0 by 0.1 to 10)
! functional definition
alpha =array for x(0 by 0.1 to 10) : sin(x)+1.1
! construction of a new array by arithmetic operations
beta = sin(w)+1.1 { this results in the same data as alpha }
gamma = sin(v)+0.1 { this array is sparsely defined }
rad = 0.1
s = 0
equations
u: div(a*grad(u)) + s = 0 { a heat equation }
boundaries
region 1
start(0,0)
value(u)=0
line to (2,0) to (2,2) to (0,2) to close
plots
elevation(alpha)
elevation(alpha,beta) vs w
elevation(gamma) vs v
summary
report(sizeof(w))
end
This problem demonstrates the use of data ARRAYS 201 in boundary definition.
Coordinate arrays are constructed by functional array definition
and joined in a spline fit to form the system boundary.
}
title 'ARRAY_BOUNDARY test'
variables
u
definitions
a = 1
rad = 1
! construct x and y coordinates on a semicircle
xb =array for ang(-pi/2 by pi/10 to pi/2) : rad*cos(ang)
Sample P roblems : Usage 514
5.2.4.3 m atrices
{ MATRICES.PDE
{ no equations }
boundaries
region 1
start(0,0)
line to (2,0) to (2,2) to (0,2) to close
{ no monitors }
plots
elevation(q) vs v as "array vs array"
elevation(q) as "array vs index"
contour(m3) vs v vs v as "matrix vs two arrays"
contour(m3) vs v as "matrix vs array and index"
This example demonstrates the use of a data MATRIX 203 in boundary definition.
Coordinates are constructed by functional matrix definition,
rotated by multiplication by a rotation matrix
and joined in a spline fit to form the system boundary.
}
title 'MATRIX_BOUNDARY test'
Variables
u
definitions
a = 1
rad = 1
! build a 2 x 21 matrix of x and y coordinates
mb =matrix for i(1,2)
for ang(-pi/2 by pi/20 to pi/2)
: if(i=1) then rad*cos(ang) else rad*sin(ang)
! build a 2 x 2 rotation matrix
rota=45
rot = matrix[2,2] ((cos(rota degrees), -sin(rota degrees)),
(sin(rota degrees), cos(rota degrees)))
! rotate the coordinate list
mbr = rot**mb
s = 1
equations
u: div(a*grad(u)) + s = 0; { the heatflow equation }
boundaries
region 1
! start curve at first point of rotated coordinates
start(mbr[1,1], mbr[2,1])
value(u)=0
! spline fit the 21-point table
spline list (mbr)
natural(u)=0
Sample P roblems : Usage 516
line to close
plots
contour(u) painted
surface(u)
end
{ WAVE_BOUNDARY.PDE
definitions
base=2
ysine = array for p(0 by 0.1 to 10): sin(2*p)+base
xsine = array for p(0 by 0.1 to 10): p
boundaries
Region 1
start(0,0)
line to (0,base)
spline list(xsine,ysine)
line to (10,0) to close
plots
grid(x,y)
end
5.2.5 CAD_Import
5.2.5.1 arrow_OBJim port
{ ARROW_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS section to tie the name stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
plots grid(x,y,z)
end
517 FlexP DE 7 : Sample P roblems
{ BOXINBOX_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
variables u
select regrid=off
materials
'boxinbox' : k=1
boundary conditions
'inner' : value(u)=1
'outer': value(u)=10
equations u: div(k*grad(u))=0
plots
grid(x,y,z)
grid(y,z) on x=0
contour(u) on x=0
end
{ CANINCAN_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
variables u
select regrid=off
Sample P roblems : Usage 518
materials
'canincan' : k=1
boundary conditions
'inside' : value(u)=1
'outside': value(u)=10
equations u: div(k*grad(u))=0
plots
grid(x,y,z)
grid(x,z) on y=0
contour(u) on y=0
end
{ CUBE_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
variables u
boundary conditions
'left' : value(u)=1
'right' : value(u)=10
equations u: div(k*grad(u))=0
plots
grid(x,y,z)
grid(x,y) on z = 0.5
contour(u) on z = 0.5
elevation(u) from (0,0.5,0.5) to (1,0.5,0.5)
end
{ CUBE2_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
519 FlexP DE 7 : Sample P roblems
coordinates cartesian3
variables u
materials
'cube1' : k = 1
'cube2' : k = 5
boundary conditions
'left' : value(u) = 1
'middle' : natural(u) = 0
'right' : value(u) = 10
equations u: div(k*grad(u))=0
plots
grid(x,y,z)
grid(x,y) on z = 0.5
contour(u) on z = 0.5
elevation(u) from (0,0.5,0.5) to (2,0.5,0.5)
end
{ CUBE2_VALIDATE.PDE
coordinates cartesian3
variables u
select ngrid = 2
materials
'cube1' : k = 1
'cube2' : k = 5
boundary conditions
'left' : value(u) = 1
'right': value(u) = 10
equations u: div(k*grad(u))=0
extrusion z = 0,1
boundaries
region 1
use material 'cube1'
start(0,0)
line to (1,0) to (1,1) to (0,1) use bc 'left'
Sample P roblems : Usage 520
line to close
region 2
use material 'cube2'
start(2,1)
line to (1,1) to (1,0) to (2,0) use bc 'right'
line to close
plots
grid(x,y,z)
grid(x,y) on z = 0.5
contour(u) on z = 0.5
elevation(u) from (0,0.5,0.5) to (2,0.5,0.5)
end
{ CUBES_BIGSMAll_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
variables u
select
regrid=off
refineobj=off ! do not refine the initial OBJ mesh
materials
'small': k=1
'big' : k=2
boundary conditions
'bottom' : value(u)=1
'middle': contact(u)=jump(u)/0.5
'top' : value(u)=10
equations u: div(k*grad(u))=0
plots
grid(x,y,z)
grid(y,z) on x=4
grid(x,z) on y=3
contour(u) on x=4
contour(u) on y=3
end
{ CUBES_BIGSMALL_VALIDATE.PDE
521 FlexP DE 7 : Sample P roblems
Note : the figure was turned on end only to make the construction easier.
}
title 'Validate Import OBJ Cubes Bigsmall'
coordinates cartesian3
variables u
materials
'small': k=1
'big' : k=2
boundary conditions
'left' : value(u)=1
'middle': contact(u)=jump(u)/0.5
'right' : value(u)=10
equations u: div(k*grad(u))=0
extrusion z=0,5,7
boundaries
limited region 1
surface 1 use bc 'left'
layer 1 use material 'big'
start(0,0)
line to (5,0) to (5,5) to (0,5) to close
limited region 2
surface 2 use bc 'middle'
surface 3 use bc 'right'
layer 2 use material 'small'
start(3,2)
line to (5,2) to (5,4) to (3,4) to close
plots
grid(x,y,z)
grid(y,z) on x=4
grid(x,z) on y=3
contour(u) on x=4
contour(u) on y=3
end
{ GOURD_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
coordinates cartesian3
plots grid(x,y,z)
Sample P roblems : Usage 522
end
{ HELIX_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
select order=2
variables U V W
definitions
E { Young's Modulus }
nu = 0.3 { Poisson's Ratio }
{ Strains }
ex = dx(U)
ey = dy(V)
ez = dz(W)
gxy = dy(U) + dx(V)
gyz = dz(V) + dy(W)
gzx = dx(W) + dz(U)
{ Stresses }
Sx = C11*ex + C12*ey + C13*ez
Sy = C12*ex + C22*ey + C23*ez
Sz = C13*ex + C23*ey + C33*ez
Txy = C44*gxy
Tyz = C44*gyz
Tzx = C44*gzx
equations
U: dx(Sx) + dy(Txy) + dz(Tzx) = 0 { the U-displacement equation }
V: dx(Txy) + dy(Sy) + dz(Tyz) = 0 { the V-displacement equation }
W: dx(Tzx) + dy(Tyz) + dz(Sz) = 0 { the W-displacement equation }
boundary conditions
'top' : natural(w) = -1e-3
'bottom' : natural(w) = 1e-3
plots
contour(Up) on y=0 as "X-displacement"
contour(Vp) on x=0 as "Y-displacement"
contour(Wp) on y=0 as "Z-displacement"
grid(x+Mt*Up,y+Mt*Vp,z+Mt*Wp) as "Shape"
grid(x+My*Up,z+My*Wp) on y=0 as "XZ Shape"
grid(y+Mx*Vp,z+Mx*Wp) on x=0 as "YZ Shape"
contour(Sx) on y=0 as "X-stress"
contour(Sy) on y=0 as "Y-stress"
contour(Sz) on y=0 as "Z-stress"
contour(Txy) on y=0 as "XY Shear stress"
contour(Tyz) on y=0 as "YZ Shear stress"
contour(Tzx) on y=0 as "ZX Shear stress"
end
{ HORN_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
variables u
materials 'horn' : k = 10
boundary conditions
'tip1' : value(u) = 1
'tip2' : value(u) = 10
'tip3' : value(u) = 100
'base' : natural(u) = -10
equations u: div(k*grad(u))=0
plots
grid(x,y,z)
Sample P roblems : Usage 524
grid(x,z) on y=0
contour(u) on y=0
end
{ TORUS_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
select regrid=off
variables u
boundary conditions
'patch1' : value(u) = 1
'patch2' : value(u) = 10
equations u: div(k*grad(u))=0
plots
grid(x,y,z)
grid(x,z) on y = 0
contour(u) on x = -y
contour(u) on z = 0
end
{ TUBEFACES_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
This mesh has some square cells on the sides that FlexPDE will
automatically split into triangular cells during the mesh import.
}
title 'Import OBJ Tubefaces'
coordinates cartesian3
525 FlexP DE 7 : Sample P roblems
variables u
boundary conditions
'bottom' : value(u) = 1
'top' : value(u) = 10
equations u: div(k*grad(u))=0
plots
grid(x,y,z)
grid(x,z) on y=0
contour(u) on y=0
end
{ WINEGLASS_OBJIMPORT.PDE
This sample demonstrates the import of a bounding mesh in OBJ file format.
It uses the MATERIALS and BOUNDARY CONDITIONS sections to tie names stated
in the OBJ file to FlexPDE properties.
coordinates cartesian3
variables u
select
order=2 ! select quadratic variable interpolation.
refineobj=off
boundary conditions
'inside' : value(u) = 1
'bottom' : value(u) = 10
initial values
u = 1
equations u: div(k*grad(u))=0
monitors
grid(x,y,z)
grid(x,z) on y=0
contour(u) on y=0
plots
grid(x,y,z)
grid(x,z) on y=0
contour(u) on y=0
end
Sample P roblems : Usage 526
5.2.6 Constraints
5.2.6.1 3d_constraint
{ 3D_CONSTRAINT.PDE
to (0,wide)
to (-wide,wide)
to close
monitors
contour(Tp) on surface z=0 as "XY Temp"
contour(Tp) on surface x=0 as "YZ Temp"
contour(Tp) on surface y=0 as "ZX Temp"
elevation(Tp) from (-wide,0,0) to (wide,0,0) as "X-Axis Temp"
elevation(Tp) from (0,-wide,0) to (0,wide,0) as "Y-Axis Temp"
elevation(Tp) from (0,0,-long) to (0,0,long) as "Z-Axis Temp"
plots
contour(Tp) on z=0 as "XY Temp"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "ZX Temp"
summary
report("Compare integral forms in region 2 of layer 2 (should be 1.00):")
report(integral(Tp,2,2))
report(integral(Tp,"Left","Top"))
report(integral(check22))
report("-----")
report "Constraint acts as an energy sink:"
report(integral(Q)) as "Source Integral "
report(sintegral(normal(-k*grad(Tp)))) as "Surface integral on total outer surface
"
report(integral(Q)-sintegral(normal(-k*grad(Tp)))) as "Energy lost to constraint "
end
5.2.6.2 3d_surf_constraint
{ 3D_SURF_CONSTRAINT.PDE
This problem demonstrates the use of CONSTRAINTS 223 on surface integrals in 3D.
This is a modification of problem 3D_BRICKS.PDE 414 .
We apply the constraint that the total flux leaving the figure must be 1.0.
The constraint acts as an auxilliary energy sink, so we report the amount
of energy lost to the constraint.
See the problems in the APPLICATIONS | CONTROL folder for methods
that control the input power to achieve the same kind of goal.
}
title '3D Surface Constraint'
select
regrid=off { use fixed grid to speed up demonstration }
coordinates
cartesian3
variables
Tp
definitions
long = 1
wide = 1
K { thermal conductivity -- values supplied later }
Q = 10*exp(-x^2-y^2-z^2) { Thermal source }
initial values
Tp = 0.
equations
Tp: div(k*grad(Tp)) + Q = 0 { the heat equation }
constraints
sintegral(normal(k*grad(Tp))) = 1 { force total surface integral to 1 }
extrusion
surface "bottom" z = -long
layer 'bottom'
Sample P roblems : Usage 528
boundaries
surface 1 value(Tp)=0 { fix bottom surface temp }
surface 3 value(Tp)=0 { fix top surface temp }
Region 1 { define full domain boundary in base plane }
layer 1 k=1 { bottom right brick }
layer 2 k=0.1 { top right brick }
start(-wide,-wide)
value(Tp) = 0 { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
Region 2 "Left" { overlay a second region in left half }
layer 1 k=0.2 { bottom left brick }
layer 2 k=0.4 { top left brick }
start(-wide,-wide)
line to (0,-wide) { walk left half boundary in base plane }
to (0,wide)
to (-wide,wide)
to close
monitors
contour(Tp) on surface z=0 as "XY Temp"
contour(Tp) on surface x=0 as "YZ Temp"
contour(Tp) on surface y=0 as "ZX Temp"
elevation(Tp) from (-wide,0,0) to (wide,0,0) as "X-Axis Temp"
elevation(Tp) from (0,-wide,0) to (0,wide,0) as "Y-Axis Temp"
elevation(Tp) from (0,0,-long) to (0,0,long) as "Z-Axis Temp"
plots
contour(Tp) on surface z=0 as "XY Temp"
contour(Tp) on surface x=0 as "YZ Temp"
contour(Tp) on surface y=0 as "ZX Temp"
summary
report("Constraint Validation:")
report(sintegral(normal(k*grad(Tp)))) as "Constrained surface integral on total
outer surface"
report(integral(Q)) as "Total interior source"
report(integral(Q) - sintegral(normal(k*grad(Tp)))) as "Energy lost to constraint"
end
5.2.6.4 constraint
{ CONSTRAINT.PDE
This problem shows the use of CONSTRAINTS 223 to resolve an ill-posed problem.
There are no value boundary conditions in any of the three equations, so
there are infinitely many solutions that satisfy the PDE's. The constraints
select from the family of solutions those which have a mean value of 1.
}
title 'Constraint Test'
variables
u1 u2 u3
equations
u1: div(grad(u1)) +x = 0
u2: div(grad(u2)) +x+y = 0
u3: div(grad(u3)) +y = 0
constraints
integral(u1) = integral(1)
integral(u2) = integral(1)
integral(u3) = integral(1)
boundaries
Region 1
start(-1,-1) line to (1,-1) to (1,1) to (-1,1) to close
monitors
contour(u1)
contour(u2)
contour(u3)
plots
contour(u1) report(integral(u1)/integral(1)) as "Average"
contour(u2) report(integral(u2)/integral(1)) as "Average"
contour(u3) report(integral(u3)/integral(1)) as "Average"
surface(u1) report(integral(u1)/integral(1)) as "Average"
surface(u2) report(integral(u2)/integral(1)) as "Average"
surface(u3) report(integral(u3)/integral(1)) as "Average"
end
5.2.7 Contact_Boundaries
5.2.7.1 3d_contact
{ 3D_CONTACT.PDE
This problem shows the use of a contact resistance boundary between layers in 3D.
The resistance model is applied to the entire boundary surface.
region.
(This is a modification of problem 3D_BRICKS.PDE 414 ).
}
title 'steady-state 3D heat conduction with Contact Resistance'
select
regrid=off { use fixed grid }
coordinates
cartesian3
variables
Tp
definitions
long = 1
wide = 1
K { thermal conductivity -- values supplied later }
Q = 10*exp(-x^2-y^2-z^2) { Thermal source }
e = 0.01 {'epsilon' offset to avoid plotting on discontinuities }
initial values
Tp = 0.
equations
Tp : div(k*grad(Tp)) + Q = 0 { the heat equation }
extrusion z = -long,0,long { divide Z into two layers }
boundaries
surface 1 value(Tp)=0 { fix bottom surface temp }
surface 2 contact(tp)=jump(tp)/10 { THE CONTACT RESISTANCE }
surface 3 value(Tp)=0 { fix top surface temp }
Region 1 { define full domain boundary in base plane }
layer 1 k=1 { bottom right brick }
layer 2 k=0.1 { top right brick }
start(-wide,-wide)
value(Tp) = 0 { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
Region 2 { overlay a second region in left half }
layer 1 k=0.2 { bottom left brick }
layer 2 k=0.4 { top left brick }
start(-wide,-wide)
line to (0,-wide) { walk left half boundary in base plane }
to (0,wide)
to (-wide,wide)
to close
monitors
contour(Tp) on z=e as "XY Temp - Upper"
contour(Tp) on z=-e as "XY Temp - Lower"
contour(Tp) on x=e as "YZ Temp"
contour(Tp) on y=e as "ZX Temp"
elevation(Tp) from (-wide,e,e) to (wide,e,e) as "X-Axis Temp"
elevation(Tp) from (e,-wide,e) to (e,wide,e) as "Y-Axis Temp"
elevation(Tp) from (e,e,-long) to (e,e,long) as "Z-Axis Temp"
plots
contour(Tp) on z=e as "XY Temp - Upper"
contour(Tp) on z=-e as "XY Temp - Lower"
contour(Tp) on x=e as "YZ Temp"
contour(Tp) on y=e as "ZX Temp"
surface(Tp) on y=e as "ZX Temp"
elevation(Tp) from (-wide,e,e) to (wide,e,e) as "X-Axis Temp"
elevation(Tp) from (e,-wide,e) to (e,wide,e) as "Y-Axis Temp"
elevation(Tp) from (e,e,-long) to (e,e,long) as "Z-Axis Temp"
end
531 FlexP DE 7 : Sample P roblems
5.2.7.2 3d_contact_region
{ 3D_CONTACT_REGION.PDE
This problem shows the use of a contact resistance boundary between layers.
The resistance model is applied only to one region of the boundary surface.
(This is a modification of problem 3D_CONTACT.PDE 529 ).
}
title 'steady-state 3D heat conduction with Contact Resistance'
select
regrid=off { use fixed grid }
coordinates
cartesian3
variables
Tp
definitions
long = 1
wide = 1
K { thermal conductivity -- values supplied later }
Q = 10*exp(-x^2-y^2-z^2) { Thermal source }
initial values
Tp = 0.
equations
Tp : div(k*grad(Tp)) + Q = 0 { the heat equation }
extrusion z = -long,0,long { divide Z into two layers }
boundaries
surface 1 value(Tp)=0 { fix bottom surface temp }
surface 3 value(Tp)=0 { fix top surface temp }
Region 1 { define full domain boundary in base plane }
layer 1 k=1 { bottom right brick }
layer 2 k=0.1 { top right brick }
start(-wide,-wide)
value(Tp) = 0 { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
Region 2 { overlay a second region in left half }
{ CONTACT RESISTANCE IN REGION 2 ONLY: }
surface 2 contact(tp)=jump(tp)/10
layer 1 k=0.2 { bottom left brick }
layer 2 k=0.4 { top left brick }
start(-wide,-wide)
line to (0,-wide) { walk left half boundary in base plane }
to (0,wide)
to (-wide,wide)
to close
monitors
contour(Tp) on z=0.01 as "XY Temp - Upper"
contour(Tp) on z=-0.01 as "XY Temp - Lower"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "ZX Temp"
elevation(Tp) from (-wide/2,0,-long) to (wide/2,0,long) as "Left Side Temp"
plots
contour(Tp) on z=0.01 as "XY Temp - Upper"
contour(Tp) on z=-0.01 as "XY Temp - Lower"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "ZX Temp"
elevation(Tp) from (-wide/2,0,-long) to (-wide/2,0,long) as "Left Side Temp"
surface(Tp) on y=0 as "ZX Temp" Viewpoint(-3.5,8.2,31)
end
Sample P roblems : Usage 532
5.2.7.3 contact_resistance_heating
{ CONTACT_RESISTANCE_HEATING.PDE
Contact resistance is modeled using the keywords JUMP 239 and CONTACT 299 .
JUMP 239 represents the "jump" in the value of a variable across an interface
(outer value minus inner value, as seen from each cell),
and is meaningful only in boundary condition statements.
CONTACT 299 is a special form of NATURAL 236 , which requests that the boundary
should support a discontinuous value of the variable.
The model is one of "contact resistance", where the outward current across an
interface is given by
R*I = -Jump(V) [=(Vinner-Vouter)],
and R is the contact resistance.
}
title "contact resistance heating"
variables
V
Temp
definitions
Kt { thermal conductivity }
Heat = 0
Rc = 2 { Electrical contact resistance }
rho = 1 { bulk resistivity }
sigma = 1/rho { bulk conductivity,
I=sigma*grad(V) }
temp0=0
size = 3
V1 = 1
totR = size*rho+Rc
cur = V1/totR
jdrop = cur*Rc
initial values
Temp = temp0
equations
V: div(sigma*grad(V)) = 0
Temp: div(Kt*grad(Temp)) + Heat =0
boundaries
Region "R1"
Kt=5
start 'box' (0,0)
natural(V)=0 natural(temp)=0 line to (size,0)
value(V)=V1 value(temp)=0 line to (size,size)
natural(V)=0 natural(temp)=0 line to (0,size)
value(V)=0 value(temp)=0 line to close
Region "R2"
Kt=1
start (0,0)
line to (size/2,0)
contact(V) = (1/rc)*JUMP(V) { resistance jump }
natural(temp) = JUMP(V)^2/Rc { heat generation }
line to(size/2,size)
533 FlexP DE 7 : Sample P roblems
natural(V)=0
natural(Temp)=0
line to (0,size) to close
monitors
contour(Temp)
plots
grid(x,y)
contour(V) painted
contour(Temp) painted
surface(Temp)
contour(kt*dx(temp)) painted
contour(kt*dx(temp)) painted
elevation(V) from(0,1.5) to (3,1.5)
elevation(temp) from(0,1.5) to (3,1.5)
elevation(dx(v)) from(0,1.5) to (3,1.5)
elevation(kt*dx(temp)) from(0,1.5) to (3,1.5)
summary
report(sintegral(V,'interface','R1')/size) ! find average interface voltage in
region 1
report(sintegral(V,'interface','R2')/size) ! find average interface voltage in
region 2
report(sintegral(jump(V)^2/rc,'interface')) as "contact source"
report(sintegral(normal(kt*grad(temp)),'box')) as "outer loss"
report(size*(jdrop)^2/Rc) as "true heat"
end
Contact resistance is modeled using the keywords JUMP 239 and CONTACT 299 .
JUMP 239 represents the "jump" in the value of a variable across an interface
(outer value minus inner value, as seen from each cell),
and is meaningful only in boundary condition statements.
CONTACT 299 is a special form of NATURAL 236 , which requests that the boundary
should support a discontinuous value of the variable.
The model is one of "contact resistance", where the flux across an interface
is given by flux(Temp) = -Jump(Temp)/R,
and R is the contact resistance.
Since CONTACT, like NATURAL, represents the outward normal component
of the argument of the divergence operator, the contact resistance condition is
represented as
CONTACT(Temp) = -JUMP(Temp)/R
Sample P roblems : Usage 534
}
title "Thermal Contact Resistance"
variables
Temp
definitions
{ thermal conductivity - values given in regions:
}
K
Heat { Heat source }
Flux = -K*grad(Temp)
Rc = 1/2 { contact resistance }
initial values
Temp = 0
equations
Temp: div(Flux) = Heat
boundaries
Region 1 { the outer boundary }
K=5
Heat=0
start "Outer" (0,0)
value(Temp)=0 { cold boundary }
line to (3,0) to (3,3) to (0,3) to close
Region 2 { an imbedded diamond }
K=1
Heat=1 { heat source in the inner diamond }
start "Inner" (1.5,0.5)
contact(Temp) = -JUMP(Temp)/Rc { the contact flux }
line to (2.5,1.5) to (1.5,2.5) to (0.5,1.5) to close
monitors
contour(Temp)
plots
grid(x,y)
contour(Temp) as "Temperature"
contour(magnitude(grad(temp))) points=5 as "Flux"
contour(Temp) zoom(2,1,1,1) as "Temperature Zoom"
elevation(Temp) from (0,0) to (3,3)
surface(Temp)
surface(Temp) zoom(2,1,1,1)
vector(-dx(Temp),-dy(Temp)) as "Heat Flow"
elevation(normal(flux)) on "Outer"
elevation(normal(flux)) on "Inner"
end
5.2.7.5 transient_contact_resistance_heating
{ TRANSIENT_CONTACT_RESISTANCE_HEATING.PDE
}
title "transient contact resistance heating"
variables
V
Temp(0.001)
definitions
Kt { thermal conductivity }
Heat =0
Rc = 2 { Electrical contact resistance }
rho = 1 { bulk resistivity }
sigma = 1/rho { bulk conductivity,
I=sigma*grad(V) }
Initial values
V = x/3 { a reasonable guess }
Temp = 0
equations
V: div(sigma*grad(V)) = 0
Temp: div(Kt*grad(Temp)) + Heat = dt(Temp)
boundaries
Region 1
Kt=15
start (0,0)
natural(V)=0 natural(temp)=0 line to (3,0)
value(V)=1 value(temp)=0 line to (3,3)
natural(V)=0 natural(temp)=0 line to (0,3)
value(V)=0 value(temp)=0 line to close
Region 2
Kt=5
start (0,0) line to (1.5,0)
contact(V) = (1/rc)*JUMP(V) { resistance jump }
natural(temp) = JUMP(V)^2/Rc { heat generation }
line to(1.5,3)
natural(V)=0 natural(Temp)=0
line to (0,3) to close
time 0 to 5 by 1e-6
monitors
for cycle=5
contour(Temp)
plots
for cycle=20
grid(x,y)
contour(V) painted
contour(Temp) painted
surface(Temp)
contour(kt*dx(temp)) painted
contour(kt*dx(temp)) painted
elevation(V) from(0,1.5) to (3,1.5)
elevation(temp) from(0,1.5) to (3,1.5)
elevation(dx(v)) from(0,1.5) to (3,1.5)
elevation(kt*dx(temp)) from(0,1.5) to (3,1.5)
histories
history(Temp) at (0.5,1.5) (1.0,1.5) (1.5,1.5) (2.0,1.5) (2.5,1.5)
end
5.2.8 Coordinate_Scaling
5.2.8.1 scaled_z
{ SCALED_Z.PDE
This example applies a 10:1 expansion to the z coordinate in a single imbedded layer.
Compare solution to UNSCALED_Z.PDE 537 , which does not scale the z-coordinate.
Sample P roblems : Usage 536
See "Help->Technical Notes->Coordinate Scaling 354 " for a discussion of the techniques
used in this example.
}
title 'Scaled Z-coordinate'
coordinates
cartesian3
variables
Tp
Zs
definitions
long = 1/2 { thickness of the upper and lower layers }
wide = 1
w=0.01 { half-thickness of the imbedded slab }
zscale=1 { The global Z-Scaling factor, defaulted to 1 for top and bottom
layers }
zscale2=20 { The desired Z-Scaling factor for the center layer }
ws = w*zscale2 { the scaled half-thickness of the slab }
SUMMARY
{ form some integrals for comparison with Unscaled_Z: }
{ the Z flux derivative must be multiplied by the scale factor, but the area of
integration
is in true coordinates }
{ flux leaving the slab, evaluated in the slab: }
report(sintegral(-k*zscale2*dz(Tp),'slab_top','slab'))
{ flux leaving the slab, evaluated in the upper layer: }
report(sintegral(-k*1*dz(Tp),'slab_top','over'))
report("--")
{ The transverse fluxes are in the correct units, but the area integration must
be
corrected by dividing by the scale factor (notice that "zscale" will evaluate
to
"zscale2" in the slab)}
report(sintegral(-normal(k*grad(Tp))/zscale,'sidewall','slab'))
end
5.2.8.2 unscaled_z
{ UNSCALED_Z.PDE
boundaries
surface 'bottom' load(Tp)=0.1*(T0-Tp)
surface 'top' load(Tp)=0.1*(T0-Tp)
Region 1
layer 2
Q = 100*exp(-x^2-y^2) { a heat source in the slab layer only }
k = 1 { redefine conductivity in layer 2 }
start 'sidewall' (-wide,-wide)
load(Tp) = 0
layer 2 load(Tp) = 0.1*(T0-Tp)
line to (wide,-wide)
to (wide,wide)
to (-wide,wide)
to close
monitors
contour(Tp) on z=0 as "XY Temp"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "ZX Temp"
plots
contour(Tp) on z=0 as "XY Temp"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "ZX Temp"
elevation(Tp) from (-wide,0,0) to (wide,0,0) as "X-Axis Temp"
elevation(Tp) from (0,-wide,0) to (0,wide,0) as "Y-Axis Temp"
elevation(Tp) from (0,0,-long-w) to (0,0,long+w) as "Z-Axis Temp"
vector(-k*dx(Tp),-k*dz(Tp)) on y=0 as "Flux on Y=0"
vector(-k*dx(Tp),-k*dy(Tp)) on z=0 as "Flux on Z=0"
elevation(k*dx(Tp)) from (-wide,0,0) to (wide,0,0) as "Center X-Flux"
elevation(k*dz(Tp)) from (0,0,-(long+w)) to (0,0,(long+w)) as "Center Z-Flux"
SUMMARY
{ form some integrals for comparison with Scaled_Z: }
report(sintegral(-k*dz(Tp),'slab_top','slab'))
report(sintegral(-k*dz(Tp),'slab_top','over'))
report("--")
report(sintegral(-normal(k*grad(Tp)),'sidewall','slab'))
end
5.2.9 Eigenvalues
5.2.9.1 3d_oildrum
{ 3D_OILDRUM.PDE
*******************************************************************
This example illustrates the use of FlexPDE in Eigenvalue problems, or
Modal Analysis.
*******************************************************************
In this problem, we determine the four lowest-energy vibrational modes of
a circular cylinder, or "oil drum", clamped on the periphery.
What we see as results are the pressure distributions of the air inside the
drum.
The three-dimensional initial-boundary value problem associated with the
scalar wave equation for sound speed "c" can be written as
c^2*del2(u) - dtt(u) = 0,
with accompanying initial values and boundary conditions:
u = f(s,t) on some part S1 of the boundary
dn(u) + a*u = g(s,t) on the remainder S2 of the boundary.
If we assume that solutions have the form
u(x,y,z,t) = exp(i*w*t)*v(x,y,z)
(where "w" is a frequency) then the equation becomes
del2(v) + lambda*v = 0
with lambda = (w/c)^2, and with boundary conditions
v = 0 on S1
dn(v) + a*v = 0 on S2.
The values of lambda for which this system has a non-trivial solution
are known as the eigenvalues of the system, and the corresponding solutions
539 FlexP DE 7 : Sample P roblems
Variables
u
equations { the eigenvalue equation }
U: div(grad(u)) + lambda*u = 0
{ define the bounding z-surfaces }
extrusion z = -1,1
boundaries
{ clamp the bottom and top faces }
surface 1 value(u) = 0
surface 2 value(u) = 0
{ define circular sidewall }
Region 1
start(0,-1)
value(u) = 0 { clamp the sides }
arc(center=0,0) angle 360
monitors { repeated for all modes }
contour(u) on x=0
contour(u) on y=0
contour(u) on z=1/2
plots { repeated for all modes }
contour(u) on x=0 surface(u) on x=0
contour(u) on y=0 surface(u) on y=0
contour(u) on z=1/2 surface(u) on z=1/2
end
5.2.9.2 3d_plate
{ 3D_PLATE.PDE
This problem considers the oscillation modes of a glass plate in space
( no mountings to constrain motion ).
-- Submitted by John Trenholme, Lawrence Livermore Nat'l Lab.
}
Sample P roblems : Usage 540
SELECT
modes = 5
ngrid=10
errlim = 0.01 { 1 percent is good enough }
VARIABLES
U { X displacement }
V { Y displacement }
W { Z displacement }
DEFINITIONS
cm = 0.01 { converts centimeters to meters
}
long = 20*cm { length of plate along Y axis }
wide = 10*cm { width of plate along X axis }
thick = 1.2*cm { thickness of plate along Z
axis }
E = 50e9 { Youngs modulus in Pascals }
nu = 0.256 { Poisson's ratio }
rho = 2500 { density in kg/m^3 = 1000*[g/
cc] }
{ constitutive relations - isotropic material }
G = E/((1+nu)*(1-2*nu))
C11 = G*(1-nu) C12 = G*nu C13 = G*nu
C22 = G*(1-nu) C23 = G*nu C33 = G*(1-nu)
C44 = G*(1-2*nu)/2
{ Strains }
ex = dx(U) ey = dy(V) ez = dz(W)
gxy = dy(U) + dx(V) gyz = dz(V) + dy(W) gzx = dx(W) + dz(U)
{ Stresses }
Sx = C11*ex + C12*ey + C13*ez
Sy = C12*ex + C22*ey + C23*ez
Sz = C13*ex + C23*ey + C33*ez
Txy = C44*gxy Tyz = C44*gyz Tzx = C44*gzx
{ find mean Y and Z translation and X rotation }
Vol = Integral(1)
With default errlim, FlexPDE in the current test gives results within 0.01%.
}
title "Vibrational modes of a drumhead"
select
{ Define the number of vibrational modes desired.
The appearance of this selector tells FlexPDE
to perform an eigenvalue calculation }
modes=8
Sample P roblems : Usage 542
Variables
u
equations { the eigenvalue equation }
U: div(grad(u)) + lambda*u = 0
boundaries
Region 1
start(0,-1)
value(u) = 0
arc(center=0,0) angle 360
monitors { repeated for all modes }
contour(u)
variables
u
equations { the eigenvalue equation }
U: div(grad(u)) + lambda*u = 0
boundaries
Region 1
start(0,-1)
value(u) = 0
arc(center=0,0) angle 360
start(0,-0.4)
natural(u)=0
arc(center=0,-0.2) angle=360
monitors { repeated for all modes }
contour(u)
plots { repeated for all modes }
contour(u)
surface(u)
end
5.2.9.5 filledguide
{ FILLEDGUIDE.PDE
select
modes = 5 { This is the number of Eigenvalues desired. }
ngrid = 30
overshoot = 1e-9 { request very tight Conjugate Gradient convergence }
variables
Hx(0.01) ! some eigenfunctions are zero, so apply a threshold
Hy(0.01) ! ... to avoid infinite regrid
definitions
cm = 0.01 ! conversion from cm to meters
b = 1*cm ! box height
L = 2*b ! box width
epsr ! values will be given by region
epsr1=1
epsr2=1.5
eps0 = 8.85e-12
mu0 = 4e-7*pi
c = 1/sqrt(mu0*eps0) ! light speed
k0b = 4 ! normalized driving frequency
k0 = k0b/b
k02 = k0^2 ! k0^2=omega^2*mu0*eps0
equations
! Hx equation multiplied by epsr to enforce continuity of Hz
Hx: dx(divh) - dy(curlh) + k02*Hx*epsr - (lambda+shift)*Hx = 0
Hy: dx(curlh/epsr) + dy(divh)/epsr + k02*Hy - (lambda+shift)*Hy/epsr = 0
boundaries
region 1 epsr=epsr1
start(0,0)
natural(Hx) = 0 value(Hy)=0
line to (L,0)
value(Hx) = 0 value(Hy)=0 natural(Hy)=0
line to (L,b)
natural(Hx) = 0 value(Hy)=0
line to (0,b)
value(Hx) = 0 natural(Hy)=0
line to close
region 2 epsr=epsr2
start(b,b)
line to (0,b) to (0,0) to (b,0)
line to close
monitors
contour(Hx) range=(-1,1)
contour(Hy) range=(-1,1)
plots
Sample P roblems : Usage 544
summary export
report lambda
report shift
report true_lambda
report(k0)
report( if(true_lambda<0) then "*" else " ") ! mark negative eigenvalues
report(kz)
report(kz/k0)
end
5.2.9.6 shiftguide
{ SHIFTGUIDE.PDE
This problem demonstrates the technique of eigenvalue shifting to select
an eigenvalue band for analysis. Compare these results to the problem
Waveguide20, and you will see that the negative modes here correspond to
the modes below the shift value, while the positive modes here correspond
to the modes above the shift value. The result modes in the shifted calculation
comprise a complete range of the unshifted modes. (The correspondence is
1:9, 2:8, 3:10, 4:11, 5:12, 6:13, 7:7, 8:6).
The solution algorithm used in FlexPDE finds the eigenvalues of lowest
magnitude, so you will always see a band of positive and negative values
centered on the shift value.
}
select
modes = 8
ngrid=20
variables
hz
definitions
L = 2
h = 0.5 ! half box height
g = 0.01 ! half-guage of wall
s = 0.3*L ! septum depth
tang = 0.1 ! half-width of tang
Hx = -dx(Hz)
Hy = -dy(Hz)
Ex = Hy
Ey = -Hx
line to close
monitors
contour(Hz)
plots
contour(Hz) painted report (lambda+shift) as "Shifted Lambda"
summary
report lambda
report (lambda+shift) as "Shifted Lambda"
end
5.2.9.7 v ibar
{ VIBAR.PDE
This problem analyzes the standing-wave vibrational modes of an elastic bar.
end
definitions
L = 2
h = 0.5 ! half box height
g = 0.01 ! half-guage of wall
s = 0.3*L ! septum depth
tang = 0.1 ! half-width of tang
Hx = -dx(Hz)
Hy = -dy(Hz)
Ex = Hy
Ey = -Hx
equations
Hz: del2(Hz) + lambda*Hz = 0
constraints
integral(Hz) = 0 { since Hz has only natural boundary conditions,
we need to constrain the answer }
boundaries
region 1
start(0,0)
natural(Hz) = 0 line to (L,0) to (L,1) to (0,1) to (0,h+g)
natural(Hz) = 0
line to (s-g,h+g) to (s-g,h+g+tang) to (s+g,h+g+tang)
to (s+g,h-g-tang) to (s-g,h-g-tang) to (s-g,h-g) to (0,h-g)
line to close
monitors
contour(Hz)
plots
549 FlexP DE 7 : Sample P roblems
contour(Hz) painted
end
5.2.10 Functions
5.2.10.1 com plex _functions
{ COMPLEX_FUNCTIONS.PDE }
COORDINATES cartesian2
SELECT ngrid=40
DEFINITIONS
! sample complex
a=9
b=4
! explicit root computation
z = complex(a,b)
r = sqrt(a^2+b^2)
d = z+r
dabs = sqrt((a+r)^2+b^2)
zscale = sqrt(r)/dabs
zroot = zscale*complex(a+r,b)
! reference value
c = 9+sqrt(97)
xd = sqrt(2*c)
zr = c/xd
zi = 4/xd
! expanded code
zrootf = sqrt(CABS(z))*CEXP(0,0.5*atan2(b,a))
BOUNDARIES
REGION 1
START(-1,-1)
LINE TO (1,-1) TO (1,1) TO (-1,1) TO CLOSE
PLOTS
contour(atan2(y,x))
contour(CARG(x,y))
contour(CABS(x,y))
contour(CEXP(x,y))
contour(CLOG(x,y))
contour(CSQRT(x,y))
contour(CARG(complex(x,y)))
contour(CABS(complex(x,y)))
contour(CEXP(complex(x,y)))
contour(CLOG(complex(x,y)))
contour(CSQRT(complex(x,y)))
SUMMARY
report("Z=A+i*B")
report(a) as "A"
report(b) as "B"
report(zr) as "test real"
report(REAL(zroot))
report(REAL(CSQRT(z))) ! test new function
report(REAL(zrootf))
report(REAL(CSQRT(z)*CSQRT(z)))
report("")
report(zi) as "test imag"
Sample P roblems : Usage 550
report(IMAG(zroot))
report(IMAG(CSQRT(z))) ! test new function
report(IMAG(zrootf))
report(IMAG(CSQRT(z)*CSQRT(z)))
report("")
report(r) as "test cabs(z)"
report(CABS(z)) ! test new function
report("")
report(sqrt(zr^2+zi^2)) as "test cabs(zroot)"
report(CABS(zroot)) ! test new function
report(CABS(zrootf)) ! test new function
report("")
report(REAL(CLOG(z))) report(IMAG(CLOG(z)))
report(REAL(CEXP(CLOG(z)))) report(IMAG(CEXP(CLOG(z))))
END
5.2.10.2 function_definition
{ FUNCTION_DEFINITION.PDE
5.2.10.3 error_reporting
{ ERROR_reporting.PDE
This sample shows the use of the TIME_ERROR 161 and SPACE_ERROR 161 functions.
It is a copy of the sample CHEMBURN.PDE 361 .
}
551 FlexP DE 7 : Sample P roblems
title
'Open Tube Chemical Reactor with Strip Heater'
select
painted { make color-filled contour plots }
variables
Temp(threshold=0.1)
C(threshold=0.1)
definitions
Lz = 1
r1=1
heat=0
gamma = 16
beta = 0.2
betap = 0.3
BI = 1
T0 = 1
TW = 0.92
RC = (1-C)*exp(gamma-gamma/Temp) { the very nasty reaction rate }
xev=0.96 { some plot points }
yev=0.25
initial values
Temp=T0
C=0
equations
Temp: div(grad(Temp)) + heat + betap*RC = dt(Temp)
C: div(grad(C)) + beta*RC = dt(C)
boundaries
region 1
start (0,0)
time 0 to 1
plots
for cycle=10 { watch the fast events by cycle }
grid(x,y)
contour(Temp) fixed range (0.9,2.5)
contour(C) as "Completion" fixed range(0,1.1)
contour(space_error())
contour(space_error(Temp))
for t= 0.1 by 0.05 to 0.2 by 0.01 to 0.3 0.5 endtime { show some surfaces during burn
}
contour(Temp) fixed range (0.9,2.5)
Sample P roblems : Usage 552
histories
history(Temp) at (0,0) (xev/2,yev/2) (xev,yev) (yev/2,xev/2) (yev,xev)
history(C) at (0,0) (xev/2,yev/2) (xev,yev) (yev/2,xev/2) (yev,xev) as "Completion"
history(time_error(Temp),time_error(C),time_error())
history(time_error(Temp),time_error(C))
end
5.2.10.4 globalm ax
{ GLOBALMAX.PDE
This sample demonstrates the use of the GLOBALMAX 161 function and its variants in 2D.
It is a copy of the example THERMAL_CONTACT_RESISTANCE.PDE 533 .
}
variables
Temp
definitions
K { thermal conductivity - values given in regions }
Heat { Heat source }
Flux = -K*grad(Temp)
Rc = 1/2 { contact resistance }
initial values
Temp = 0
equations
Temp: div(Flux) = Heat
boundaries
Region 1 "Outer" { the outer boundary }
K=5
Heat=0
start "Outer" (0,0)
value(Temp)=0 { cold boundary }
line to (3,0) to (3,3) to (0,3) to close
monitors
contour(Temp)
plots
grid(x,y)
contour(Temp) as "Temperature"
contour(magnitude(grad(temp))) points=5 as "Flux"
contour(Temp) zoom(2,1,1,1) as "Temperature Zoom"
elevation(Temp) from (0,0) to (3,3)
surface(Temp)
surface(Temp) zoom(2,1,1,1)
vector(-dx(Temp),-dy(Temp)) as "Heat Flow"
elevation(normal(flux)) on "Outer"
elevation(normal(flux)) on "Inner"
553 FlexP DE 7 : Sample P roblems
summary
report(globalmax(Temp),globalmax_x(Temp),globalmax_y(Temp)) as "Global Maximum"
report(" ")
report(globalmax(Temp,"Inner"),globalmax_x(Temp,"Inner"),globalmax_y(Temp,"Inner")) as
"Inner Maximum"
report(globalmax(Temp,"Outer"),globalmax_x(Temp,"Outer"),globalmax_y(Temp,"Outer")) as
"Outer Maximum"
report(" ")
report(globalmax(Temp,1),globalmax_x(Temp,1),globalmax_y(Temp,1)) as "Region 1 Maximum"
report(globalmax(Temp,2),globalmax_x(Temp,2),globalmax_y(Temp,2)) as "Region 2 Maximum"
end
{ GLOBALMAX_3D.PDE
This sample demonstrates the use of the GLOBALMAX 161 function and its variants in 3D.
It is a copy of the example 3D_BRICKS+TIME.PDE 415 .
}
select
regrid=off { use fixed grid }
coordinates
cartesian3
variables
Tp
definitions
long = 1
wide = 1
K { thermal conductivity -- values supplied later }
Q = 10*exp(-x^2-y^2-z^2) { thermal source }
initial values
Tp = 0.
equations
Tp : div(k*grad(Tp)) + Q = 0 { the heat equation }
boundaries
Surface 1 value(Tp)=0 { fix bottom surface temp }
Surface 3 value(Tp)=0 { fix top surface temp }
monitors
contour(Tp) on z=0 as "XY Temp"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "XZ Temp"
elevation(Tp) from (-wide,0,0) to (wide,0,0) as "X-Axis Temp"
elevation(Tp) from (0,-wide,0) to (0,wide,0) as "Y-Axis Temp"
elevation(Tp) from (0,0,-long) to (0,0,long) as "Z-Axis Temp"
plots
contour(Tp) on z=0 as "XY Temp"
contour(Tp) on x=0 as "YZ Temp"
contour(Tp) on y=0 as "XZ Temp"
contour(Tp) on x=globalmax_x(Tp) as "YZ Temp at max" report(globalmax_x(Tp)) as
"X_max"
elevation(Tp) from (-wide,0,0) to (wide,0,0) as "X-Axis Temp"
elevation(Tp) from (0,-wide,0) to (0,wide,0) as "Y-Axis Temp"
elevation(Tp) from (0,0,-long) to (0,0,long) as "Z-Axis Temp"
summary
report(globalmax(Tp), globalmax_x(Tp), globalmax_y(Tp), globalmax_z(Tp)) as "Global
Maximum"
report(" ")
report(globalmax(Tp, "left"), globalmax_x(Tp, "left"), globalmax_y(Tp, "left"),
globalmax_z(Tp, "left")) as "Left Maximum"
report(globalmax(Tp, "right"), globalmax_x(Tp, "right"), globalmax_y(Tp, "right"),
globalmax_z(Tp, "right")) as "Right Maximum"
report(globalmax(Tp, "lower"), globalmax_x(Tp, "lower"), globalmax_y(Tp, "lower"),
globalmax_z(Tp, "lower")) as "Lower Maximum"
report(globalmax(Tp, "upper"), globalmax_x(Tp, "upper"), globalmax_y(Tp, "upper"),
globalmax_z(Tp, "upper")) as "Upper Maximum"
report(globalmax(Tp, "right", "upper"), globalmax_x(Tp, "right", "upper"),
globalmax_y(Tp, "right", "upper"), globalmax_z(Tp, "right", "upper")) as "Right Upper
Maximum"
report(" ")
report(globalmax(Tp, 1), globalmax_x(Tp, 1), globalmax_y(Tp, 1), globalmax_z(Tp, 1)) as
"Region 1 Maximum"
report(globalmax(Tp, 2), globalmax_x(Tp, 2), globalmax_y(Tp, 2), globalmax_z(Tp, 2)) as
"Region 2 Maximum"
report(globalmax(Tp, 1, 1), globalmax_x(Tp, 1, 1), globalmax_y(Tp, 1, 1),
globalmax_z(Tp, 1, 1)) as "Region 1 Layer 1 Maximum"
report(globalmax(Tp, 2, 2), globalmax_x(Tp, 2, 2), globalmax_y(Tp, 2, 2),
globalmax_z(Tp, 2, 2)) as "Region 2 Layer 2 Maximum"
end
5.2.10.6 standard_functions
{ STANDARD_FUNCTIONS.PDE
plots
elevation(sqrt(x)) from (0) to (1)
elevation(dx(sqrt(x)),0.5/sqrt(x)) from (0.01) to (1)
5.2.10.7 sum
{ SUM.PDE
}
title 'Sum test'
Variables
u
definitions
k = 1
u0 = 1-x^2-y^2 { boundary forced to parabolic values }
xc = array(-0.5,0.5,0.5,-0.5) { arrays of source spot coordinates }
yc = array(-0.5,-0.5,0.5,0.5)
s = sum( i, 1, 4, exp(-10*((x-xc[i])^2+(y-yc[i])^2)) ) { summed Gaussian
source }
equations
U: div(K*grad(u)) +s = 0
boundaries
region 1
start(-1,-1)
value(u)=u0
line to (1,-1)
to (1,1)
to (-1,1)
to close
monitors
grid(x,y)
contour(u)
contour(s)
plots
grid(x,y)
contour(u)
contour(s)
end
5.2.10.8 swage_pulse
{ SWAGE_PULSE.PDE
A pulse can be made by two ifs:
r1 = IF x<x1 THEN 0 ELSE 1
r2 = IF x<x2 THEN 1 ELSE 0
pulse = r1*r2
This can be directly translated in to SWAGE 167 or RAMP 165 statements with width W:
spulse = SWAGE(x-x1,0,1,w) * SWAGE(x-x2,1,0,w)
rpulse = RAMP(x-x1,0,1,w) * RAMP(x-x2,1,0,w)
}
title "SWAGE and RAMP Pulses"
select
elevationgrid=2000
{ -- No variables, no equations -- }
definitions
x1 = -0.5
x2 = 0.5
w = 0.05
swage_pulse = SWAGE(x-x1,0,1,w) * SWAGE(x-x2,1,0,w)
ramp_pulse = RAMP(x-x1,0,1,w) * RAMP(x-x2,1,0,w)
boundaries
region 1
557 FlexP DE 7 : Sample P roblems
5.2.10.9 swage_test
{ SWAGE_TEST.PDE
This example illustrates the use of the SWAGE 167 and RAMP 165 functions to generate
smoother alternatives to the IF..THEN 180 construct.
IF..THEN is frequently used to turn sources on and off, to define discontinuous
initial conditions and the like.
elevation(dx(ramp(x,-1,1,0.1)), dx(swage(x,-
1,1,0.1)))
from (-0.5,0) to (0.5,0)
end
5.2.10.10 unit_functions
{ UNIT_FUNCTIONS.PDE
This example illustrates the unit step, unit pulse,
and unit ramp functions ustep(arg1), upulse(arg1,arg2),
and uramp(arg1,arg2) See Unit Functions 163 .
}
title
Sample P roblems : Usage 558
"unit functions"
select
elevationgrid=500
{no variables}
definitions
x1 = 0.2
x2 = 0.4
{no equations}
{plot domain -- required}
boundaries
region 1
start (-1,0)
line to (1,0) to (1,1) to (-1,1) to close
plots
elevation(ustep(x-x1)) from (0,0) to (1,0)
elevation(dx(ustep(x-x1))) from (0,0) to (1,0)
elevation(upulse(x-x1,x-x2)) from (0,0) to (1,0)
elevation(dx(upulse(x-x1,x-x2))) from (0,0) to (1,0)
elevation(uramp(x-x1,x-x2)) from (0,0) to (1,0)
elevation(dx(uramp(x-x1,x-x2))) from (0,0) to (1,0)
! generating a square wave by clipping a cosine
elevation(ustep(cos(4*pi*x))) from (-1,0) to (1,0)
! the duty cycle can be controlled by offsetting the cosine from zero
elevation(ustep(cos(4*pi*x)-0.3)) from (-1,0) to (1,0)
end
5.2.10.11 v ector_functions
{ VECTOR_FUNCTIONS.PDE
VECTOR
MAGNITUDE
DOT
CROSS
NORMAL
TANGENTIAL
}
title
"vector functions"
select
elevationgrid=500
{no variables}
definitions
u= exp(-x^2+ y) { A scalar potential, perhaps }
f= grad(u) { F = grad(u) is a vector }
df= div(f) { Divergence of F is a scalar}
cf= curl(f) { Curl of F is a new vector }
vx= -sin(y) vy= 2*sin(x) { vector components }
v= vector(vx,vy) { Another vector }
mv= magnitude(v) { Magnitude of v }
cv= curl(v)
ccv= curl(curl(v))
tvv = v*v { v*v is a tensor }
divtx = 2*vx*dx(vx)+vx*dy(vy)+vy*dy(vx) {x-component of div(t) }
divty = vx*dx(vy)+vy*dx(vx)+2*vy*dy(vy) {y-component of div(t) }
divt = vector(divtx,divty)
{no equations}
{plot domain -- required}
boundaries
559 FlexP DE 7 : Sample P roblems
region 1
start "Outer" (-1,0)
line to (1,0) to (1,1) to (-1,1) to close
feature
start "inner" (-1/2,1/2) line to (1/2,1/2)
plots
vector(f)
elevation(normal(f)) on "Outer"
elevation(tangential(f)) on "inner"
contour(df) as "Div F"
contour(mv) as "Magnitude V"
contour(dot(v,vector(x,0)))
contour(zcomp(cross(f,v)))
contour(zcomp(cv)) as "Curl V"
vector(ccv) as "Curl Curl V"
vector(div(v*v)) as "Div(V*V) inline"
vector(divt) as "Div(V*V) expanded"
vector(div(tvv)) as "Div(V*V) tensor parameter"
end
5.2.11 Implicit_Curves
5.2.11.1 im plicit_curv e_boundary
{ IMPLICIT_CURVE_BOUNDARY.PDE
Definitions
k = 1
u0 = 1-x^2-y^2
s = 2*3/4+5*2/4
Initial Values u = 1
Equations
U: div(K*grad(u)) + s = 0
Boundaries
region 1
start(-0.1, 0.004) value(u)=u0
line to (0.1,0.004)
{ create a boundary segment that follows the expression
(x^2+y^2)^2 - 3*x^2*y - y^3 = A, where A is calculated using
the current point, and start moving in the +Y direction. }
adapt curve ((x^2+y^2)^2 - 3*x^2*y - y^3) by (+y) to close
Plots
contour(u)
surface(u)
End
{ IMPLICIT_CURVE_SURFACE.PDE
Sample P roblems : Usage 560
Definitions
f1 = (x^2+y^2)^3-4*x^2*y^2
f2 = (x^2+y^2)^2-4*x*y
f3 = (x^2+y^2)^2 - 3*x^2*y - y^3
Boundaries
region 1
start(-2,-1)
line to (2,-1) to(2,2) to (-2,2) to close
Plots
contour(F1)
contour(F1) zoom(-1,0, 2,1)
contour(dx(F1)) zoom(-1,0, 2,1)
contour(dy(F1)) zoom(-1,0, 2,1)
elevation(dx(F1),dy(F1)) from (-1,0) to (1,0)
contour(F2)
contour(F2) zoom(-1,0, 2,1)
contour(dx(F2)) zoom(-1,0, 2,1)
contour(dy(F2)) zoom(-1,0, 2,1)
elevation(dx(F2),dy(F2)) from (-1,0) to (1,0)
contour(F3)
contour(F3) zoom(-1,0, 2,1)
contour(dx(F3)) zoom(-1,0, 2,1)
contour(dy(F3)) zoom(-1,0, 2,1)
elevation(dx(F3),dy(F3)) from (-1,0) to (1,0.0)
End
5.2.11.3 sine_boundary
{ SINE_BOUNDARY.PDE
definitions
k = 1
bottom = -1
equations
U: div(K*grad(u)) + 4 = 0
boundaries
Region 1
start(-1,bottom)
value(u)=0
line to (10,bottom)
561 FlexP DE 7 : Sample P roblems
natural(u)=0
line to (10,2)
value(u)=1
{ create a boundary segment that follows the equation
y = cos(pi*x)+1, and start moving in the -X direction. }
curve (y = cos(pi*x)+1) by (-x) to (-1,0)
natural(u)=0
line to close
plots
contour(u)
elevation(u) from(-1,0) to (1,0)
end
{ SINE_BOUNDARY_3D.PDE
definitions
k = 1
bottom = -1
equations
U: div(K*grad(u)) + 4 = 0
extrusion z = 0,1
boundaries
Region 1
start(-1,bottom)
value(u)=0
line to (10,bottom)
natural(u)=0
line to (10,2)
value(u)=1
{ create a boundary segment that follows the equation
y = cos(pi*x)+1, and start moving in the -X direction. }
curve (y = cos(pi*x)+1) by (-x) to (-1,0)
natural(u)=0
line to close
plots
grid(x,y) on z=1/2
contour(u) on z=1/2
surface(u) on z=1/2
elevation(u) from(-1,0,1/2) to (1,0,1/2)
end
5.2.12 Import_Export
5.2.12.1 3d_m esh_ex port
{ 3D_MESH_EXPORT.PDE
This example shows the use of the TRANSFER 213 command to export problem data
Sample P roblems : Usage 562
The accompanying test 3D_MESH_IMPORT.PDE 562 reads the transfer file produced here.
definitions
k = 1
an = pi/4 { this is the angular size of the repeated segment }
crot = cos(an) { the sine and cosine needed in the transformation }
srot = sin(an)
H = 0
xc = 1.5
yc = 0.2
rc = 0.1
equations
U: div(K*grad(u)) + H = 0
extrusion z=0,0.4,0.6,1
boundaries
Region 1
start(1,0) line to (2,0)
value(u) = 0 arc(center=0,0) to (2*crot,2*srot)
antiperiodic(x*crot+y*srot, -x*srot+y*crot)
line to (crot,srot)
value(u)=0
arc(center= 0,0) to close
Limited Region 2
layer 2 H=1
start(xc-rc,0) line to (xc+rc,0) to (xc+rc,rc) to (xc-rc,rc) to close
Limited Region 3
layer 2 H=-1
start((xc-rc)*crot,(xc-rc)*srot)
line to ((xc+rc)*crot,(xc+rc)*srot)
to ((xc+rc)*crot+rc*srot,(xc+rc)*srot-rc*crot)
to ((xc-rc)*crot+rc*srot,(xc-rc)*srot-rc*crot) to close
plots
contour(u) on z=0.5 paint
grid(x,y,z)
transfer(u) file="mesh3u.xfr" ! Export mesh and data
transfer() file="mesh3.xfr" ! Export mesh only
end
This example shows the use of the TRANSFERMESH 213 command to import a
3D Mesh. The mesh file is created by running 3D_MESH_EXPORT.PDE 561 .
Note that the domain structure must exactly match that of the exporting problem.
Periodicity condtions must also be the same, except that periodic and antiperiodic
may be exchanged.
}
title '3D MESH IMPORT TEST'
coordinates cartesian3
variables
u
definitions
k = 1
{ angular size of the repeated segment: }
an = pi/4
{ sine and cosine needed in transformation }
crot = cos(an)
srot = sin(an)
H = 0
xc = 1.5
yc = 0.2
rc = 0.1
transfermesh("3d_mesh_export_output/
mesh3.xfr") ! << read the mesh file
equations
U: div(K*grad(u)) + H = 0
extrusion z=0,0.4,0.6,1
boundaries
Region 1
start(1,0) line to (2,0)
value(u) = 0 arc(center=0,0) to (2*crot,2*srot)
antiperiodic(x*crot+y*srot, -x*srot+y*crot)
line to (crot,srot)
natural(u)=x-2.4*y ! BC changed from exporting problem
arc(center= 0,0) to close
Limited Region 2
layer 2 H = 1
start(xc-rc,0) line to (xc+rc,0) to (xc+rc,rc) to (xc-rc,rc) to close
Limited Region 3
layer 2 H = -1
start((xc-rc)*crot,(xc-rc)*srot)
line to ((xc+rc)*crot,(xc+rc)*srot)
to ((xc+rc)*crot+rc*srot,(xc+rc)*srot-rc*crot)
to ((xc-rc)*crot+rc*srot,(xc-rc)*srot-rc*crot) to close
plots
contour(u) on z=0.5 paint
grid(x,y,z)
end
5.2.12.3 3d_post_processing
{ 3D_POST_PROCESSING.PDE
This example demonstrates the use of the TRANSFERMESH 213 facility to import
both data and mesh structure from 3D_MESH_EXPORT.PDE 561 and perform
post-processing without gridding or solving any equations.
Note that the domain structure must exactly match that of the exporting problem.
Sample P roblems : Usage 564
plots
grid(x,y,z)
contour(u) on x=0 { YZ plane through diameter }
export
contour(u) on z=0.5 { XY plane above center }
export format "#x#b#y#b#z#b#1"
contour(u) on surface 2 { top surface }
export format "#x#b#y#b#z#b#1"
end
5.2.12.5 blocktable
{ BLOCKTABLE.PDE
This example shows the use of the BLOCK 210 modifier in reading TABLE 208 data.
The BLOCK 210 modifier allows table data to be interpreted in Histogram profile.
The default interpretation imposes a 10% rise width on the histogram blocks,
to avoid dramatic timestep cuts when data are used as driving profiles in
time-dependent problems.
The BLOCK(rise) 210 qualifier allows the specification of a rise width as a fraction
of block width.
}
title '1D BLOCK table'
select
regrid=off
{ No Variables are necessary }
definitions
{ single value format with default 10% rise width: }
u = block table("table1.tbl")
{ assignment list format with 50% rise width: }
block(0.5) tabledef("table1.tbl",v)
{ single value format with un-blocked interpretation: }
w = table("table1.tbl")
boundaries
Region 1
start(0,0)
line to (10,0) to (10,1) to (0,1) to close
plots
contour(u) as "10% rise"
contour(v) as "50% rise"
contour(w) as "Unblocked"
elevation(u) as "10% rise" from(0,0.5) to (10,0.5)
elevation(v) as "50% rise" from(0,0.5) to (10,0.5)
elevation(w) as "Unblocked" from(0,0.5) to (10,0.5)
elevation(u, v, w) from(0,0.5) to (10,0.5)
end
Sample P roblems : Usage 566
5.2.12.6 ex port
{ EXPORT.PDE
This sample demonstrates the use of several forms of data export selectors.
All exports use the default file naming conventions, which append modifiers
to the problem name.
A heat flow problem is solved on a square for example purposes.
}
title "Demonstrate forms of export"
variables
Temp
definitions
K = 1
source = 4
Texact = 1-x^2-y^2
flux=magnitude(K*grad(Temp))
Initial values
Temp = 0
equations
Temp: div(K*grad(Temp)) + source = 0
boundaries
Region 1
start "BDRY" (-1,-1)
value(Temp)=Texact
line to (1,-1)
to (1,1)
to (-1,1)
to close
monitors
contour(Temp)
plots
{ this contour plot exports graphic images in four formats:
( notice that the BMP file is 46 times larger than the other formats!) }
contour(Temp) PNG EPS EMF BMP
{ export temperature and flux in NetCDF format }
cdf(temp,flux)
{ export FlexPDE TABLE format }
table(temp)
{ export temperature and flux in TecPlot format }
tecplot(temp,flux)
{ export temperature and flux in linearized VTK format }
vtklin(temp,flux)
end
5.2.12.7 ex port_form at
{ EXPORT_FORMAT.PDE
This problem demonstrates a few variations on the use of the
FORMAT 250 modifier in data export.
}
Title 'Test FORMATTED export'
Variables
u(1.0)
Equations
U: dxx(u) + dyy(u) = -4
567 FlexP DE 7 : Sample P roblems
Boundaries
region 1
start(0.5,1)
value(u)=0 { the cold outer boundary }
line to (2.5,1) to (2.5,2) to (0.5,2) to close
start(1,1.2)
natural(u) = 0
line to (1,1.8) to (2,1.8)
line to (1.52,1.52) to (1,1.52) to (1,1.48) to (1.52,1.48)
to (2,1.2) to close
Monitors
contour(u)
Plots
{ An ELEVATION plot prints a tag-delimited data list to the file "PTABLE.TXT":}
elevation(u) from (1.5,1) to (1.5,2) export format "#y#b#1" file="ptable.txt"
{ A CONTOUR plot prints a tab-delimited table of values in the default
file "export_format.p02": }
contour(u^2) export format "#x#b#y#b#1"
{ A VECTOR plot prints a table of vectors delimited by commas and parentheses
in the file "VECTOR.TXT": }
vector(-dx(u),-dy(u)) zoom(1.9,1.7,0.2,0.2) export format "(#x,#y)=(#1,#2)"
file "vectors.txt"
{ A TABLE output without graphics writes a 10x10 table of FIXED POINT gridding
statements suitable for inclusion in another PDE descriptor
(in the default file "export_format_01.tbl"): }
table(u) format "fixed point (#x,#y) point load(u)=(#1-u)" points=10
{ A TABLE output without graphics writes a 12x10 table of gaussian source
statements suitable for inclusion in another PDE descriptor
(in the default file "export_format_02.tbl"): }
table(u) format "+a*exp(-((x-#x)/c)^2-((y-#y)/c)^2)*(#1-u)" points=(12,10)
End
5.2.12.8 ex port_history
{ EXPORT_HISTORY.PDE
This example illustrates use of the FORMAT 250 modifier in the export of a
HISTORY 270 plot.
The repeat (#R 250 ) construct is used to create a comma-delimited data list.
initial value
temp = Ta
equations
Temp: div(k*grad(temp)) + source = cp*dt(temp)
boundaries
region 1
start(0,0)
natural(temp) = 0 line to (long,0)
value(temp) = Ta line to (long,1)
natural(temp) = -H*(temp - Ta) line to (0,1)
value(temp) = Ta line to close
feature
start(0.01*long,0) line to (0.01*long,1)
time -0.5 to 19 by 0.01
monitors
for t = -0.5 by 0.5 to (long + 1)
elevation(temp) from (0,1) to (long,1) range=(0,1800) as "Surface Temp"
contour(temp)
plots
for t = -0.5 by 0.5 to (long + 1)
elevation(temp) from (0,0) to (long,0) range=(0,1800) as "Axis Temp"
histories
{ EXPORT a formatted HISTORY file: }
history(temp) at (0,0) (1,0) (2,0) (3,0) (4,0) (5,0) (6,0) (7,0) (8,0)
(9,0) (10,0) (11,0) (12,0) (13,0) (14,0) (15,0) (16,0)
(17,0) (18,0) export format "#t#r,#i"
end
variables
Temp
definitions
K = 1
source = 4
Tzero = 0
flux = -K*grad(Temp)
equations
Temp: div(K*grad(Temp)) + source = 0
boundaries
Region 1
start "OUTER" (0,0)
natural(Temp)=0 line to(1,0)
natural(Temp)=0 arc (center=0,0) to (0,1)
natural(Temp)=0 line to close
start "INNER" (0.4,0.2)
natural(Temp)=Tzero-Temp
arc (center=0.4,0.4)
to (0.6,0.4)
to (0.4,0.6)
569 FlexP DE 7 : Sample P roblems
to (0.2,0.4)
to close
monitors
contour(Temp)
plots
grid(x,y)
contour(Temp)
surface(Temp)
vector(-K*dx(Temp),-K*dy(Temp)) as "Heat Flow"
contour(source)
elevation(normal(flux)) on "outer" range(-0.08,0.08)
report(bintegral(normal(flux),"outer")) as "bintegral"
elevation(normal(flux)) on "inner" range(1.95,2.3)
report(bintegral(normal(flux),"inner")) as "bintegral"
{ HERE IS THE TRANSFER OUTPUT COMMAND: }
transfer(Temp,source) file="transferm.xfr"
end
This problem demonstrates the use of the TRANSFERMESH 246 facility to import
both data and mesh structure from MESH_EXPORT.PDE 568 .
5.2.12.11 post_processing
{ POST_PROCESSING.PDE
This example demonstrates the use of the TRANSFERMESH 213 facility to import
both data and mesh structure from MESH_EXPORT.PDE 568 and perform
post-processing without gridding or solving any equations.
Note that the domain structure must exactly match that of the exporting problem.
}
title "Using TRANSFERMESH for post-processing"
definitions
K = 1
transfermesh('mesh_export_output/transferm.xfr',Temp)
boundaries
Region 1
start "OUTER" (0,0)
line to(1,0)
arc (center=0,0) to (0,1)
line to close
start "INNER" (0.4,0.2)
arc (center=0.4,0.4)
to (0.6,0.4)
to (0.4,0.6)
to (0.2,0.4)
to close
plots
grid(x,y)
contour(Temp)
contour(Temp) zoom(0.2,0.2,0.1,0.1)
surface(Temp)
571 FlexP DE 7 : Sample P roblems
5.2.12.12 sm oothtable
{ SMOOTHTABLE.PDE
This example shows the use of the SMOOTH 210 modifier for data tables.
}
title 'Smooth Table Input Test'
definitions
size=10
ts = table('table_s.tbl')
tsx = smooth(1,0) table('table_s.tbl')
tsy = smooth(0,1) table('table_s.tbl')
tsxy = smooth(1,1) table('table_s.tbl')
boundaries
region 1
start(0,size)
line to (0,0) to (size,0) to (size,size) to close
plots
grid(x,y)
surface(ts) as 'Table'
surface(tsx) as 'X-smooth'
surface(tsy) as 'Y-smooth'
surface(tsxy) as 'XY-smooth'
elevation(ts,tsx) from(0,size/2) to (size,size/2) as 'X-smooth'
elevation(ts,tsy) from(size/2,0) to (size/2,size) as 'Y-smooth'
elevation(ts,tsxy) from(size/2,0) to (size/2,size) as 'XY-smooth'
end
5.2.12.13 splinetable
{ SPLINETABLE.PDE
This example solves the same system as TABLE.PDE 572 , using a Spline interpretation of
the
data in the table file 'TABLE.TBL'.
The file format is the same for TABLE 208 or SPLINE TABLE 210 input.
The SPLINE TABLE operator can be used to build spline tables of one or two
dimensions.
The resulting interpolation is third order in the coordinates, with continuous values
and derivatives. First or second derivatives of the interpolated function may be
computed.
Here the table is used as source and diffusivity in a fictitious heat equation, merely
to
show the use of the table variable.
The SAVE function is used to construct a Finite Element interpolation of the data from
the
spline table, for comparison of derivatives. Cubic FEM basis is used so that the
second
derivative is meaningful.
}
title 'Spline Table Input Test'
select
regrid=off
variables
u
Sample P roblems : Usage 572
definitions
alpha = spline table('table.tbl') ! construct spline fit of table:
beta = 1/alpha
femalpha = save(alpha) ! save a FEM interpolation of table:
equations
U: div(alpha*grad(u)) + beta = 0
boundaries
region 1
start(0,10)
value(u) = 0
line to (0,0) to (10,0) to (10,10) to close
monitors
contour(u)
plots
grid(x,y)
contour(alpha) as 'table'
contour(dx(alpha)) as 'dx(table)'
contour(dy(alpha)) as 'dy(table)'
vector(grad(alpha)) as 'grad(table)'
surface(alpha) as 'table'
contour(dxx(alpha)) as 'dxx(table)'
contour(dxy(alpha)) as 'dxy(table)'
contour(dyy(alpha)) as 'dyy(table)'
contour(dxx(alpha)+dyy(alpha)) as "Table Curvature"
contour(div(grad(femalpha))) as "FEM Curvature"
surface(beta) as "table reciprocal"
contour(u) as "temperature solution"
surface(u) as "temperature solution"
end
5.2.12.14 table
{ TABLE.PDE
This problem demonstrates the use of tabular data.
It reads the file "TABLE.TBL", uses the data in a heat equation,
and displays the table data.
}
title 'Table Input Test'
select
errlim = 0.0005
variables
u
definitions
alpha = table('table.tbl')
beta = 1/alpha
equations
U: div(alpha*grad(u)) + beta = 0
boundaries
region 1
start(0,10)
value(u) = 0
line to (0,0) to (10,0) to (10,10) to close
monitors
contour(u)
plots
grid(x,y)
contour(alpha) as "Conductivity (Table data)"
surface(alpha) as 'Conductivity (Table data)'
vector(grad(alpha)) as 'grad(table)'
surface(beta) as "Source (Table Reciprocal)"
contour(u) as "Temperature solution"
573 FlexP DE 7 : Sample P roblems
5.2.12.15 tabledef
{ TABLEDEF.PDE
This problem illustrates the use of the TABLEDEF 210 function to define several
parameters from an imported table named TABLEDEF.TBL
Note that the TABLEDEF 210 function has the same syntax as the TRANSFER 213 function.
The difference is that TABLEDEF 210 uses a rectangular grid of data values,
while TRANSFER 213 uses an unstructured triangular finite element mesh created
by a prior FlexPDE run.
}
title 'Table Input Test'
select
errlim = 0.0005
variables
u
definitions
tabledef('tabledef.tbl',alpha,beta)
equations
U: div(alpha *grad(u)) + beta = 0
boundaries
region 1
start(0,10)
value(u) = 0
line to (0,0) to (10,0) to (10,10) to close
monitors
contour(u)
plots
grid(x,y)
contour(u)
surface(u)
contour(alpha)
contour(beta)
vector(grad(alpha))
end
The output is in default format, suitable for TABLE 208 input to other FlexPDE runs.
See "FORMAT 'string'" in the Help Index for formatting controls.
See TABLE_IMPORT.PDE 574 for an example of reading the TABLE 208 created here.
}
title 'TABLE generation'
Sample P roblems : Usage 574
select
regrid=off
definitions
u = exp(-16*(x^2+y^2))
boundaries
Region 1
start(-1,-1)
line to (1,-1) to (1,1) to (-1,1) to close
plots
contour(u)
surface(u)
! 2D table
table(u) points=51 file='gauss2.tbl'
! 1D table
elevation(u) from(-1,0) to (1,0) export file='gauss1.tbl'
end
Tzero = 0
flux = -K*grad(Temp)
equations
Temp: div(K*grad(Temp)) + source = 0
boundaries
Region 1
start "OUTER" (0,0)
natural(Temp)=0 line to(1,0)
natural(Temp)=0 arc (center=0,0) to (0,1)
natural(Temp)=0 line to close
This problem demonstrates the use of the TRANSFER 213 facility to import
temperatures from TRANSFER_EXPORT.PDE 574 as the source of thermal expansion
driving a stress calculation.
initial values
U = 0
V = 0
equations
U: dx(Sxx) + dy(Sxy) = 0
V: dy(Syy) + dx(Sxy) = 0
constraints
integral(u) = 0
integral(v) = 0
integral(dx(v)-dy(u)) = 0
boundaries
Region 1
start "OUTER" (0,0)
natural(U)=0 value(V)=0 line to(1,0)
natural(U)=0 natural(V)=0
arc (center=0,0) to (0,1) { free outer boundary }
value(U)=0 natural(V)=0 line to close
{ free inner boundary }
start "INNER" (0.4,0.2)
natural(U)=0 natural(V)=0
arc (center=0.4,0.4)
to (0.6,0.4)
to (0.4,0.6)
to (0.2,0.4)
to close
monitors
grid(x+100*U,y+100*V)
plots
contour(Temp) report(Kxfer)
grid(x+100*U,y+100*V)
vector(U,V) as "Displacement"
contour(U) as "X-Displacement"
contour(V) as "Y-Displacement"
contour(Sxx) as "X-Stress"
contour(Syy) as "Y-Stress"
surface(Sxx) as "X-Stress"
surface(Syy) as "Y-Stress"
end
5.2.13 Integrals
5.2.13.1 2d_integrals
{ 2D_INTEGRALS.PDE
This problem demonstrates the specification of various integrals in 2D.
}
title '2D Integrals'
coordinates
ycylinder
variables
Tp
select errlim=1e-4
definitions
R0 = 0.1
R1 = 0.4
R2 = 0.6
Long = 1.0
577 FlexP DE 7 : Sample P roblems
5.2.13.2 3d_integrals
{ 3D_INTEGRALS.PDE
This problem demonstrates the specification of various integrals in 3D.
( This is a modification of problem 3D_BRICKS.PDE 414 )
}
title '3D Integrals'
coordinates
cartesian3
variables
Tp
definitions
long = 1
wide = 1
K { thermal conductivity -- values supplied later }
Q = 10*max(1-x^2-y^2-z^2,0) { Thermal source }
{ These definitions create a selector that supresses evaluation
of Tp except in region 2 of layer 2 }
flag22=0
check22 = if flag22>0 then Tp else 0
{ These definitions create a selector that supresses evaluation
of Tp except in region 2 of all layers }
flag20=0
check20 = if flag20>0 then Tp else 0
initial values
Tp = 0.
equations
Tp: div(k*grad(Tp)) + Q = 0 { the heat equation }
extrusion
surface "bottom" z = -long
layer 'bottom layer'
surface "middle" z=0
layer 'top layer'
surface 'top' z= long { divide Z into two layers }
boundaries
surface 1 value(Tp)=0 { fix bottom surface temp }
surface 3 value(Tp)=0 { fix top surface temp }
Region 1 { define full domain boundary in base plane }
layer 1 k=1 { bottom right brick }
layer 2 k=0.1 { top right brick }
start "outside" (-wide,-wide)
value(Tp) = 0 { fix all side temps }
line to (wide,-wide) { walk outer boundary in base plane }
to (wide,wide)
to (-wide,wide)
to close
Region 2 "Left" { overlay a second region in left half }
flag20=1
layer 1 k=0.2 { bottom left brick }
layer 2 k=0.4 flag22=1 { top left brick }
start(-wide,-wide)
line to (0,-wide) { walk left half boundary in base plane }
to (0,wide)
to (-wide,wide)
to close
monitors
contour(Tp) on surface z=0 as "XY Temp"
contour(Tp) on surface x=0 as "YZ Temp"
contour(Tp) on surface y=0 as "ZX Temp"
elevation(Tp) from (-wide,0,0) to (wide,0,0) as "X-Axis Temp"
elevation(Tp) from (0,-wide,0) to (0,wide,0) as "Y-Axis Temp"
elevation(Tp) from (0,0,-long) to (0,0,long) as "Z-Axis Temp"
plots
579 FlexP DE 7 : Sample P roblems
end
A = 4500 {amplitude}
source = A*exp(-((z-1*t)/.5)^2)*(200/(t+199))
tsource = time_integral(vol_integral(source))
initial value
temp = Ta
equations
temp: div(k*grad(temp)) + source = cp*dt(temp)
boundaries
region 1
start(0,0)
natural(temp) = 0 line to (long,0)
value(temp) = Ta line to (long,1)
natural(temp) = -H*(temp - Ta) line to (0,1)
value(temp) = Ta line to close
feature
start(0.01*long,0) line to (0.01*long,1)
time -0.5 to 19
monitors
for t = -0.5 by 0.5 to (long + 1)
elevation(temp) from (0,1) to (long,1) range=(0,1800) as "Surface Temp"
contour(temp)
contour(dt(temp))
plots
for t = -0.5 by 0.5 to (long + 1)
elevation(temp) from (0,0) to (long,0) range=(0,1800) as "Axis Temp"
histories
history(temp,dt(temp)) at (0,0) (1,0) (2,0) (3,0) (4,0) (5,0) (6,0) (7,0) (8,0)
(9,0) (10,0) (11,0) (12,0) (13,0) (14,0) (15,0) (16,0)
(17,0) (18,0)
history(tsource) as "Total Source"
end
5.2.14 Mesh_Control
5.2.14.1 3d_curv ature
{ 3D_CURVATURE.PDE
This problem demonstrates automatic mesh densification due to curvature and
proximity to small features.
The example consists of a three-layer heatflow problem. The bottom layer contains
a hidden rise, or "dimple", that rises close to the base of the adjoining layer.
FlexPDE detects this dimple and automatically refines the computation mesh to
resolve the curvature of the tip.
It also detects the proximity of the dimple peak to the adjoining layer and refines
the
mesh in that layer as well.
}
definitions
long = 1
wide = 1
K = 1
Q = 0
narrow = 0.2
z1 = 0
z2 = 0.1+0.3*exp(-(x^2+y^2)/narrow^2)
z3 = 0.5
z4= 1
initial values
Tp = 0.
equations
Tp: div(k*grad(Tp)) + Q = 0
extrusion z = z1,z2,z3,z4
boundaries
surface 1 value (Tp)=0
surface 4 value (Tp)=1
Region 1
layer 1 k=10
layer 3 k=5
start (-wide,-wide)
line to (wide,-wide) to (wide,wide) to (-wide,wide) to close
monitors
grid (x,z) on y=0
contour (Tp) on z=0.38 painted
plots
grid(x,y,z) on layer 1
grid (x,z) on y=0
grid(x,y) on surface 2
contour (Tp) on y=0 as "ZX Temp"
contour (Tp) on z=0.38 painted
end
5.2.14.4 front
{ FRONT.PDE
The FRONT 242 command is used to force mesh refinement wherever the
concentration variable passes through a value of 0.5.
title
'FRONT statement in Chemical Reactor'
select
painted { make color-filled contour plots }
variables
Temp (threshold=1)
C (threshold=1)
definitions
Lz = 1
r1=1
heat=0
gamma = 16
beta = 0.2
betap = 0.3
BI = 1
T0 = 1
TW = 0.92
{ the very nasty reaction rate: }
RC = (1-C)*exp(gamma-gamma/Temp)
xev=0.96 { some plot points }
yev=0.25
initial value
Temp=T0
C=0
equations
Temp: div(grad(Temp)) + heat + betap*RC = dt(Temp)
C: div(grad(C)) + beta*RC = dt(C)
boundaries
region 1
start (0,0)
{ a mirror plane on X-axis }
natural(Temp) = 0
natural(C) = 0
line to (r1,0)
{ "Strip Heater" at fixed temperature }
{ ramp the boundary temp in time, because discontinuity is costly to diffuse }
value(Temp)=T0 + 0.2*uramp(t,t-0.05)
natural(C)=0 { no mass flow on strip heater }
arc(center=0,0) angle 5
{ convective cooling and no mass flow on outer arc }
natural(Temp)=BI*(TW-Temp)
natural(C)=0
arc(center=0,0) angle 85
{ a mirror plane on Y-axis }
natural(Temp) = 0
natural(C) = 0
line to (0,0) to close
time 0 to 1
{ FORCE CELLS TO SPAN NO MORE THAN 0.1 ACROSS C=0.5 }
front(C-0.5, 0.1)
plots
for cycle=10 { watch the fast events by cycle }
grid(x,y)
contour(Temp)
contour(C) as "Completion"
for t= 0.2 by 0.05 to 0.3 { show some surfaces during burn }
surface(Temp)
surface(C) as "Completion"
histories
history(Temp,C) at (0,0) (xev/2,yev/2) (xev,yev) (yev/2,xev/2) (yev,xev)
Sample P roblems : Usage 584
end
5.2.14.5 m esh_density
{ MESH_DENSITY.PDE
5.2.14.6 m esh_spacing
{ MESH_SPACING.PDE
definitions
k = 1
u0 = 1-x^2-y^2
s = 2*3/4+5*2/4
mesh_spacing = exp(-2*(x^2+y^2))
b = 0.1
c = 0.02
equations
u : div(K*grad(u)) +s = 0
boundaries
Region 1
start(-1,-1)
value(u)=u0
line to (1,-1) to (1,1) to (-1,1) to close
Region 2
mesh_spacing = c
start(-b,-b)
line to (b,-b) to (b,b) to (-b,b) to close
plots
grid(x,y)
contour(u)
end
5.2.14.7 resolv e
{ RESOLVE.PDE
This is a test problem from Timoshenko: Theory of Elasticity, p41
The RESOLVE 243 statement has been added to force regridder to resolve the
shear stress.
}
title "RESOLVE shear stress in bent bar"
select
elevationgrid=500
cubic
variables
U { X-displacement }
V { Y-displacement }
definitions
L = 1 { Bar length }
hL = L/2
W = 0.1 { Bar thickness }
hW = W/2
eps = 0.01*L
I = 2*hW^3/3 { Moment of inertia }
nu = 0.3 { Poisson's Ratio }
E = 2.0e11 { Young's Modulus for Steel (N/M^2) }
{ plane stress coefficients }
G = E/(1-nu^2)
C11 = G
C12 = G*nu
C22 = G
C33 = G*(1-nu)/2
amplitude=1e-6 { a guess for grid-plot scaling }
mag=0.1/amplitude
Sample P roblems : Usage 586
5.2.15 Misc
5.2.15.1 askuser
{ ASKUSER.PDE
This example demonstrates the use of the ASK USER command to take input from the user
at run time.
The problem is a copy of FILLET.PDE 590 .
}
Variables
u
select
587 FlexP DE 7 : Sample P roblems
definitions
k = 1
u0 = 1-x^2-y^2
s = ask user("What source do you want to use?",2*3/4+5*2/4)
equations
U: div(K*grad(u)) +s = 0
boundaries
Region 1
start(-1,-1)
value(u)=u0 line to (1,-1) FILLET(0.1)
to (-0.25,-0.25) FILLET(0.1)
to (-1,1) BEVEL(0.1)
to close
plots
grid(x,y)
contour(u) points=200
grid(x,y) zoom(0.6,-1, 0.2,0.2)
contour(u) zoom(0.6,-1, 0.2,0.2) as "Convex Fillet Closeup"
grid(x,y) zoom(-0.35,-0.35, 0.2,0.2)
contour(u) zoom(-0.35,-0.35, 0.2,0.2) as "Concave Fillet Closeup"
end
5.2.15.2 bc_sets
{ BC_SETS.PDE
This example shows the basic use of boundary condition sets.
}
COORDINATES cartesian2
VARIABLES u v
BOUNDARY CONDITIONS
'inlet' : value(u)=1 natural(v)=1
'outlet': natural(u)=1 value(v)=10
'side' : natural(u)=0 natural(v)=0
EQUATIONS
u: div(grad(u))=0
v: div(grad(v))=0
BOUNDARIES
Region 1
start(0,0) use bc 'side'
line to (5,0) use bc 'outlet'
line to (5,1) use bc 'side'
line to (0,1) use bc 'inlet'
line to close
PLOTS
contour(u)
contour(v)
END
Sample P roblems : Usage 588
5.2.15.3 bc_switching
{ BC_SWITCHING.PDE
To achieve this, one can apply a flux that drives the boundary to the
desired value. The flux is a "large" penalty term multiplied by the
difference of the desired value (U0) and the actual value :
NATURAL(U) = penalty*(U0-U)
The size of the penalty term will dictate how rigorously the value is
tracked.
variables Temp
definitions
penalty = 300 { penalty for value bc }
Temp0 = 15 { ambient temperature }
heater = 315 { heater temperature }
h = 1 { block size }
k = 0.85 { thermal conductivity }
cp = 1 { heat capacity }
rt = 0.5 { heater ramp time }
equations
Temp : div(k*grad(Temp)) = cp*dt(Temp)
initial values
Temp = Temp0
boundaries
region 1
start(0,0)
line to (h,0)
natural(Temp) = if (y > delta) then penalty*(Temp0-Temp) else 0
line to (h,h)
nobc(Temp)
line to (0,h)
value(Temp) = RAMP(t-rt,Temp0,heater,2*rt)
line to close
time 0 to 6 by 1e-4
monitors
for cycle = 10
contour(Temp)
elevation(Temp) from(h,0) to (h,h)
plots
for t = 1 by 1 to 6
contour(Temp)
elevation(Temp) from(h,0) to (h,h)
589 FlexP DE 7 : Sample P roblems
histories
history(Temp) at (0,h/2), (h,h/5), (h,4*h/5)
end
5.2.15.4 data_fitting
{ DATA_FITTING.PDE
This example uses GLOBAL VARIABLES to form a least-squares fit to a Gaussian data
distribution,
and then follows the fit as the Gaussian diffuses out.
The basic process of least-squares fitting seeks to minimize the integral of the
square of the
difference between the given data and the analytic fit function:
minimize G = Integral (( F - P)^2 * dV)
where F is the analytic fit and P is the array of given data.
The technique is to find a stationary point in the derivatives of G with respect to
the fit parameters.
In our case, we choose F(x,y) = A*exp(-R^2/W^2), where A is the amplitude and W is
the half-width
of the fitted Gaussian, and R is the radius sqrt(x^2+y^2), (a pre-defined name in
FlexPDE).
With this definition, we can define the fit equations
dG/dA = Integral(2*(F-P)*dF/dA) = 0
dG/dW = Integral(2*(F-P)*dF/dW) = 0
We start by solving the fit equations in an INITIAL EQUATIONS section, then proceed
to solve the
fit equations simultaneously with the diffusion of the data field.
}
coordinates cartesian2
global variables
A(Threshold = 0.001) ! The Fit amplitude
W(Threshold=0.001) ! The Fit half-width
definitions
box = 1.5 ! The Domain Size
wdata = 0.1 ! The half-width of the data Gaussian
k = 0.1 ! the diffusivity of the data equation
W: integral(2*fitg*dfdw) =0
boundaries
region 1
start(-box,-box)
line to (box,-box) to (box,box) to (-box,box) to close
initial values
p = exp(-(x^2 + y^2)/wdata^2)
A = 0.9 ! slightly erroneous first guess amplitude
W= 1.1*wdata ! slightly erroneous first guess half-width
time 0 to 1
plots
for cycle=1
elevation(fitf,p) from (-box,0) to (box,0)
report(A) report(integral(2*fitg*dfdk))
contour(fitf)
contour(p)
contour(fitg) as "Fit Error"
contour(dfdk)
contour(dfdw)
history(A)
history(W)
end
5.2.15.5 fillet
{ FILLET.PDE
This example demonstrates the use of the FILLET 235 and BEVEL 235 commands
}
title 'fillet test'
variables
u
definitions
k = 1
u0 = 1-x^2-y^2
s = 2*3/4+5*2/4
equations
U: div(K*grad(u)) +s = 0
boundaries
Region 1
start(-1,-1)
value(u)=u0
line to (1,-1) FILLET(0.1)
to (-0.25,-0.25) FILLET(0.1)
to (-1,1) BEVEL(0.1)
to close
monitors
grid(x,y)
contour(u)
plots
grid(x,y)
contour(u)
contour(u) zoom(0.6,-1, 0.2,0.2) as "Convex Fillet Closeup"
contour(u) zoom(-0.3,-0.3, 0.1,0.1) as "Concave Fillet Closeup"
end
591 FlexP DE 7 : Sample P roblems
5.2.15.6 fit+weight
{ FIT+WEIGHT.PDE
This test shows the use of spatially-varying weights in the FIT 164 function.
There are no variables or equations here, just a domain and some tabular
data which is FIT in different ways.
The weight declared in the FIT statement is effectively the square of the
spatial distance over which variations are smoothed.
}
title 'Test Variable-Weight FIT'
definitions
u = table('table.tbl')
boundaries
region 1
start(0,10)
line to (0,0) to (10,0) to (10,10) to close
plots
grid(x,y)
contour(u)
contour(fit(u)) as 'unweighted'
contour(fit(u,0.2)) as 'constant weight'
contour(fit(u,0.02*(x-5)^2)) as 'side-weights'
contour(fit(u,0.05*x)) as 'right-side weight'
end
5.2.15.7 ifthen
{ IFTHEN.PDE
Region 1
start(0,0)
value(u)=0
line to (2,0) to (2,2) to (0,2) to close
monitors
contour(u)
plots
surface(u)
contour(u)
contour(a) as "Conditional Conductivity"
elevation(a,u) from (0,1) to (2,1) as "Conductivity and Solution"
end
5.2.15.8 lum p
{ LUMP.PDE
}
title 'LUMP test'
select
contourgrid=400 { use a very dense plot grid to show lump structure }
threads=1
Variables
u
definitions
k = 2
u0 = 1+x^2+y^2
s = u0 - 4*k
lumps = lump(s) { Used in a definition }
Initial values
u = 1
equations
U: u - div(K*grad(u)) = s
boundaries
Region 1
start(-1,-1)
value(u)=u0
line to (1,-1) to (1,1) to (-1,1) to close
monitors
contour(u)
plots
grid(x,y)
contour(u)
contour(s)
contour(lump(s)) as "Lumped Source - Direct Reference"
contour(lumps) as "Lumped Source - Defined Parameter"
end
593 FlexP DE 7 : Sample P roblems
5.2.15.9 m aterial_sets
{ MATERIAL_SETS.PDE
This example shows the basic use of MATERIALS 215 for grouping parameter values.
There are no variables or equations.
}
Coordinates cartesian3
Materials { These values are arbitrary and not intended to reflect the actual physical
values for these materials }
'iron' : K = 4 J = 1
'aluminum' : K = 3 J = 2
'plastic' : K = 2 J = 3
'wood' : K = 1 J = 4
Extrusion z = 0, 1, 2, 3, 4
Boundaries
Region 1
Layer 1 use material 'iron'
Layer 2 use material 'aluminum'
Layer 3 use material 'plastic'
Layer 4 use material 'wood'
start(0,0) line to (1,0) to (1,1) to (0,1) to close
Region 2
use material 'iron'
start(0,1) line to (1,1) to (1,2) to (0,2) to close
Plots
contour(K) on x=0.5 painted range(0,5)
contour(J) on x=0.5 painted range(0,5)
End
5.2.15.10 point_load
{ POINT_LOAD.PDE
Variables
u
definitions
k = 1
u0 = 1-r^2
s = 4
dr(f) = (x/r)*dx(f) + (y/r)*dy(f) { functional definition of polar
derivatives... }
dphi(f) = (-y)*dx(f) + x*dy(f) {... in cartesian coordinates }
pload = staged (0, 2)
boundaries
Region 1
start(0,0) point load(u)=pload
natural(u) = 0 line to (1,0)
value(u)=u0 arc(center=0,0) angle=90
natural(u)=0 line to close
monitors
grid(x,y) as "Computation Mesh"
contour(u) as "Solution"
contour(u-u0) as "Error (u-u0)"
plots
grid(x,y) as "Computation Mesh"
contour(u) as "Solution"
contour(u-u0) as "Error (u-u0)"
end
5.2.15.11 polar_coordinates
{ POLAR_COORDINATES.PDE
This example demonstrates the use of functional parameter definitions
to pose equations in polar-coordinate form. The function definitions
expand polar derivatives in cartesian (XY) geometry.
}
title 'Polar Coordinates'
Variables
u
definitions
k = 1
u0 = 1-r^2
s = 4
dr(f) = (x/r)*dx(f) + (y/r)*dy(f) { functional definition of polar derivatives... }
dphi(f) = (-y)*dx(f) + x*dy(f) {... in cartesian coordinates }
equations { equation expressed in polar coordinates
(Multiplied by r^2 to clear the r=0 singularity) }
U: r*dr(r*dr(u)) + dphi(dphi(u)) + r*r*s = 0
boundaries
Region 1
start(0,0)
natural(u) = 0 line to (1,0)
value(u)=u0 arc(center=0,0) angle=90
natural(u)=0 line to close
monitors
grid(x,y) as "Computation Mesh"
contour(u) as "Solution"
contour(u-u0) as "Error (u-u0)"
plots
grid(x,y) as "Computation Mesh"
contour(u) as "Solution"
contour(u-u0) as "Error (u-u0)"
end
5.2.15.12 repeat
{ REPEAT.PDE
This example illustrates the use of the REPEAT 181 statement to generate
repetitive structures, and the string facility for creating labels.
595 FlexP DE 7 : Sample P roblems
}
title 'REPEAT and $string test'
Variables
u
definitions
a = 1
{ a list of X-coordinates: }
xc=array(1/3, 2/3, 3/3, 4/3, 5/3)
{ a list of Y-coordinates: }
yc=array(1/3, 2/3, 3/3, 4/3, 5/3)
rad = 0.1 { radius of circular dots }
s = 0
equations
U: div(a*grad(u)) + s = 0;
boundaries
region 1
start(0,0)
value(u)=0
line to (2,0) to (2,2) to (0,2) to close
region 2
a = 0.05
s = 4*magnitude(x-1,y-1)
repeat i=1 to 5 { an indexed loop on X-position }
repeat j=1 to 5 { an indexed loop on Y-position }
{ an array of circular dots at the tabulated coordinates }
start "Loop"+$i+$j (xc[i]+rad,yc[j]) {construct loop name using string
conversion }
arc(center=xc[i],yc[j]) angle=360
endrepeat
endrepeat
monitors
contour(u)
plots
contour(u) painted
surface(u)
surface(s) as "Source"
repeat i=1 to 5
repeat j=1 to 5
elevation(u) on 'loop'+$i+$(j)
endrepeat
endrepeat
end
5.2.15.13 rotated_ellipse
{ ROTATED_ELLIPSE.PDE
VARIABLES V Q
DEFINITIONS eps = 1
EQUATIONS
V: div(eps*grad(V)) = 0 {potential equation}
Q: div(grad(Q)/eps) = 0 {adjoint equation}
BOUNDARIES
Sample P roblems : Usage 596
REGION 1
start(0,0)
value(V) = 0 natural(Q) = tangential(grad(V))
line to (3,0)
line to (3, 2.5)
value(V) = 100 natural(Q) = tangential(grad(V))
arc(center = 1.5, 2.5) angle= 180.
line to close
! embedded path will become an EXCLUDE :
start( 2.08, 2.08)
natural(V) = 0 natural(Q) = tangential(grad(V))
arc(center = 1.5, 1.5 rotate= 45.) to ( 1.22, 1.78)
arc(center = 1.5, 1.5 rotate= 45.) to ( 0.92, 0.92)
arc(center = 1.5, 1.5 rotate= 45.) to ( 1.78, 1.22)
arc(center = 1.5, 1.5 rotate= 45.) to ( 2.08, 2.08)
PLOTS
grid(x,y)
contour(V) as 'Potential'
surface(V) as 'Potential'
contour(Q) as 'Field Lines'
vector(-dx(V),-dy(V)) as 'Electric Field'
END
5.2.15.14 sav e
{ SAVE.PDE
select
ngrid=20
contourgrid=100 { use a very dense plot grid to show data structure }
Variables
u,v
definitions
k = 2
u0 = 1+x^2+y^2
s = cos(20*x)*cos(20*y)
save_s = save(s) { Used in a definition }
Initial values
u = 1
equations
U: u - div(K*grad(u)) = s
V: v - div(K*grad(v)) = save_s
boundaries
region 1
start(-1,-1)
value(u)=u0 value(v)=u0
line to (1,-1) to (1,1) to (-1,1) to close
region 2
k=4
start(-1,-1) line to (0,-1) to (0,0) to (-1,0) to close
plots
grid(x,y)
contour(u)
597 FlexP DE 7 : Sample P roblems
contour(v)
contour(s)
contour(save_s)
elevation(s, save_s) from(-1,0) to (1,0)
end
5.2.15.15 spacetim e1
{ SPACETIME1.PDE
This example illustrates the use of FlexPDE to solve an initial value problem
of 1-D transient heatflow as a 2D boundary-value problem.
Here the spatial coordinate is represented by X, the time coordinate by Y,
and the temperature by u(x,y).
boundaries
Region 1
start(0,0)
value(u)=ut0 { set the t=0 temperature }
line to (1,0)
value(u) = 0 { always cold at x=1 }
line to (1,1)
natural(u) = 0 { no sources at t=1 }
line to (0,1)
value(u) = 0 { always cold at x=0 }
line to close
monitors
contour(u)
plots
contour(u)
surface(u)
contour(u-u0) as "error"
end
5.2.15.16 spacetim e2
{ SPACETIME2.PDE
5.2.15.17 spline_boundary
{ SPLINE_BDRY.PDE
This example shows the use of the SPLINE 210 statement in constructing boundary curves.
A circular arc is approximated by five spline segments.
The end segments are made very short to establish the proper slope at the ends.
The problem solves a heatflow equation on a quarter circle and compares the solution
with the analytic value.
}
title 'Spline Boundary'
Variables
u
definitions
k = 1
u0 = 1-r^2
s = 4
equations
U: div(k*grad(u)) + s = 0
boundaries
Region 1
start(0,0)
natural(u) = 0 line to (1,0)
value(u)=0
spline to(0.99985,0.01745) ! short initial interval to establish slope
to (0.866,0.5)
to(0.5,0.866)
to (0.01745,0.99985) ! short final interval to establish slope
to (0,1)
natural(u)=0 line to close
monitors
grid(x,y)
contour(u)
contour(u-u0)
plots
grid(x,y)
contour(u)
contour(u-u0)
end
Sample P roblems : Usage 600
Variables
u
equations
U: div(grad(u)) + 4 = 0;
boundaries
region 1
start(0,0)
value(u)=0
line to (width,0) to (width,2) to (0,2) to close
monitors
contour(u)
plots
grid(x,y)
surface(u)
contour(u)
histories
history(integral(u)) vs width as "Integral vs width"
end
5.2.15.19 stages
{ STAGES.PDE
This example demonstrates the use of staging to solve a problem for a range of
parameters.
We stage both the equation parameters and the solution ERRLIM 187 .
The problem is a nonlinear test, which solves a modified steady-state Burgers
equation.
}
title 'Staged Problem'
select
stages = 3 { run only the first three of the listed stages }
errlim = staged(0.01, 0.001, 0.0005)
Variables
u
definitions
scale = staged(1, 2, 4, 8) { extra value ignored }
a = 1/scale
Initial values
u = 1 - (x-1)^2 - (y-1)^2
equations
U: div(a*grad(u)) + scale*u*dx(u) +4 = 0;
601 FlexP DE 7 : Sample P roblems
boundaries
region 1
start(0,0)
value(u)=0
line to (2,0) to (2,2) to (0,2) to close
monitors
contour(u)
plots
surface(u) report scale as "Scale"
contour(u) report scale as "Scale"
histories
history(integral(u)) vs scale as "Ingegral vs Scale"
end
5.2.15.20 tabulate
{ TABULATE.PDE
This problem tabulates an arithmetic expression into a data table.
The structure of the inline tabulate command is:
TABULATE <range_controls> : <expression>
The <range_control> clause is
VERSUS <name> ( <list_specification> )
or
FOR <name> ( <list_specification> )
variables
u
definitions
alpha =tabulate versus x(0 by 0.1 to 10)
versus y(0 by 0.1 to 10)
: sin(x)*sin(y)+1.1
xar =array (0 by 0.1 to 10)
beta =spline tabulate for x(xar)
for y(0 by 0.1 to 10)
: sin(x)*sin(y)+1.1
p = x
q = p+y
s = y^2*(p+q)
equations
U: div(beta*grad(u)) + alpha = 0
boundaries
region 1
start(0,10)
value(u) = 0
line to (0,0) to (10,0) to (10,10) to close
monitors
contour(u)
Sample P roblems : Usage 602
plots
grid(x,y) as "computation mesh"
contour(u) as "solution"
surface(u) as "solution"
contour(alpha) as "tabulated data" export file='alpha.tbl'
contour(beta) as "spline-tabulated data"
contour(alpha-beta) as "linear-spline difference"
vector(grad(alpha)) as "table gradient"
vector(grad(beta)) as "spline gradient"
surface(alpha) as "tabulated data"
surface(beta) as "spline data"
table(alpha)
table(s)
vtk(beta)
contour(space_error())
end
5.2.15.21 tensors
{ TENSORS.PDE
Title
"vector functions"
Definitions
v1 = vector(1,2,3)
v2 = vector(3,2,1)
vv = v1*v2 ! vector product
t1 = tensor((1,2,3),(4,5,6),(7,8,9))
t2 = tensor((1,4,7),(2,5,8),(3,6,9))
t12 = t1**t2 ! dot product
dot12 = dot(t1,t2)
dot1v = dot(t1,v1)
dotv1 = dot(v1,t1)
dotv2 = dot(v1,t2)
dot12v = dot(dot12,v1)
Plots
summary ("OPERATIONS WITH A TENSOR RESULT :")
report ""
report "Vector product V1 * V2"
report "(1,2,3) * (3,2,1) = ((3,2,1), (6,4,2), (9,6,3))"
report ""
report(xxcomp(vv), xycomp(vv), xzcomp(vv)) as "VV xx,xy,xz "
report(yxcomp(vv), yycomp(vv), yzcomp(vv)) as "VV yx,yy,yz "
report(zxcomp(vv), zycomp(vv), zzcomp(vv)) as "VV zx,zy,zz "
report ""
report "Tensor dot product T1 ** T2"
report "((1,2,3), (4,5,6), (7,8,9)) ** ((1,4,7), (2,5,8), (3,6,9))"
report " = ((14,32,50), (32,77,122), (50,122,194))"
report(xxcomp(t12), xycomp(t12), xzcomp(t12)) as "T12 xx,xy,xz "
report(yxcomp(t12), yycomp(t12), yzcomp(t12)) as "T12 yx,yy,yz "
report(zxcomp(t12), zycomp(t12), zzcomp(t12)) as "T12 zx,zy,zz "
report ""
report "Tensor dot product DOT( T1, T2 )"
report "((1,2,3), (4,5,6), (7,8,9)) ** ((1,4,7), (2,5,8), (3,6,9))"
report " = ((14,32,50), (32,77,122), (50,122,194))"
report ""
603 FlexP DE 7 : Sample P roblems
End
5.2.15.22 two_histories
{ TWO_HISTORIES.PDE
variables
temp (threshold=100)
definitions
k = 0.85 {thermal conductivity}
cp = 1 { heat capacity }
long = 18
H = 0.4 {free convection boundary coupling}
Ta = 25 {ambient temperature}
A = 4500 {amplitude}
source = A*exp(-((z-1*t)/.5)^2)*(200/(t+199))
initial value
temp = Ta
equations
temp: div(k*grad(temp)) + source = cp*dt(temp)
boundaries
region 1
start(0,0)
natural(temp) = 0 line to (long,0)
value(temp) = Ta line to (long,1)
natural(temp) = -H*(temp - Ta) line to (0,1)
Sample P roblems : Usage 604
histories
history(temp,dt(temp)) at (5,0) (10,0) (15,0)
history(temp,dt(temp)) at (5,0) (10,0) (15,0) window = 5 ! moving window
history(temp,dt(temp)) at (5,0) (10,0) (15,0) window(3,8) ! fixed window
history(integral(temp),integral(dt(temp)))
end
5.2.16 Moving_Mesh
5.2.16.1 1d_stretch_x
{ 1D_STRETCH_X.PDE
VARIABLES
u
xm = move(x)
DEFINITIONS
Hl = 1
gwid = 0.15
u0 = exp(-x^2/gwid^2)
lmove = Hl + t
vx = dt(xm)
INITIAL VALUES
u = u0
dt(xm) = x/Hl
EULERIAN EQUATIONS
U: dt(u)=0
Xm: div(grad(vx))=0
BOUNDARIES
REGION 1
{ In 1D, "point" boundary conditions must FOLLOW the point at which
they are to be applied: }
START(-Hl) point value(u)=0 point value(xm)= -lmove
Line to (Hl) point value(u)=0 point value(xm)= lmove
TIME 0 TO 0.5 by 0.01
MONITORS
for cycle=1
605 FlexP DE 7 : Sample P roblems
END
5.2.16.2 2d_blob_position
{ 2D_BLOB_POSITION.PDE
See 2D_BLOB_VELOCITY.PDE 606 for a version that uses mesh velocity variables.
}
TITLE 'Pulsating circle in 2D - position specification'
COORDINATES
cartesian2
VARIABLES
Phi { the temperature }
Xm = MOVE(x) { surrogate X }
Ym = MOVE(y) { surrogate Y }
DEFINITIONS
K = 1 { default conductivity }
R0 = 0.75 { initial blob radius }
Um = dt(Xm)
Vm = dt(Ym)
INITIAL VALUES
Phi = (y+1)/2
EULERIAN EQUATIONS
Phi: Div(-k*grad(phi)) = 0
Xm: div(grad(Xm)) = 0
Ym: div(grad(Ym)) = 0
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0
VELOCITY(Xm)=0 VELOCITY(Ym)=0
LINE TO (1,-1)
NATURAL(Phi)=0
LINE TO (1,1)
VALUE(Phi)=1
LINE TO (-1,1)
NATURAL(Phi)=0
LINE TO CLOSE
REGION 2 'blob' { the embedded blob }
k = 0.001
START 'ring' (R0,0)
VELOCITY(Xm) = -0.25*sin(t)*x/r
VELOCITY(Ym) = -0.25*sin(t)*y/r
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
TIME 0 TO 2*pi
MONITORS
for cycle=1
grid(x,y)
Sample P roblems : Usage 606
contour(phi)
PLOTS
FOR T = 0 BY pi/20 TO 2*pi
GRID(x,y)
CONTOUR(Phi) notags nominmax
VECTOR(-k*grad(Phi))
CONTOUR(magnitude(Um,Vm))
VECTOR(Um,Vm) fixed range(0,0.25)
ELEVATION(Phi) FROM (0,-1) to (0,1)
ELEVATION(Normal(-k*grad(Phi))) ON 'ring'
END
See 2D_BLOB_POSITION.PDE 605 for a version that uses no mesh velocity variables.
}
TITLE 'Pulsating circle in 2D - velocity specification'
COORDINATES
cartesian2
VARIABLES
Phi { the temperature }
Xm = MOVE(x) { surrogate X }
Ym = MOVE(y) { surrogate Y }
Um(0.1) { mesh x-velocity }
Vm(0.1) { mesh y-velocity }
DEFINITIONS
K = 1 { default conductivity }
R0 = 0.75 { initial blob radius }
INITIAL VALUES
Phi = (y+1)/2
EULERIAN EQUATIONS
Phi: Div(-k*grad(phi)) = 0
Xm: dt(Xm) = Um
Ym: dt(Ym) = Vm
Um: div(grad(Um)) = 0
Vm: div(grad(Vm)) = 0
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=0
VELOCITY(Xm)=0 VELOCITY(Ym)=0
VALUE(Um)=0 VALUE(Vm)=0
LINE TO (1,-1)
NATURAL(Phi)=0
LINE TO (1,1)
VALUE(Phi)=1
LINE TO (-1,1)
NATURAL(Phi)=0
LINE TO CLOSE
REGION 2 'blob' { the embedded blob }
k = 0.001
START 'ring' (R0,0)
VELOCITY(Xm) = Um
VELOCITY(Ym) = Vm
VALUE(Um) = -0.25*sin(t)*x/r
VALUE(Vm) = -0.25*sin(t)*y/r
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
TIME 0 TO 2*pi
607 FlexP DE 7 : Sample P roblems
MONITORS
for cycle=1
grid(x,y)
contour(phi)
PLOTS
FOR T = 0 BY pi/20 TO 2*pi
GRID(x,y)
CONTOUR(Phi) notags nominmax
VECTOR(-k*grad(Phi))
CONTOUR(magnitude(Um,Vm))
VECTOR(Um,Vm) fixed range(0,0.25)
ELEVATION(Phi) FROM (0,-1) to (0,1)
ELEVATION(Normal(-k*grad(Phi))) ON 'ring'
END
5.2.16.4 2d_lagrangian_shock
{ 2D_LAGRANGIAN_SHOCK.PDE
This example demonstrates moving meshes in 2D by solving Sod's shock tube problem
(a 1D problem) on a 2D moving mesh.
Mesh nodes are given the local fluid velocity, so the model is fully Lagrangian.
Ref: G.A. Sod, "A Survey of Several Finite Difference Methods for Systems of
Nonlinear
Hyperbolic Conservation Laws", J. Comp. Phys. 27, 1-31 (1978)
See also Kershaw, Prasad and Shaw, "3D Unstructured ALE Hydrodynamics with the
Upwind Discontinuous Finite Element Method", UCRL-JC-122104, Sept 1995.
Other versions of this problem can be found in the "Applications | Fluids" 377 folder.
}
TITLE "Sod's Shock Tube Problem - 2D Lagrangian"
SELECT
ngrid= 100
regrid=off
VARIABLES
rho(1)
u(1)
P(1)
xm=move(x)
DEFINITIONS
len = 1
wid = 0.01
gamma = 1.4
{ define a damping term to kill unwanted oscillations }
eps = 0.001
v = 0
rho0 = 1.0 - 0.875*uramp(x-0.49, x-0.51)
p0 = 1.0 - 0.9*uramp(x-0.49, x-0.51)
INITIAL VALUES
rho = rho0
u = 0
P = p0
EULERIAN EQUATIONS
{ equations are stated as appropriate to the Eulerian (lab) frame.
FlexPDE will add motion terms to convert to Lagrangian form for moving mesh }
{ since the equation is really in x only, we add dyy(.) terms with natural(.)=0
on the sidewalls to impose uniformity across the fictitious y coordinate }
rho: dt(rho) + u*dx(rho) + rho*dx(u) = dyy(rho) + eps*dxx(rho)
u: dt(u) + u*dx(u) + dx(P)/rho = dyy(u) + eps*dxx(u)
Sample P roblems : Usage 608
MONITORS
for cycle=5
grid(x,10*y)
elevation(rho) from(0,wid/2) to (len,wid/2) range (0,1)
elevation(u) from(0,wid/2) to (len,wid/2) range (0,1)
elevation(P) from(0,wid/2) to (len,wid/2) range (0,1)
PLOTS
for t=0 by 0.02 to 0.143, 0.16 by 0.02 to 0.375
grid(x,10*y)
elevation(rho) from(0,wid/2) to (len,wid/2) range (0,1)
elevation(u) from(0,wid/2) to (len,wid/2) range (0,1)
elevation(P) from(0,wid/2) to (len,wid/2) range (0,1)
END
{ 2D_MOVEPOINT.PDE
A point defined by name as a MOVABLE POINT 208 and used in the definition of the domain
will move
with the mesh.
Any point declared explicitly or not used in the domain definition will remain fixed.
}
TITLE "stretching brick"
SELECT
regrid=off
VARIABLES
u
xm = move(x)
ym = move(y)
DEFINITIONS
Hl = 1/2
gwid = 0.15
u0= exp(-(x^2+y^2)/gwid^2)
lmove = Hl + t
ms = gwid^2/u0
vx = dt(xm)
vy = dt(ym)
P = movable point(Hl,Hl)
Q = movable point(0.1,0)
R = point(-0.2,-0.2)
INITIAL VALUES
u= u0
dt(xm) = x/Hl
609 FlexP DE 7 : Sample P roblems
dt(ym) = y/Hl
EQUATIONS
U: dt(u)=0
Xm: div(grad(vx))=0
Ym: div(grad(vy))=0
BOUNDARIES
REGION 1
mesh_spacing = ms
START(-Hl,-Hl)
value(u) = 0 nobc(xm) value(ym)=-lmove
Line to (Hl,-Hl)
value(u)=0 value(xm)=lmove nobc(ym)
line to P
value(u)=0 nobc(xm) value(ym) = lmove
line to (-Hl,Hl)
value(u)=0 value(xm)=-lmove nobc(ym)
line to close
NODE POINT Q
MONITORS
for cycle=1
grid(x,y) zoom(-Hl-1/2,-Hl-1/2, 2*Hl+1,2*Hl+1)
grid(x,y) zoom(-0.6,0.4, 0.2,0.2)
contour(vx) zoom(-0.6,0.4, 0.2,0.2)
contour(vy) zoom(-0.6,0.4, 0.2,0.2)
contour(u)
elevation(u,u0) from(-10*Hl,0) to (10*Hl,0) range (0,1)
elevation(u,u0) from(0,-10*Hl) to (0,10*Hl) range (0,1)
PLOTS
for time=0.1 by 0.1 to endtime
grid(x,y) zoom(-Hl-1/2,-Hl-1/2, 2*Hl+1,2*Hl+1)
report(distance(P,(0.2,0)))
contour(u)
contour(u-u0) as "True Total Error"
contour(space_error()) as "Estimated Step Error" painted
elevation(u,u0) from(-10*Hl,0) to (10*Hl,0) range (0,1)
elevation(vx) from(-10*Hl,0) to (10*Hl,0) range (0,1)
elevation(u,u0) from(0,-10*Hl) to (0,10*Hl) range (0,1)
elevation(vy) from(0,-10*Hl) to (0,10*Hl) range (0,1)
History(u) at P,Q, (0.2,0) as "Points a(P) and b(Q) move with the mesh, c(0.2,0) is
fixed in space"
History(u,u0) at R,(-0.2,-0.2) as "both points are fixed in space"
History(distance(P,R)) ! both are movable points, so the distance changes as the mesh
moves
at P,R ! name the points to get markers on the domain
History(time_error())
END
5.2.16.6 2d_stretch_x
{ 2D_STRETCH_X.PDE
}
TITLE "2D brick stretching in x"
VARIABLES
u
xm = move(x)
DEFINITIONS
Hl = 1/2
wid = 0.01
gwid = 0.15
u0 = exp(-x^2/gwid^2)
lmove = Hl + t
vx = dt(xm)
INITIAL VALUES
u = u0
dt(xm) = x/Hl
EULERIAN EQUATIONS
U: dt(u)=0
Xm: div(grad(vx)) = 0
BOUNDARIES
REGION 1
START(-Hl,0) line to (Hl,0)
value(u)=0 value(xm)=lmove line to (Hl,wid)
natural(u)=0 nobc(xm) line to (-Hl,wid)
value(u)=0 value(xm)=-lmove line to close
TIME 0 TO 0.5 by 0.01
MONITORS
for time=0
grid(x,10*y) as "Initial mesh"
contour(vx)
for cycle=1
grid(x,10*y)
contour(u) zoom(-2*Hl,0, 4*Hl,2*wid)
contour(vx) zoom(-2*Hl,0, 4*Hl,2*wid)
contour(dt(xm)) zoom(-2*Hl,0, 4*Hl,2*wid)
elevation(u,u0) from(-10*Hl,wid/2) to (10*Hl,wid/2) range (0,1)
elevation(vx) from(-10*Hl,wid/2) to (10*Hl,wid/2) range (0,1)
elevation(dt(xm)) from(-10*Hl,wid/2) to (10*Hl,wid/2) range (0,1)
PLOTS
for time=0.1 by 0.1 to endtime
grid(x,10*y)
contour(u) zoom(-2*Hl,0, 4*Hl,2*wid)
contour(vx) zoom(-2*Hl,0, 4*Hl,2*wid)
contour(dt(xm)) zoom(-2*Hl,0, 4*Hl,2*wid)
elevation(u,u0) from(-10*Hl,wid/2) to (10*Hl,wid/2) range (0,1)
END
5.2.16.7 2d_stretch_x y
{ 2D_STRETCH_XY.PDE
Output plots show that the Gaussian has retained its shape as
it moves through the mesh.
SELECT
regrid=off
VARIABLES
u
xm = move(x)
ym = move(y)
DEFINITIONS
Hl = 1/2
gwid = 0.15
u0 = exp(-(x^2+y^2)/gwid^2)
lmove = Hl + t
ms = gwid^2/u0
vx = dt(xm)
vy = dt(ym)
INITIAL VALUES
u = u0
dt(xm) = x/Hl
dt(ym) = y/Hl
EULERIAN EQUATIONS
U: dt(u)=0
Xm: div(grad(vx))=0
Ym: div(grad(vy))=0
BOUNDARIES
REGION 1
mesh_spacing = ms
START(-Hl,-Hl)
value(u)=0 nobc(xm) value(ym)=-lmove
line to (Hl,-Hl)
value(u)=0 value(xm)=lmove nobc(ym)
line to (Hl,Hl)
value(u)=0 nobc(xm) value(ym)=lmove
line to (-Hl,Hl)
value(u)=0 value(xm)=-lmove nobc(ym)
line to close
MONITORS
for cycle=1
grid(x,y) zoom(-Hl-1/2,-Hl-1/2, 2*Hl+1,2*Hl+1)
contour(u)
elevation(u,u0) from(-10*Hl,0) to (10*Hl,0) range (0,1)
elevation(u,u0) from(0,-10*Hl) to (0,10*Hl) range (0,1)
PLOTS
for time=0.1 by 0.1 to endtime
grid(x,y) zoom(-Hl-1/2,-Hl-1/2, 2*Hl+1,2*Hl+1)
contour(u)
contour(u-u0) as "True Total Error"
contour(space_error()) as "Estimated Step Error"
elevation(u,u0) from(-10*Hl,0) to (10*Hl,0) range (0,1)
elevation(vx) from(-10*Hl,0) to (10*Hl,0) range (0,1)
elevation(u,u0) from(0,-10*Hl) to (0,10*Hl) range (0,1)
elevation(vy) from(0,-10*Hl) to (0,10*Hl) range (0,1)
END
Sample P roblems : Usage 612
5.2.16.8 3d_blob_position
{ 3D_BLOB_POSITION.PDE
See 3D_BLOB_VELOCITY.PDE 613 for a version that uses mesh velocity variables.
}
TITLE 'Pulsating circle in 3D - position specification'
COORDINATES
cartesian3
VARIABLES
Phi { the temperature }
Xm = MOVE(x) { surrogate X }
Ym = MOVE(y) { surrogate Y }
Zm = MOVE(z) { surrogate Z }
DEFINITIONS
K = 1 { default conductivity }
R0 = 0.75 { initial blob radius }
zsphere = SPHERE ((0,0,0),R0)
z1, z2
Um = dt(Xm)
Vm = dt(Ym)
Wm = dt(Zm)
INITIAL VALUES
Phi = (z+1)/2
EULERIAN EQUATIONS
Phi: Div(-k*grad(phi)) = 0
Xm: div(grad(Xm)) = 0
Ym: div(grad(Ym)) = 0
Zm: div(grad(Zm)) = 0
EXTRUSION
SURFACE 'Bottom' z = -1
SURFACE 'Sphere Bottom' z=z1
SURFACE 'Sphere Top' z=z2
SURFACE 'Top' z=1
BOUNDARIES
SURFACE 1
VALUE(Phi)=0 VELOCITY(Xm)=0 VELOCITY(Ym)=0 VELOCITY(Zm)=0
SURFACE 4
VALUE(Phi)=1 VELOCITY(Xm)=0 VELOCITY(Ym)=0 VELOCITY(Zm)=0
REGION 1 'box'
z1=0 z2=0
START(-1,-1)
NATURAL(Phi)=0 VELOCITY(Xm)=0 VELOCITY(Ym)=0 VELOCITY(Zm)=0
LINE TO (1,-1) TO (1,1) TO (-1,1) TO CLOSE
LIMITED REGION 2 'blob' { the embedded blob }
z1 = -zsphere
z2 = zsphere
layer 2 k = 0.001
SURFACE 2
VELOCITY(Xm) = -0.25*sin(t)*x/r
VELOCITY(Ym) = -0.25*sin(t)*y/r
VELOCITY(Zm) = -0.25*sin(t)*z/r
SURFACE 3
VELOCITY(Xm) = -0.25*sin(t)*x/r
VELOCITY(Ym) = -0.25*sin(t)*y/r
VELOCITY(Zm) = -0.25*sin(t)*z/r
START 'ring' (R0,0)
ARC(CENTER=0,0) ANGLE=360 TO CLOSE
TIME 0 TO 2*pi by pi/20
613 FlexP DE 7 : Sample P roblems
MONITORS
FOR cycle=1
GRID(x,y,z) ON 'blob' ON LAYER 2
CONTOUR(phi) ON y=0
PLOTS
FOR T = 0 BY pi/20 TO 2*pi
GRID(x,y,z) ON 'blob' ON LAYER 2 FRAME(-R0,-R0,-R0, 2*R0,2*R0,2*R0)
CONTOUR(Phi) notags nominmax ON y=0
VECTOR(-k*grad(Phi)) ON y=0
CONTOUR(magnitude(Um,Vm,Wm)) ON y=0
VECTOR(Um,Wm) ON y=0 FIXED RANGE(0,0.25)
ELEVATION(Phi) FROM (0,0,-1) TO (0,0,1)
ELEVATION(magnitude(Um,Vm,Wm)) FROM (0,0,-1) TO (0,0,1)
END
See 3D_BLOB_POSITION.PDE 612 for a version that uses no mesh velocity variables.
}
TITLE 'Pulsating circle in 3D - velocity specification'
COORDINATES
cartesian3
VARIABLES
Phi { the temperature }
Xm = MOVE(x) { surrogate X }
Ym = MOVE(y) { surrogate Y }
Zm = MOVE(z) { surrogate Z }
Um(0.1) { mesh x-velocity }
Vm(0.1) { mesh y-velocity }
Wm(0.1) { mesh z-velocity }
DEFINITIONS
K = 1 { default conductivity }
R0 = 0.75 { initial blob radius }
INITIAL VALUES
Phi = (z+1)/2
EULERIAN EQUATIONS
Phi: Div(-k*grad(phi)) = 0
Xm: dt(Xm) = Um
Ym: dt(Ym) = Vm
Zm: dt(Zm) = Wm
Um: div(grad(Um)) = 0
Vm: div(grad(Vm)) = 0
Wm: div(grad(Wm)) = 0
EXTRUSION
SURFACE 'Bottom' z = -1
SURFACE 'Sphere Bottom' z=z1
SURFACE 'Sphere Top' z=z2
SURFACE 'Top' z=1
BOUNDARIES
SURFACE 1
VALUE(Phi)=0 VELOCITY(Xm)=0 VELOCITY(Ym)=0 VELOCITY(Zm)=0
VALUE(Um)=0 VALUE(Vm)=0 VALUE(Wm)=0
Sample P roblems : Usage 614
SURFACE 4
VALUE(Phi)=1 VELOCITY(Xm)=0 VELOCITY(Ym)=0 VELOCITY(Zm)=0
VALUE(Um)=0 VALUE(Vm)=0 VALUE(Wm)=0
REGION 1 'box'
z1=0 z2=0
START(-1,-1)
NATURAL(Phi)=0
VELOCITY(Xm)=0 VELOCITY(Ym)=0 VELOCITY(Zm)=0
VALUE(Um)=0 VALUE(Vm)=0 VALUE(Wm)=0
LINE TO (1,-1) TO (1,1) TO (-1,1) TO CLOSE
TIME 0 TO 2*pi
MONITORS
FOR cycle=1
GRID(x,y,z) ON 'blob' ON LAYER 2
CONTOUR(phi) ON y=0
PLOTS
FOR T = 0 BY pi/20 TO 2*pi
GRID(x,y,z) ON 'blob' ON LAYER 2
CONTOUR(Phi) notags nominmax ON y=0
VECTOR(-k*grad(Phi)) ON y=0
CONTOUR(magnitude(Um,Vm,Wm)) ON y=0
VECTOR(Um,Wm) ON y=0 FIXED RANGE(0,0.25)
ELEVATION(Phi) FROM (0,0,-1) TO (0,0,1)
ELEVATION(magnitude(Um,Vm,Wm)) FROM (0,0,-1) TO (0,0,1)
END
5.2.17 ODE
5.2.17.1 linearode
{ LINEARODE.PDE
This example shows the application of FlexPDE to the solution of a linear
first-order differential equation.
We select the simple example
dH/dt = a - b*H
This equation has the exact solution
H(t) = H(0)*exp(-b*t) + (a/b)*(1-exp(-b*t))
The existence of an exact solution allows us to analyze the errors
in the FlexPDE solution.
Since FlexPDE requires a spatial domain, we solve the system over
a simple box with minimum mesh size.
}
title
"FIRST ORDER ORDINARY DIFFERENTIAL EQUATION"
615 FlexP DE 7 : Sample P roblems
select
{ Since no spatial information is required, use the minimum grid }
ngrid=1
errlim = 1e-4
variables
{ declare Height to be the system variable }
Height(threshold=1)
definitions
{ define the equation parameters }
a = 2
b = 0.1
H0 = 100
{ define the exact solution: }
Hexact = H0*exp(-b*t) + (a/b)*(1-exp(-b*t))
initial values
Height = H0
equations
Height : dt(Height) = a - b*Height { The ODE }
boundaries
region 1
start (0,0)
line to (1,0) to (1,1) to (0,1) to close
time 0 to 100
plots
for time = 0,1,10 by 10 to 100
{ Plot the solution: }
history(Height) at (0.5,0.5)
{ Plot the error check: }
history((Height-Hexact)/Hexact) at (0.5,0.5) as "Relative Error"
end
5.2.17.2 nonlinode
{ NONLINODE.PDE
This example shows the application of FlexPDE to the solution of a
non-linear first-order differential equation.
A liquid flows into the top of a reactor vessel through an unrestricted
pipe and exits from the bottom through a choke value. This problem is
discussed in detail in Silebi and Schiesser.
definitions
{ define the equation parameters }
a = 2
b = 0.1
H0 = 100
{ define the accuracy check }
T0 = sqrt(H0) + (a/b)*ln(a-b*sqrt(H0))
Tcheck = sqrt(Height) + (a/b)*ln(a-b*sqrt(Height))
initial values
Height = H0
equations { The ODE }
Height : dt(Height) = a - b*sqrt(Height)
boundaries
{ define a fictitious spatial domain }
region 1
start (0,0)
line to (1,0) to (1,1) to (0,1) to close
{ define the time range }
time 0 to 1000
plots
for t=0, 1, 10 by 10 to endtime
{ Plot the solution: }
history(Height) at (0.5,0.5)
{ Plot the accuracy check: }
history((T0 - Tcheck - (b/2)*t)/((b/2)*t)) at (0.5,0.5)
as "Relative Error"
end
5.2.17.3 second_order_tim e
{ SECOND_ORDER_TIME.PDE
This example shows the integration of Bessel's Equation as a test of the
time integration capabilities of FlexPDE.
Bessel's Equation for order zero can be written as
t^2*dtt(w) + t*dt(w) + t^2*w = 0
Dividing by t^2 and avoiding the pole at t=0, we can write
dtt(w) + dt(w)/t + w = 0
FlexPDE cannot directly integrate second order time equations, so we define an
auxiliary variable v=dt(w) and write a coupled pair of equations
dt(v) + v/t + w = 0
dt(w) = v
We use a dummy spatial grid of two cells and solve the equation at each node.
You can try varying the value given for ERRLIM 187 to see how it behaves.
}
title "Integration of Bessel's Equation"
select
ngrid=1
errlim=1e-4 { increase accuracy to prevent accumulation of errors }
Variables
v (threshold=0.1)
w (threshold=0.1)
definitions
L = sqrt(2)
t0 = 0.001 { Start integration at t=0.001 }
Initial values { Initialize to known values at t=t0 }
w = 1-2.25*(t0/3)^2
v = -0.5*t0 + 0.5625*t0*(t0/3)^2
617 FlexP DE 7 : Sample P roblems
equations
v: dt(v) +v/t + w = 0
w: dt(w) = v
boundaries
region 1
start(-L,-L) line to (L,-L) to (L,L) to (-L,L) to close
time 0.001 to 4*pi { Exclude t=0 }
plots
for t=0.01 by 0.01 to 0.1 by 0.1 to 1 by 1 to endtime
history(w,bessj(0,t)) at (0,0) as "W(t) and BESSJ0(t)"
history(w-bessj(0,t)) at (0,0) as "Absolute Error"
history(v,-bessj(1,t)) at (0,0) as "V(t) and dt(BESSJ0(t))"
history(v+bessj(1,t)) at (0,0) as "Slope Error"
history(deltat)
end
5.2.18 Optimization
5.2.18.1 criticality
{ CRITICALITY.PDE
FlexPDE implements the Nelder-Mead "amoeba" algorithm to minimize 243 or maximize 242 an
objective function.
This is not the method of greatest speed, but it is very flexible, and allows FlexPDE
to perform
optimization searches in a wide range of problem environments.
variables
N { neutron Density }
select
modes=1 { calculate only the smallest eigenvalue }
cell_limit=2000
definitions
source { name the material parameters, values will be declared by region }
sigmat { transport cross-section }
sigmar { removal cross-section }
sigmaf { fission cross-section }
boundaries
monitors
contour(N) as "Neutron Density"
history(lambda,mix, convergence) report(convergence) report(lambda) report(mix)
plots
grid(x,y)
contour(N) as 'Neutron Density' report(mix) report(lambda) report(mix)
surface(N) as 'Neutron Density'
vector(-beta/sigmat*grad(N)) as 'Neutron Flux'
contour(mix*sigmaf*nper*N) as "Fission Source"
contour(sigmar*N) as "Neutron Absorption"
end
{ CRITICALITY_SIZE.PDE
This problem demonstrates the use of FlexPDE in the solution of optimization
problems.
FlexPDE implements the Nelder-Mead "amoeba" algorithm to minimize 243 or maximize 242 an
objective function.
This is not the method of greatest speed, but it is very flexible, and allows FlexPDE
to perform
optimization searches in a wide range of problem environments.
In this probem, we use the "mix" parameter discovered in CRITICALITY.PDE 617 and solve
for the critical size of the assembly.
select
modes=1 { calculate only the smallest eigenvalue }
cell_limit=2000
definitions
source { name the material parameters, values will be declared by region }
sigmat { transport cross-section }
sigmar { removal cross-section }
sigmaf { fission cross-section }
beta = 1/3 { Fick's Law proportionality factor }
nper = 2 { number of neutrons produced per fission }
convergence = (lambda-1)^2 { optimization parameter: a function with a smooth
minimum at lambda=1 }
Hw { the outer halfwidth of the structure }
box = 3*Hw/5 { the halfwith of the reactive inclusion }
mix = 0.086052 { as reported by CRITICALITY.PDE }
end
5.2.18.3 power_control
{ POWER_CONTROL.PDE
This example shows the use of the MINIMIZE 243 optimization feature. It is
analogous to the APPLICATIONS/CONTROL/CONTROL_STEADY.PDE 367 example.
We wish to find the required power input to a heater, such that the resulting
average temperature over the domain is a specified value.
}
VARIABLES
temp { The temperature field }
DEFINITIONS
setpoint=700 { the desired average temperature }
skintemp=325 { fixed outer boundary temperature }
k=1 { conductivity }
heat=0 { the heat function for the temperature.
it is non-zero only in the heater region }
INITIAL VALUES
temp = setpoint
EQUATIONS
temp: div(-k*grad(temp))-heat = 0 { diffusion of temperature field }
BOUNDARIES
REGION 'Insulation'
k=0.1
heat=0
start(-4,-4)
value(temp)=skintemp
line to (4,-4) to (4,4) to (-4,4) to close
REGION 'Heater'
k=50
heat=power
start(-1,-1) line to (1,-1) to (1,1) to (-1,1) to close
MONITORS
contour(temp)
report power
report tcontrol
History(abs(tcontrol-setpoint),power)
PLOTS
621 FlexP DE 7 : Sample P roblems
contour(temp)
report power
report power*integral(1,'heater') as "Total Power"
report tcontrol as "Average Temp"
elevation(temp) from(-4,0) to (4,0)
History(abs(tcontrol-setpoint),power)
Summary
report power*integral(1,'heater') as "Total Power needed to establish an average
temperature of 700 "
END
5.2.18.4 size_control
{ SIZE_CONTROL.PDE
This example shows the use of the MINIMIZE 243 optimization feature applied to geometric
size.
We wish to find the correct size of a heater with fixed power input, such that the
resulting
average temperature over the domain is a specified value.
}
VARIABLES
temp { The temperature field }
DEFINITIONS
setpoint=700 { the desired average temperature }
skintemp=325 { fixed outer boundary temperature }
k=1 { conductivity }
heat=0 { the heat function for the temperature.
it is non-zero only in the heater region }
INITIAL VALUES
temp = setpoint
EQUATIONS
temp: div(-k*grad(temp))-heat = 0 { diffusion of temperature field }
BOUNDARIES
REGION 'Insulation'
k=0.1
heat=0
start(-4,-4)
value(temp)=skintemp
line to (4,-4) to (4,4) to (-4,4) to close !fixed outer size
REGION 'Heater'
Sample P roblems : Usage 622
k=50
heat=power/integral(1,'Heater') ! convert total power to power density
start(-len,-len) line to (len,-len) to (len,len) to (-len,len) to close
MONITORS
contour(temp)
report power
report tcontrol
History(abs(tcontrol-setpoint),len)
PLOTS
contour(temp)
report len
report tcontrol as "Average Temp"
elevation(temp) from(-4,0) to (4,0)
History(abs(tcontrol-setpoint),len)
History(len)
Summary report len as "Length needed to establish an average temperature of 700 "
END
5.2.19 Periodicity
5.2.19.1 3d_antiperiodic
{ 3D_ANTIPERIODIC.PDE
This example shows the use of FlexPDE in a 3D problem with azimuthal
anti-periodicity.
(See the example ANTIPERIODIC.PDE 625 for notes on antiperiodic boundaries.)
In this problem we create a repeated 45-degree segment of a ring.
}
title '3D AZIMUTHAL ANTIPERIODIC TEST'
coordinates cartesian3
Variables
u
definitions
k = 1
{ angular size of the repeated segment: }
an = pi/4
{ the sine and cosine for transformation }
crot = cos(an)
srot = sin(an)
H = 0
xc = 1.5
yc = 0.2
rc = 0.1
equations
u : div(K*grad(u)) + H = 0
extrusion z=0,0.4,0.6,1
boundaries
region 1
{ this line forms the remote boundary for the later periodic statement }
start(1,0) line to (2,0)
value(u) = 0 arc(center=0,0) to (2*crot,2*srot)
{ The following line segment is periodic under an angular rotation.
The mapping expressions take each point on the line into a corresponding
point in the base line. Note that although all the mapped y-coordinates
will be zero, we give the general expression so that the transformation
will be invertible. }
antiperiodic(x*crot+y*srot, -x*srot+y*crot)
line to (crot,srot)
623 FlexP DE 7 : Sample P roblems
value(u)=0
arc(center= 0,0) to close
limited region 2
layer 2 H = 1
start(xc-rc,0) line to (xc+rc,0) to (xc+rc,rc) to (xc-rc,rc) to close
limited region 3
layer 2 H = -1
start((xc-rc)*crot,(xc-rc)*srot)
line to ((xc+rc)*crot,(xc+rc)*srot)
to ((xc+rc)*crot+rc*srot,(xc+rc)*srot-rc*crot)
to ((xc-rc)*crot+rc*srot,(xc-rc)*srot-rc*crot) to close
monitors
grid(x,y,z)
contour(u) on z=0.1
contour(u) on z=0.5
contour(u) on z=0.9
plots
grid(x,y,z)
contour(u) on z=0.1 painted
contour(u) on z=0.5 painted
contour(u) on z=0.9 painted
end
The PERIODIC 240 statement appears in the position of a boundary condition, but
the syntax is slightly different, and the requirements and implications are
more extensive.
The syntax is:
PERIODIC(X_mapping,Y_mapping)
The mapping expressions specify the arithmetic required to convert a point
(X,Y) in the immediate boundary to a point (X',Y') on a remote boundary.
The mapping expressions must result in each point on the immediate boundary
mapping to a point on the remote boundary. Segment endpoints must map to
segment endpoints. The transformation must be invertible; do not specify
constants as mapped coordinates, as this will create a singular transformation.
The periodic boundary statement terminates any boundary conditions in effect,
and instead imposes equality of all variables on the two boundaries. It is
still possible to state a boundary condition on the remote boundary,
but in most cases this would be inappropriate.
The periodic statement affects only the next following LINE 226 or ARC 226 path.
These paths may contain more than one segment, but the next appearing
LINE or ARC statement terminates the periodic condition unless the periodic
statement is repeated.
In this problem, we have a heat equation with an off=center source in an irregular
figure. The figure is periodic in X, with Y faces held at zero, and Z-faces
insulated.
}
title '3D X-PERIODIC BOUNDARY TEST'
coordinates
cartesian3
Variables
u
definitions
k = 0.1
h=0
x0=0.5 y0=-0.2
x1=1.1 y1 = 0.2
Sample P roblems : Usage 624
equations
u : div(K*grad(u)) + h = 0
extrusion z=0,0.4,0.6,1
boundaries
region 1
start(-1,-1)
value(u)=0 line to (1,-1) { Force U=0 on Y=-1 }
{ The following arc is required to be a periodic image of an arc
two units to its left. (This image boundary has not yet been defined.) }
periodic(x-2,y) arc(center=-1,0) to (1,1)
value(u)=0 line to (-1,1) { Force U=0 on Y=1 }
{ The following arc provides the required image boundary for the previous
periodic statement }
nobc(u) { turn off the value BC }
arc(center= -3,0) to close
{ an off-center heat source in layer 2 provides the asymmetric conditions to
demonstrate the periodicity of the solution }
limited region 2
layer 2 h=10 k=10
start(x0,y0) line to (x1,y0) to (x1,y1) to (x0,y1) to close
monitors
contour(u) on z=0
contour(u) on z=0.5
contour(u) on z=1
contour(u) on y=0
plots
contour(u) on z=0 painted
contour(u) on z=0.5 painted
contour(u) on z=1 painted
contour(u) on y=0 painted
end
5.2.19.3 3d_zperiodic
{ 3D_ZPERIODIC.PDE
This example shows the use of FlexPDE in 3D applications with periodic
boundaries in the Z-direction.
boundaries
Region 1
start(-1,-1)
value(u)=0
line to (1,-1)
arc(center=-1,0) to (1,1)
line to (-1,1)
arc(center=-3,0) to close
5.2.19.4 antiperiodic
{ ANTIPERIODIC.PDE
This example shows the use of FlexPDE in applications with antiperiodic
boundaries.
The ANTIPERIODIC 240 statement appears in the position of a boundary condition, but
the syntax is slightly different, and the requirements and implications are
more extensive.
The syntax is:
ANTIPERIODIC(X_mapping,Y_mapping)
The mapping expressions specify the arithmetic required to convert a point
(X,Y) in the immediate boundary to a point (X',Y') on a remote boundary.
The mapping expressions must result in each point on the immediate boundary
mapping to a point on the remote boundary. Segment endpoints must map to
segment endpoints. The transformation must be invertible; do not specify
constants as mapped coordinates, as this will create a singular transformation.
The antiperiodic boundary statement terminates any boundary conditions in effect,
and instead imposes equality of all variables on the two boundaries. It is
still possible to state a boundary condition on the remote boundary,
but in most cases this would be inappropriate.
The antiperiodic statement affects only the next following LINE 226 or ARC 226 path.
These paths may contain more than one segment, but the next appearing
LINE or ARC statement terminates the periodic condition unless the periodic
statement is repeated.
}
title 'ANTI-PERIODIC BOUNDARY TEST'
Variables
u
definitions
k = 0.1
h=0
equations
u : div(K*grad(u)) + h = 0
boundaries
Region 1
start(-1,-1)
value(u)=0 line to (1,-1)
Sample P roblems : Usage 626
value(u)=0
arc(center= 0,0) to close
region 2
H = 1
start(xc-rc,yc) arc(center=xc,yc) angle=360
monitors
grid(x,y)
contour(u)
plots
grid(x,y) contour(u)
end
5.2.19.6 periodic+tim e
{ PERIODIC+TIME.PDE
}
title 'Time-dependent Periodic Boundary Test'
variables
u(0.01)
definitions
k = 0.1
h=0
x0=0.5 y0=-0.2
x1=1.1 y1=0.2
equations
u : div(K*grad(u)) + h = dt(u)
boundaries
region 1
start(-1,-1)
value(u)=0 line to (0.9,-1) to (1,-1)
{ The following arc is required to be a periodic image of an arc
two units to its left. (This image boundary has not yet been defined.) }
periodic(x-2,y) arc(center=-1,0) to (1,1)
value(u)=0 line to (-1,1)
{ The following arc provides the required image boundary for the previous
periodic statement }
nobc(u) { turn off the value BC }
arc(center= -3,0) to close
{ an off-center heat source provides the asymmetric conditions to
demonstrate the periodicity of the solution }
region 2 h=10 k=10
start(x0,y0) line to (x1,y0) to (x1,y1) to (x0,y1) to close
time 0 to 10
monitors
for cycle=1
grid(x,y)
contour(u)
plots
for cycle=10
grid(x,y)
contour(u)
end
Sample P roblems : Usage 628
5.2.19.7 periodic
{ PERIODIC.PDE
This example shows the use of FlexPDE in applications with periodic boundaries.
The PERIODIC 240 statement appears in the position of a boundary condition, but
the syntax is slightly different, and the requirements and implications are
more extensive.
The syntax is:
PERIODIC(X_mapping,Y_mapping)
The mapping expressions specify the arithmetic required to convert a point
(X,Y) in the immediate boundary to a point (X',Y') on a remote boundary.
The mapping expressions must result in each point on the immediate boundary
mapping to a point on the remote boundary. Segment endpoints must map to
segment endpoints. The transformation must be invertible; do not specify
constants as mapped coordinates, as this will create a singular transformation.
The periodic boundary statement terminates any boundary conditions in effect,
and instead imposes equality of all variables on the two boundaries. It is
still possible to state a boundary condition on the remote boundary,
but in most cases this would be inappropriate.
The periodic statement affects only the next following LINE 226 or ARC 226 path.
These paths may contain more than one segment, but the next appearing
LINE or ARC statement terminates the periodic condition unless the periodic
statement is repeated.
}
title 'PERIODIC BOUNDARY TEST'
variables
u
definitions
k = 0.1
h=0
x0=0.5 y0=-0.2
x1=1.1 y1=0.2
equations
u : div(K*grad(u)) + h = 0
boundaries
region 1
start(-1,-1)
value(u)=0 line to (0.9,-1) to (1,-1)
{ The following arc is required to be a periodic image of an arc
two units to its left. (This image boundary has not yet been defined.) }
periodic(x-2,y) arc(center=-1,0) to (1,1)
value(u)=0 line to (-1,1)
{ The following arc provides the required image boundary for the previous
periodic statement }
nobc(u) { turn off the value BC }
arc(center= -3,0) to close
{ an off-center heat source provides the asymmetric conditions to
demonstrate the periodicity of the solution }
region 2 h=10 k=10
start(x0,y0) line to (x1,y0) to (x1,y1) to (x0,y1) to close
monitors
grid(x,y)
contour(u)
plots
grid(x,y)
contour(u)
end
629 FlexP DE 7 : Sample P roblems
5.2.19.8 periodic_m ap
{ PERIODIC_MAP.PDE
This example is a modification of PERIODIC.PDE 628 , and shows the use of the MAP facility
in applications with periodic boundaries 240 .
( Only FlexPDE versions 7.16 or later support this facility. )
The PERIODIC (or ANTIPERIODIC) statement presets the behavior of all variables.
A statement MAP() = 1 or MAP() = -1 may then appear for any number of variables,
to independently set the behavior of that variable.
MAP(.)=1 means PERIODIC, MAP(.)=-1 means ANTIPERIODIC
}
title 'MAPPED PERIODIC BOUNDARY TEST'
variables
u,v
definitions
k = 0.1
h=0
x0=0.5 y0=-0.2
x1=1.1 y1=0.2
offset = sqrt(5)-2
select
debug(periodics)
equations
u : div(K*grad(u)) + h = 0
v : div(K*grad(v)) + h = 0
boundaries
region 1
start(-1,-1)
value(u)=0 value(v)=0 line to (0.9,-1) to (1,-1)
{ The following boundary is required to be a periodic image of the boundary
two units to its left. (This image boundary has not yet been defined.) }
periodic(x-2,y)
{ The variable U is declared PERIODIC, and the variable V is declared ANTIPERIODIC:
}
map(u)=1 map(v)=-1
{ the boundary is declared to be an arc: }
arc(center=-1,0) to (1,1)
value(u)=0 value(v)=0 line to (-1,1)
{ The following arc provides the required image boundary for the previous
periodic statement }
nobc(u) nobc(v) { turn off the value BC }
arc(center= -3,0) to close
{ an off-center heat source provides the asymmetric conditions to
demonstrate the periodicity of the solution }
region 2 h=10 k=10
start(x0,y0) line to (x1,y0) to (x1,y1) to (x0,y1) to close
monitors
grid(x,y)
contour(u)
contour(v)
plots
grid(x,y)
contour(u)
contour(v)
elevation(u,v) from(-1+offset,0) to (1+offset,0)
end
Sample P roblems : Usage 630
definitions
k = 1
h=0
x0=0.4 x1=0.9 { right box x-coordinates }
x2=-0.5 x3=0.0 { left box x-coordinates }
y0=-0.7 y1 = -0.3 {y-coordinates for both
boxes }
equations
u : div(K*grad(u)) + h = 0
boundaries
region 1
{ Periodic bottom boundary }
start(-1,-1)
periodic(x,y+2) line to (1,-1)
{ Periodic right boundary }
periodic(x-2,y) arc(center=-1,0) to (1,1)
{ Image of periodic bottom boundary }
line to (-1,1)
{ Image of periodic right boundary }
arc(center= -3,0) to close
{ off-center hot box }
start(x0,y0)
value(u)=1 line to (x1,y0) to (x1,y1) to (x0,y1) to close
{ off-center cold box }
start(x2,y0)
value(u)=-1 line to (x3,y0) to (x3,y1) to (x2,y1) to close
monitors
grid(x,y)
contour(u)
plots
grid(x,y)
contour(u)
end
5.2.20 Plotting
5.2.20.1 3d_ploton
{ 3D_PLOTON.PDE
This problem shows some of the possible 'ON' 254 qualifiers for 3D plots.
631 FlexP DE 7 : Sample P roblems
}
title '3D Test -- Plot Qualifiers'
coordinates
cartesian3
Variables
u
definitions
k = 0.1
heat = 4
equations
U: div(K*grad(u)) + heat = 0
extrusion
surface z = 0
surface z = 0.8-0.3*(x^2+y^2)
surface z = 1.0-0.3*(x^2+y^2)
boundaries
region 1 'outer'
layer 2 k = 1
start(-1,-1)
value(u) = 0
line to (1,-1) to (1,1) to (-1,1) to close
region 2 'plug'
layer 2 k = 1
start 'dot' (0.5,0.5) arc(center=0,0) angle=360
plots
grid(x,y,z) on region 1 as "Only Region 1, both layers"
grid(x,y,z) on region 'plug' on layer 2 as "Region 2 Layer 2"
grid(x,y,z) on region 'plug' on layers 1,2 paintregions as "Region 2, both layers"
grid(y,z) on x=0 on 'plug' as "Cut plane on region 2"
contour(u) on x=0.51 on layer 2 as "Solution on X-cut in layer 2"
contour(u) on z=0.51 on region 2 as "Solution on Z-cut in region 2"
contour(u) on surface 2 on region 2 as "Solution on paraboloidal layer
interface"
vector(grad(u)) on surface 2 on 'outer' as "Flux on layer interface in region 1"
end
5.2.20.2 ex port_test
{ EXPORT_TEST.PDE
This sample demonstrates the use of EXPORT 249 selectors in PLOT 245 output.
}
Variables
Temp { Identify "Temp" as the system variable }
definitions
K = 1 { declare and define the conductivity }
source = 4 { declare and define the source }
Texact = 1-x^2-y^2 { for convenience, define the exact solution }
initial values
Temp = 0 { unimportant in linear steady-state problems }
equations
Temp: div(K*grad(Temp)) + source = 0 { define the heatflow equation }
monitors
contour(Temp) { show the Temperature during solution }
end
5.2.20.3 plot_on_grid
{ PLOT_ON_GRID.PDE
}
title "Contour plots on a deformed grid"
select
cubic { Use Cubic Basis }
variables
U { X-displacement }
V { Y-displacement }
definitions
L = 1 { Bar length }
hL = L/2
W = 0.1 { Bar thickness }
hW = W/2
eps = 0.01*L
I = 2*hW^3/3 { Moment of inertia }
nu = 0.3 { Poisson's Ratio }
E = 2.0e11 { Young's Modulus for Steel (N/M^2) }
{ plane stress coefficients }
G = E/(1-nu^2)
C11 = G
C12 = G*nu
C22 = G
C33 = G*(1-nu)/2
amplitude=GLOBALMAX(abs(v)) { for grid-plot scaling }
mag=1/amplitude
force = -250 { total loading force in Newtons (~10 pound force) }
dist = 0.5*force*(hW^2-y^2)/I { Distributed load }
Sx = (C11*dx(U) + C12*dy(V)) { Stresses }
Sy = (C12*dx(U) + C22*dy(V))
Txy = C33*(dy(U) + dx(V))
{ Timoshenko's analytic solution: }
Vexact = (force/(6*E*I))*((L-x)^2*(2*L+x) + 3*nu*x*y^2)
Uexact = (force/(6*E*I))*(3*y*(L^2-x^2) +(2+nu)*y^3 -6*(1+nu)*hW^2*y)
633 FlexP DE 7 : Sample P roblems
Sxexact = -force*x*y/I
Txyexact = -0.5*force*(hW^2-y^2)/I
initial values
U = 0
V = 0
equations { the displacement equations }
U: dx(Sx) + dy(Txy) = 0
V: dx(Txy) + dy(Sy) = 0
boundaries
region 1
start (0,-hW)
5.2.20.4 plot_test
{ PLOT_TEST.PDE
variables
v
definitions
Lx=2 Ly=1.5
delx=0.25*Ly
d=0.1*Ly ddy=0.1*d
Ex=-dx(v) Ey=-dy(v)
Eabs=sqrt(Ex^2+Ey^2)
eps0=8.854e-12
eps
DEx=eps*Ex DEy=eps*Ey
Dabs=sqrt(DEx^2+DEy^2)
zero=1.e-15
equations
V: div(-eps*grad(v)) = 0
Sample P roblems : Usage 634
boundaries
region 1
eps=eps0
start(-Lx,-Ly) Load(v)=0
line to (Lx,-Ly) to (Lx,Ly) to (-LX,Ly) to close
start "Plate1" (-delx/2,-d/2) value(v)=0
line to (delx/2,-d/2) to (delx/2,-d/2-ddy) to(-delx/2,-d/2-ddy)
to close
start "Plate2" (-delx/2,d/2+ddy) value(v)=1
line to (delx/2,d/2+ddy) to (delx/2,d/2) to(-delx/2,d/2)
to close
region 2 { Dielectric }
eps = 7.0*eps0
start(-delx/2,-d/2)
line to (delx/2,-d/2) to (delx/2,d/2) to(-delx/2,d/2)
to close
MONITORS
contour(v)
PLOTS
! Contour plots
contour(v) as "Potential"
contour(v) contours=50 as "More Contours"
contour(v) contours=10 fixed range=(0.4,0.6) as "Fixed Range"
contour(v) levels=0, 0.1, 0.3, 0.5, 0.7, 0.9 as "Selected Levels"
! contour with stretching zoom
contour(v) zoom(-Lx/2,-Ly/2,Lx,Ly) as "Zoomed Contour (stretched)"
contour(v) on region 2 as "Region 2 Contour"
contour(magnitude(grad(v))) log as "Field (Log divisions)"
integrate
report integral(magnitude(grad(v))) as "Integral Report"
contour(magnitude(grad(v))) as "Field (NO Log divisions)"
! Surface Plots
surface(magnitude(grad(v))) log as "Field (Log divisions)"
integrate
report integral(magnitude(grad(v))) as "Integral Report"
surface(v) as "Surface(V)"
surface(v) gray as "Surface(V) Gray"
surface(v) gray mesh points=20 as "Surface(V) Gray Mesh"
! Vector plot (with 3-argument square zoom)
vector(dx(v),dy(v)) zoom(-Ly/2,-Ly/2,Ly) as " Zoomed Field Vectors (square)"
! Elevations
elevation(v, dy(v)*d) from (0,-Ly) to (0,Ly) points=1000 as "1000 Point Elevation"
integrate
elevation(normal(grad(v))) on "Plate1" as "Elevation Plot on Boundary " integrate
elevation(magnitude(grad(v))) from (0,-0.9*Ly) to (0,0.9*Ly) log as "LOG Field"
! Grid plots
grid(x,y) paintmaterials as "Mesh Plot"
grid(x,y) paintmaterials nolines as "Materials Plot"
end
5.2.21 Sequenced_Equations
5.2.21.1 equation_iteration
{ EQUATION_ITERATION.PDE
This is not a better way to solve this particular problem, but simply an exanple
of the usage for the START_ITERATATION - END_ITERATION construct.
variables
u(0.1)
v(0.01)
p(1)
psi
select
ngrid=40
definitions
Lx = 5 Ly = 1.5
p0 = 2
speed2 = u^2+v^2
speed = sqrt(speed2)
dens = 1
visc = 0.04
vxx = -(p0/(2*visc*(2*Lx)))*(Ly^2-y^2) { open-channel x-velocity }
rball=0.4
cut = 0.1 { value for bevel at the corners of the obstruction }
penalty = 100*visc/rball^2
Re = globalmax(speed)*(Ly/2)/(visc/dens)
initial values
u = 0.5*vxx v = 0 p = p0*(Lx+x)/(2*Lx)
equations
! Iterate U and V until mutual convergence
start_iteration
u: visc*div(grad(u)) - dx(p) = dens*(u*dx(u) + v*dy(u))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
then
v: visc*div(grad(v)) - dy(p) = dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
end_iteration
then
psi: div(grad(psi)) + w = 0 ! solve streamline equation separately from velocities
boundaries
region 1
start(-Lx,0)
load(u) = 0 value(v) = 0 load(p) = 0 value(psi)=0
line to (Lx/2-rball,0)
monitors
contour(speed) report(Re)
contour(psi) as "Streamlines"
contour(max(psi,-0.003)) zoom(Lx/2-3*rball,0, 3*rball,3*rball) as "Vortex
Streamlines"
vector(u,v) as "flow" zoom(Lx/2-3*rball,0, 3*rball,3*rball) norm
plots
contour(u) report(Re)
contour(v) report(Re)
contour(speed) painted report(Re)
vector(u,v) as "flow" report(Re)
contour(p) as "Pressure" painted
contour(dx(u)+dy(v)) as "Continuity Error"
elevation(u) from (-Lx,0) to (-Lx,Ly)
elevation(u) from (0,0) to (0,Ly)
elevation(u) from (Lx/2,0) to (Lx/2,Ly)
elevation(u) from (Lx,0) to (Lx,Ly)
contour(psi) as "Streamlines"
contour(max(psi,-0.003)) zoom(Lx/2-3*rball,0, 3*rball,3*rball) as "Vortex
Streamlines"
vector(u,v) as "flow" zoom(Lx/2-3*rball,0, 3*rball,3*rball) norm
end
5.2.21.2 initialeq
{ INITIALEQ.PDE
coordinates xcylinder('Z','R')
variables
temp (threshold=100)
temp2(threshold=100)
definitions
k = 0.85 {thermal conductivity}
cp = 1 { heat capacity }
long = 18
H = 0.4 {free convection boundary coupling}
Ta = 25 {ambient temperature}
A = 4500 {amplitude}
source = A*exp(-((z-1*t)/.5)^2)*(200/(t+199))
tsource = time_integral(vol_integral(source))
t1 = time_integral(1.0)
initial value
temp = Ta
temp2 = Ta
initial equations
Temp: div(k*grad(temp)) + A*exp(-(z-long/2)^2)= 0
637 FlexP DE 7 : Sample P roblems
equations
Temp: div(k*grad(temp)) + source = cp*dt(temp)
Temp2: div(k*grad(temp2)) + source = cp*dt(temp2)
boundaries
region 1
start(0,0)
natural(temp) = 0
natural(temp2) = 0
line to (long,0)
value(temp) = Ta
value(temp2) = Ta
line to (long,1)
natural(temp) = -H*(temp - Ta)
natural(temp2) = -H*(temp2 - Ta)
line to (0,1)
value(temp) = Ta
value(temp2) = Ta
line to close
feature
start(0.01*long,0) line to (0.01*long,1)
time -0.5 to 19
monitors
for t = -0.5 by 0.5 to (long + 1)
elevation(temp, temp2) from (0,1) to (long,1) range=(0,1800) as "Surface Temp"
contour(temp)
contour(dt(temp))
contour(temp2)
plots
for t = -0.5 by 0.5 to (long + 1)
elevation(temp, temp2) from (0,0) to (long,0) range=(0,1800) as "Axis Temp"
histories
history(temp,dt(temp)) at (0,0) (1,0) (2,0) (3,0) (4,0) (5,0) (6,0) (7,0) (8,0)
(9,0) (10,0) (11,0) (12,0) (13,0) (14,0) (15,0) (16,0)
(17,0) (18,0)
history(temp2,dt(temp2)) at (0,0) (1,0) (2,0) (3,0) (4,0) (5,0) (6,0) (7,0) (8,0)
(9,0) (10,0) (11,0) (12,0) (13,0) (14,0) (15,0) (16,0)
(17,0) (18,0)
history(t1) as "Tintegral(1)"
history(tsource) as "Tintegral(Source)"
end
5.2.21.3 sm oothing_discontinuities
{ SMOOTHING_DISCONTINUITIES.PDE
This creates an implicit steady-state equation for the value at the end of the initial
time deltat0:
div(D*grad(u)) = (u - u0)/deltat0.
We use the INITIAL EQUATIONS 220 facility to solve this system before beginning the time
evolution.
Sample P roblems : Usage 638
variables
u(threshold=0.1) { fraction of external concentration }
definitions
concs = 1.8e8 { surface concentration atom/micron^3}
D = 1.1e-2 { diffusivity micron^2/hr}
conc = concs*u
cexact1d = concs*erfc(x/(2*sqrt(D*t)))
uexact1d = erfc(x/(2*sqrt(D*t))) { masked surface flux multiplier }
M = upulse(y-0.3,y-0.7)
u0 = 0
dt0 = 0.05
initial equations
u: div(D*grad(u)) = (u - u0)/dt0 ! finite difference over time for a first step
equations
u : div(D*grad(u)) = dt(u)
boundaries
region 1
start(0,0)
natural(u) = 0
line to (1,0) to (1,1) to (0,1)
value(u) = M
line to close
plots
for t=dt0 0.1 by 0.05 to 0.2 by 0.1 to endtime
contour(u)
surface(u)
elevation(u,uexact1d) from (0,0.5) to (1,0.5)
elevation(u-uexact1d) from (0,0.5) to (1,0.5)
histories
history(u) at (0.05,0.5) (0.1,0.5) (0.15,0.5) (0.2,0.5)
end
5.2.21.4 theneq+tim e
{ THENEQ+TIME.PDE
variables
u(0.01),v(0.01)
definitions
k = 1
a=2
! analytic solutions
u0 = (a-x^2-y^2)
v0 = (a*(x^2+y^2)/4-(x^4+y^4)/12)
equations
u: div(K*grad(u)) + 4 = dt(u)
then
v: div(K*grad(v)) - u = dt(v)
boundaries
Region 1
start(-1,-1)
! ramp the boundary values, so that the initial BV's are consistent with the
initial interior values.
value(u)=u0*Uramp(t, t-10)
value(v)=v0*Uramp(t, t-10)
line to (1,-1) to (1,1) to (-1,1) to close
time 0 to 100
plots
for cycle=10
contour(u) paint
surface(u)
contour(v) paint
surface(v)
elevation(u,div(K*grad(v))) from(-1,0) to (1,0)
history(u,v) at (0,0)
end
5.2.21.5 theneq
{ THENEQ.PDE
5.2.22 Stop+Restart
5.2.22.1 restart_ex port
{ RESTART_EXPORT.PDE
VARIABLES
temp(100)
psi(0.001)
w(1)
DEFINITIONS
Lx = 1 Ly = 0.5
Rad = 0.5*(Lx^2+Ly^2)/Ly
Gy = 980
heatin = min(10,t)
t0 = 50
rho0 = 1
rho = rho0*(1 - alpha*temp)
cp = 1
u = dy(psi)
v = -dx(psi)
penalty = 5000
EQUATIONS
temp: div(k*grad(temp)) = rho0*cp*(dt(temp) + u*dx(temp) + v*dy(temp))
psi: div(grad(psi)) + w = 0
w: dt(w) + u*dx(w) + v*dy(w) = visc*div(grad(w)) - Gy*dx(rho)
BOUNDARIES
region 1
641 FlexP DE 7 : Sample P roblems
TIME 0 to 10
MONITORS
for cycle=5 { watch what's happening }
contour(temp) as "Temperature"
contour(psi) as "Stream Function"
contour(w) as "Vorticity"
vector(curl(psi)) as "Flow Velocity" norm
PLOTS
for t = 1 by 1 to 10 by 10 to endtime
grid(x,y)
contour(temp) as "Temperature" painted
contour(psi) as "Stream Function"
contour(w) as "Vorticity" painted
vector(curl(psi)) as "Flow Velocity" norm
contour(rho) as "Density" painted
HISTORIES
history(temp) at (0.1*Lx,Ly) (0.2*Lx,Ly) (0.5*Lx,Ly) (0.8*Lx,Ly)
(0.7*Lx,0.5*Ly) (0.04*Lx,0.1*ly) as "Temperature"
history(u) at (0.1*Lx,Ly) (0.2*Lx,Ly) (0.5*Lx,Ly) (0.8*Lx,Ly)
(0.7*Lx,0.5*Ly) (0.04*Lx,0.2*Ly) as "X-velocity"
history(v) at (0.04*Lx,0.1*ly) as "Y-velocity"
history(v) at (0.04*Lx,0.1*ly) vs sqrt(t) as "Y-velocity"
END
VARIABLES
temp(100)
psi(0.001)
w(1)
DEFINITIONS
Lx = 1 Ly = 0.5
Rad = 0.5*(Lx^2+Ly^2)/Ly
Sample P roblems : Usage 642
Gy = 980
heatin = min(10,t)
t0 = 50
rho0 = 1
rho = rho0*(1 - alpha*temp)
cp = 1
u = dy(psi)
v = -dx(psi)
penalty = 5000
INITIAL VALUES
restart("restart_export_output/restart_export_restart.xfr")
EQUATIONS
temp: div(k*grad(temp)) = rho0*cp*(dt(temp) + u*dx(temp) + v*dy(temp))
psi: div(grad(psi)) + w = 0
w: dt(w) + u*dx(w) + v*dy(w) = visc*div(grad(w)) - Gy*dx(rho)
BOUNDARIES
region 1
TIME 0 to 100
MONITORS
for cycle=5 { watch what's happening }
contour(temp) as "Temperature"
contour(psi) as "Stream Function"
contour(w) as "Vorticity"
vector(curl(psi)) as "Flow Velocity" norm
PLOTS
for t = 1 by 1 to 10 by 10 to endtime
grid(x,y)
contour(temp) as "Temperature" painted
contour(psi) as "Stream Function"
contour(w) as "Vorticity" painted
643 FlexP DE 7 : Sample P roblems
HISTORIES
history(temp) at (0.1*Lx,Ly) (0.2*Lx,Ly) (0.5*Lx,Ly) (0.8*Lx,Ly)
(0.7*Lx,0.5*Ly) (0.04*Lx,0.1*ly) as "Temperature"
history(u) at (0.1*Lx,Ly) (0.2*Lx,Ly) (0.5*Lx,Ly) (0.8*Lx,Ly)
(0.7*Lx,0.5*Ly) (0.04*Lx,0.2*Ly) as "X-velocity"
history(v) at (0.04*Lx,0.1*ly) as "Y-velocity"
history(v) at (0.04*Lx,0.1*ly) vs sqrt(t) as "Y-velocity"
history(psi) at (0.52,0.38)
END
5.2.23 Variable_Types
5.2.23.1 array _v ariables
{ ARRAY_VARIABLES.PDE
variables
U=array[5] { an array of field variables }
global variables
g(threshold=0.1) = array[5] { and an array of global variables }
definitions
u0 = 1-x^2-y^2
s = array(1,2,3,4,5) { each equation has a different source }
{ use initial equations to diffuse the otherwise discontinuous initial value caused by
value BC }
initial equations
repeat i=1 to 5
U[i]: del2(u[i]) = 0
endrepeat
equations
repeat i=1 to 5
U[i]: del2(u[i]) +s[i] = dt(u[i])
g[i]: dt(g[i]) = i-g[i]
endrepeat
boundaries
Region 1
start(-1,-1)
repeat i=1 to 5
value(u[i])=u0
endrepeat
line to (1,-1) to (1,1) to (-1,1) to close
time 0 to 10
plots
for cycle=10
contour(u_1) ! variables may be indexed with underscores
repeat i=1 to 5
contour(u[i]) as "U_"+$i ! variables may be indexed with brackets
endrepeat
history(g)
history(u) at (0,0) (1/4,1/4)(1/2,1/2)(3/4,3/4)
vtk(u,g)
table(u,g)
transfer(u,g)
Sample P roblems : Usage 644
end
This example demonstrates the use of COMPLEX 114 variables and ARRAY 201 definitions
to compute the time-sinusoidal behavior of a rod in a box.
The heat equation is
div(k*grad(temp)) = cp*dt(temp)
If we assume that the sources and solutions are in steady oscillation at a frequency
omega, then we can write
temp(x,y,t) = phi(x,y)*exp(i*omega*t) = phi(x,y)*(cos(omega*t) + i*sin(omega*t))
Substituting this into the heat equation and dividing the exp(i*omega*t) out of the
result leaves
div(k*grad(phi)) - i*omega*cp*phi = 0
The temperature temp(x,y,t) can be reconstructed at any time by expanding the above
definition.
In this example, we construct an array of sample times and the associated arrays
of sine and cosine factors. These arrays are then used to display a time history of
temperature at various points in the domain.
}
TITLE 'Time Sinusoidal Heat flow around an Insulating blob '
645 FlexP DE 7 : Sample P roblems
VARIABLES
! define the complex amplitude function phi and its real and imaginary components
phi=complex(phir,phii)
DEFINITIONS
k=1
ts = array (0 by pi/20 to 2*pi) ! an array of sample times
fr = cos(ts) ! sine and cosine arrays
fi = sin(ts)
! define a function for evaluating a time array of temp(px,py,t) at a point
temp(px, py) = eval(phir,px,py)*fr + eval(phii,px,py)*fi
EQUATIONS
phi: Div(k*grad(phi)) - complex(0,1)*phi= 0
BOUNDARIES
REGION 1 'box'
START(-1,-1)
VALUE(Phi)=complex(0,0) LINE TO(1,-1) { Phi=0 in base line }
NATURAL(Phi)=complex(0,0) LINE TO (1,1) { normal derivative =0 on right side }
VALUE(Phi)=complex(1,0) LINE TO (-1,1) { Phi = 1 on top }
NATURAL(Phi)=complex(0,0) LINE TO CLOSE { normal derivative =0 on left side }
REGION 2 'rod' { the embedded circular rod }
k=0.01
START 'ring' (1/2,0)
ARC(CENTER=0,0) ANGLE=360 TO FINISH
PLOTS
CONTOUR(Phir) ! plot the real part of phi
REPORT(k) REPORT(INTEGRAL(Phir, 'rod'))
CONTOUR(Phii) ! plot the imaginary part of phi
REPORT(k) REPORT(INTEGRAL(Phii, 'rod'))
! reconstruct the temperature distribution at a few selected times
REPEAT tx=0 by pi/2 to 2*pi
SURFACE(phir*cos(tx)+phii*sin(tx)) as "Phi at t="+$[4]tx
ENDREPEAT
! plot the time history at a few selected positions
ELEVATION(temp(0,0), temp(0,0.2), temp(0,0.4), temp(0,0.5)) vs ts as "Histories"
VECTOR(-k*grad(Phir))
! plot a lineout of phir and phii through the domain
ELEVATION(Phi) FROM (0,-1) to (0,1)
! plot the real component of flux on the surface of the rod
ELEVATION(Normal(-k*grad(Phir))) ON 'ring'
END
Declaring a variable COMPLEX 114 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 }
Sample P roblems : Usage 646
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
This example shows the use of complex 114 variables in time-dependent systems.
The equation that is solved is not intended to represent any real application.
}
title 'Complex transient equations'
Variables
U(0.01) = complex (Ur,Ui) { creates variables Ur and Ui }
definitions
u0 = 1-x^2-y^2
s = complex(4,x)
equations
{ create two scalar equations, one for Ur and one for Ui }
U: del2(U) +s = dt(U)
boundaries
Region 1
start(-1,-1)
natural(Ur)=u0-Ur
line to (1,-1) to (1,1) to (-1,1) to close
time 0 to 1
plots
for cycle=10
contour(Ur,Ui)
contour(Real(u),Imag(U))
contour(U)
vector(U)
elevation(u,s) from(-1,0) to (1,0)
history(u,s) at (0,0)
end
The problem is a modification of LOWVISC.PDE 404 , in which the bottom half of the
channel
has been filled with a solid.
The fluid equations are declared INACTIVE 126 in the solid region, but a temperature
equation has been added that is active everywhere.
647 FlexP DE 7 : Sample P roblems
The bottom of the solid is held at temperature = 0, while the fluid has an incoming
temperature of 1.
We solve the equations in sequence: first the fluid equations, then the temperature.
}
title 'Variables inactive in regions'
variables
u(0.1)
v(0.01)
p(0.1)
temp(0.1)
definitions
Lx = 5 Ly = 1.5
Gx = 0 Gy = 0
u0 = 0 { default initial u-velocity }
p0 = 0 { default initial pressure }
pin=2 { inlet pressure }
speed2 = u^2+v^2
speed = sqrt(speed2)
dens = 1
visc = 0.04
vxx = (p0/(2*visc*(2*Lx)))*y^2*(Ly-y)^2 { open-channel x-velocity }
k = 0.1 { default thermal conductivity }
rball=0.5
cut = 0.1 { bevel the corners of the obstruction }
penalty = 100*visc/rball^2
Re = globalmax(speed)*(Ly/2)/(visc/dens)
initial values
u = u0 v = 0 p = p0
equations
u: visc*div(grad(u)) - dx(p) = dens*(u*dx(u) + v*dy(u))
v: visc*div(grad(v)) - dy(p) = dens*(u*dx(v) + v*dy(v))
p: div(grad(p)) = penalty*(dx(u)+dy(v))
then
temp: div(k*grad(temp)) - u*dx(temp) - v*dy(temp) = 0
Boundaries
{ bound the entire region, placing temperature boundary conditions }
region 1
INACTIVE (u,v,p) { Inactivate the fluid in this region }
start(-Lx,-Ly)
value(temp)=0 line to (Lx,-Ly)
natural(temp)=0 line to (Lx,0)
value(temp)=1 line to (Lx,Ly) { inlet fluid temp = 1 }
natural(temp)=0 line to (-Lx,Ly)
natural(temp)=-k*dx(temp) line to close { outlet diffusive temperature flux }
{ overlay the fluid region onto the total domain, including obstruction,
and place fluid boundary conditions }
region 2
u0 = 0.5*vxx P0=pin*x/(2*Lx) { initial values in fluid region }
K = 0.01 { fluid thermal conductivity }
start(-Lx,0)
value(u)=0 value(v) = 0
line to (Lx/2-rball,0)
to (Lx/2-rball,rball) bevel(cut)
to (Lx/2+rball,rball) bevel(cut)
to (Lx/2+rball,0)
to (Lx,0)
load(u) = 0 value(v) = 0 value(p) = pin
line to (Lx,Ly)
value(u) = 0 value(v) = 0 load(p) = 0
line to (-Lx,Ly)
load(u) = 0 value(v) = 0 value(p) = 0
line to close
monitors
contour(speed)
Sample P roblems : Usage 648
contour(u) report(Re)
contour(v) report(Re)
contour(p) as "Pressure" painted
contour(temp)
plots
contour(u) report(Re)
contour(v) report(Re)
contour(p) as "Pressure" painted
contour(temp)
contour(speed) painted report(Re)
vector(u,v) as "flow" report(Re)
contour(dx(u)+dy(v)) as "Continuity Error"
end
5.2.23.9 v ector+tim e
{ VECTOR+TIME.PDE
This example demonstrates the use of Vector variables 198 in time-dependent problems.
A vector variable is controlled by a heat equation. The X and Y components are given
source terms consistent with an arbitrarily chosen final result.
Sample P roblems : Usage 650
This problem is not intended to represent any real application, but is constructed
merely to demonstrate the use of some features of vector variable support
in FlexPDE.
}
title 'Vector transient heatflow'
Variables
{ declare a vector variable with components Ux and Uy.
Each component is expected to have a variation large compared to 0.01 }
U(0.01) = vector(Ux,Uy)
{ declare a scalar field variable to validate the y-component }
V(0.01)
definitions
{ Define the expected solutions for the components. }
u0 = (1-x^2-y^2)
u1 = (1+y+x^3)
{ Define source terms that will result in the programmed solutions }
s = vector(4,-6*x)
equations
U: del2(U) +s = dt(U)
v: del2(v) +ycomp(s) = dt(v)
boundaries
Region 1
start 'outer' (-1,-1)
{ Apply a time ramp to the value boundary conditions, so that the
initial boundary values agree with the initial field values. }
value(U)=vector(u0,u1)*uramp(t, t-1)
value(v)=u1*uramp(t, t-1)
line to (1,-1) to (1,1) to (-1,1) to close
time 0 to 5
plots
for cycle=10
{ various uses of vector variables in plot statements: }
contour(Ux, u0)
contour(Uy, u1)
contour(v, u1)
contour(Ux, Uy)
contour(U)
vector(U)
elevation(U, v) from(-1,0) to (1,0)
history(U, v) at(0,0)
elevation(u1, Uy, v) on 'outer'
elevation(u0, Ux) on 'outer'
elevation(normal(grad(Ux)), normal(grad(u0))) on 'outer'
elevation(normal(grad(v)), normal(grad(Uy)), normal(grad(u1))) on 'outer'
end
651 FlexP DE 7
MERGEDIST 185
mesh 251
-L- im port 2 86
Lagrange 130, 221 Mesh Generat ion
LAMBDA 180 Controls 2 3 3
LANCZOS 190 MESH_DENSITY 2 1 4
LAY ER 93, 280 MESH_SPACING 54 , 2 1 4
Extrusion 9 5, 2 2 3 Mesh Generat ion Cont rols 183
Shaped Interfaces 1 06 Mesh Refinement
LEVELS 251 Controls 1 3 4
License 35, 36, 39, 41 FRONT 2 4 2
Registration 3 2 , 3 3 RESOLVE 2 4 3
LIMIT 244 MESH_DENSITY 214
LIMITED REGIONS 98, 232 MESH_SPACING 214
LINE 52, 226 Met afile 248
LINE LIST 229 Mimimize
LINE_INTEGRAL 64, 17 2 section 2 4 3
MIN funct ion 161
LINE_INTEGRATE 251
MOD funct ion 161
LINUPDATE 187
Modal Analy sis 7 5, 221, 27 7
Linux 2
MODE SUMMARY plot 247
LIST 212, 226
MODES 187
Lit eral St rings 158
Modify Menu 6
LN funct ion 160
MONITORS 57 , 245
LOAD 236
Steady State 2 58
LOG 251 Tim e Selection 2 58
LOG10 funct ion 160 MOVABLE 208
logarit hm 160 MOVE 197
LOGLIMIT 192 Movie 26
LUMP funct ion 165 Making 3 56
Moving Meshes 130, 197 , 221
Balancing 1 3 1
-M- Exam ple 1 3 2
MacOS 2 Mult iple processors 143, 189
Magnet ic Field 83
Magnet ic Vect or Pot ent ial 288
Magnet ost at ics 288 -N-
MAGNITUDE of vect or 17 7 Named Pat hs 226
MAP 240 NATURAL 236
Mat erial Boundary Condition 4 8, 56 , 82 , 83 , 2 7 4 , 3 00
Param eters 55, 9 6 , 2 3 0 Net work License Manager 39
Properties 55, 9 6 , 2 3 0 NEWTON 187 , 27 6
MATERIALS 215 Newt on-Raphson It erat ion 81
MATRICES Next 26
Using 1 4 0 NGRID 185
MATRIX NOBC 236
Definition 2 03 NODE POINT (Node Placement ) 234
Size 2 03 NODELIMIT 184
MAX funct ion 161
NOHEADER 251
Maximize
NOLINES 252
Plot 2 2
section 2 4 2 NOMERGE 252
Maximum Value 161 NOMINMAX 192, 252
Maxwell's Equat ions 288 Non-Analy t ic Funct ions 161
Menu 6 NONLINEAR 187
MERGE 251 Coefficients and Equations 7 9
Problem s 81 , 1 4 2 , 2 7 6
Index 656