File: Ribbon

package info (click to toggle)
dxsamples 4.4.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 26,340 kB
  • sloc: ansic: 10,079; sh: 8,445; java: 1,772; makefile: 1,102
file content (41 lines) | stat: -rw-r--r-- 1,118 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Import the electron density field
electrondensity = Import("watermolecule");

// Partition for parallelism
electrondensity = Partition(electrondensity);

// Compute the gradient of the electron density field
gradient = Gradient(electrondensity);

// Create a camera
camera = AutoCamera(electrondensity,"off-front");

// Create approximately 10 starting points, scattered through the data 
starts = Sample(electrondensity, 10);

// Compute the divergence and curl of the gradient field. We will use the
// curl to put twist on the streamlines
div, curl = DivCurl(gradient);

// Create streamlines from each of the starting points created by Sample.
// The curl is used to give a twist component to the lines, based on the
// vorticity of the vector field.
lines = Streamline(gradient, starts,curl=curl);

// Map the original electron density onto the lines, and color using 
// AutoColor
streamlinesmapped = Map(lines,electrondensity);
colored = AutoColor(streamlinesmapped);

// Create ribbons of width 0.2 in user units.
ribbons = Ribbon(colored,width=0.2);

// Display the ribbons
Display(ribbons,camera);