// knot32.fe

// Surface Evolver initial datafile for trefoil knot
// (3,2 torus knot) with soap film partially touching boundary

// Boundary gap energy is used to keep gaps from opening along wire.
// This has no hessian, so to use hessian, you first have to fix
// the vertices on boundary 1 and set the gap coefficient to 0 ("k 0" command).

parameter maj_r = 2      // torus major radius
parameter min_r = 0.5    // torus minor radius

// Using CONVEX boundary to prevent vertices sliding along it opening gaps.
boundary 1 parameter 1 convex   // the knotted wire
x1:  cos(2*p1)*(maj_r + min_r*cos(3*p1))
x2:  sin(2*p1)*(maj_r + min_r*cos(3*p1))
x3:  min_r*sin(3*p1)

vertices
1    0.0*pi  boundary 1
2    0.2*pi  boundary 1
3    0.4*pi  boundary 1
4    0.6*pi  boundary 1  bare  fixed // part of the bare wire
5    0.8*pi  boundary 1  bare  fixed
6    1.0*pi  boundary 1
7    1.2*pi  boundary 1
8    1.4*pi  boundary 1
9    1.6*pi  boundary 1
10   1.8*pi  boundary 1

edges
1     1 2 boundary 1
2     2 3 boundary 1
3     3 4 boundary 1  bare
4     4 5 boundary 1  bare
5     5 6 boundary 1  bare
6     6 7 boundary 1
7     7 8 boundary 1
8     8 9 boundary 1
9     9 10 boundary 1
10    10 1 boundary 1
11   3 6  // triple  line
12   3 7
13   3 8
14   3 9
15   6 10
16   6 1
17   6 2

faces
1  11 6 -12
2  12 7 -13
3  13 8 -14
4  14 9 -15 -11
5  15 10 -16
6  16 1 -17
7  17 2 11

read
hessian_normal

// Fix vertices on wire except those where wire leaves film.
fixer := { fix vertex where on_boundary 1 and id !=3 and id !=6 }

// Typical evolution
gogo := { g 20; U; r; g 20; V;V;V;V; u; g 20; r; g 20; V; V; g 20;
	  r; g 20; V; V;
	  fix vertex where on_boundary 1; k 0;  // so can use Hessian
	  fix edge where on_boundary 1;
	  hessian; hessian;
	}
