All,
The attached crashes GMSH versions 2.8.6 and 2.8.5 on Linux x86_64 when the
logical resolves to "false".
Also, when it resolves to "true", it doesn't read the following script line, so
I put in a semicolon, which causes the scripting language to throw an "error ".
Any help would be appreciated.
Regards,
Dan
//
// tired of doing all the geometry calculations for radiusing corners
// Author: Danny Holstein
// Started: 2/12/15
//
// Function radius_corner(aL, bL, aR, bR, r)
// Where L and R refer to left and right lines, y = ax + b, and r is radius on corners
// rc_arry[] is used to dummy up an argument list, rc_arry[] = {aL, bL, aR, bR, r}
// = { 0, 1, 2, 3, 4}
Function radius_corner
angleL = Atan2(rc_arry[0], 1.0); // Printf("rc_arry[0]=%f, angleL=%f", rc_arry[0], angleL);
angleR = Atan2(rc_arry[2], 1.0);
If ((angleL - angleR)^2 < .25)
Error("Two lines may not be parallel for radiusing");
Endif
;
sign = (angleL > angleR ? 1.0 : -1.0);
x_center = ((rc_arry[1] - rc_arry[3]) + sign*rc_arry[4]*(1/Cos(angleR) - 1/Cos(angleL)))
/(rc_arry[2] - rc_arry[0]);
y_center = rc_arry[0] * x_center + rc_arry[1] - sign*rc_arry[4]/Cos(angleL);
PC = newp; Point(PC) = {x_center, y_center, 0, mesh_sz};
PL = newp; Point(PL) = {x_center - sign*rc_arry[4]*Sin(angleL), y_center + sign*rc_arry[4]*Cos(angleL), 0, mesh_sz};
PR = newp; Point(PR) = {x_center - sign*rc_arry[4]*Sin(angleR), y_center + sign*rc_arry[4]*Cos(angleR), 0, mesh_sz};
Circle(newl) = {PL, PC, PR};
x_center = (rc_arry[1] - rc_arry[3])
/(rc_arry[2] - rc_arry[0]);
y_center = rc_arry[0] * x_center + rc_arry[1];
PInt = newp; Point(PInt) = {x_center, y_center, 0, mesh_sz};
Return
// Function line_dxf(line_dxf_num)
Function line_dxf
func_pt[] = Point{cL[0]};
Printf(Str(" 0", "LINE", " 8", "Gun_Geom", "10")) >> dxf_file; // layer "Gun_Geom"
Printf("%f", func_pt[0]/m_per_mm) >> dxf_file; // x0
Printf(" 20") >> dxf_file;
Printf("%f", func_pt[1]/m_per_mm) >> dxf_file; // y0
Printf(" 11") >> dxf_file;
func_pt[] = Point{cL[1]};
Printf("%f", func_pt[0]/m_per_mm) >> dxf_file; // x1
Printf(" 21") >> dxf_file;
Printf("%f", func_pt[1]/m_per_mm) >> dxf_file; // y1
Return
// Function line_dxf(arc_dxf_num); arc_pts[] = {pt_start, pt_center, pt_stop};
Function arc_dxf
ctr_pt[] = Point{arc_pts[1]};
start_pt[] = Point{arc_pts[0]};
stop_pt[] = Point{arc_pts[2]};
Printf(Str(" 0", "ARC", " 8", "Gun_Geom", " 10")) >> dxf_file;
Printf("%f", ctr_pt[0]/m_per_mm) >> dxf_file; // xC
Printf(" 20") >> dxf_file;
Printf("%f", ctr_pt[1]/m_per_mm) >> dxf_file; // yC
Printf(" 40") >> dxf_file;
Printf("%f", Sqrt((ctr_pt[0]-start_pt[0])^2 + (ctr_pt[1]-start_pt[1])^2)/m_per_mm) >> dxf_file; // radius
Printf(" 50") >> dxf_file;
Printf("%f", (180/Pi) * Atan2(start_pt[1]-ctr_pt[1], start_pt[0]-ctr_pt[0])) >> dxf_file; // angle_start (degrees)
Printf(" 51") >> dxf_file;
Printf("%f", (180/Pi) * Atan2(stop_pt[1]-ctr_pt[1], stop_pt[0]-ctr_pt[0])) >> dxf_file; // angle_stop (degrees)
Return
//
// gyrotron data for Michelle code
// author: Danny Holstein, from Jags spreadsheet
// started 2/9/2015
//
m_per_in = .0254; // meters per inch
m_per_mm = .001; // meters per mm
r_per_deg = Pi/180; // rad per degreee
dxf_file = "keri.dxf";
l_auto = 1; // if true/1, don't use computed anode/cathode spacing
k_r = 14 * m_per_mm; // Cathode Radius (mm)
k_cur_den = 20; // Cathode Current Density (A/cm^2)
k_slope = 50 * r_per_deg; // Cathode Slope (degrees)
k_a_spacing = 7.58; // Cathode-First Anode Spacing Factor
k_temp = 1050; // Cathode Temperature (degrees C)
k_surf = 32; // Cathode surface finish (μ inches)
k_nose = 13.62 * m_per_mm; // Cathode nose radius
k_stalk = 19/14 * k_r; // Cathode stalk radius
k_stalk_r = 7.62 * m_per_mm; // Cathode stalk radius of curvature
and_r1 = 8.0 * m_per_mm; // anode first radius of curvature
and_s1 = 7.62 * m_per_mm; // anode first spacing
and_k = 7.58 * m_per_mm; // anode cathode spacing
and_r2 = 12.7 * m_per_mm; // anode second radius of curvature
and_d2 = 2*16.62 * m_per_mm; // anode second diameter (past cathode, not a spacing)
and_l2 = 12.3 * m_per_mm; // anode second length
and_r3 = 2.0 * m_per_mm; and_l3 = 160.0 * m_per_mm; and_d3 = 6.4*2 * m_per_mm;
and_r4 = 2.0 * m_per_mm; and_l4 = 20.3 * m_per_mm; and_d4 = 4.8*2 * m_per_mm;
tun_r = 2.0 * m_per_mm; tun_l = 20.0 * m_per_mm; tun_d = 6.0*2 * m_per_mm; // tunnel params
beam_volt = 40; // Voltage (kV)
beam_cur = 6; // Current (A)
beam_alpha = 2; // Pitch Factor (Alpha)
beam_r = 1.52 * m_per_mm; // Beam Radius (mm)
beam_thick = 0.25 * m_per_mm; // Beam Thickness (mm)
cav_B = 1.83; // Cavity Magnetic Field (T)
cav_r = 2.127 * m_per_mm; // Cavity Radius (mm)
mesh_sz = 0.0;
//
// gyrotron mesh for Michelle code
// author: Danny Holstein
// started 2/9/2015
//
Include "keri.dat";
// Include "calcs.dat";
Include "functions.dat";
Printf(Str("0", "SECTION", "2", "ENTITIES")) > dxf_file;
//
// spreadsheet calculations and initialization complete, build geometry
//
// cathode
Point(1) = {-ls/2*Cos(k_slope) * m_per_mm, k_r + 0.5*ls*Sin(k_slope) * m_per_mm, 0, mesh_sz};
Point(2) = { ls/2*Cos(k_slope) * m_per_mm, k_r - 0.5*ls*Sin(k_slope) * m_per_mm, 0, mesh_sz};
Line(1) = {1, 2};
cL[] = {1, 2}; Call line_dxf;
// cathode nose
cp[] = Point{2};
c = k_nose * Sin(Pi/2 - k_slope);
d = k_nose * Cos(Pi/2 - k_slope);
e = (cp[1] - c)
/ Tan(k_slope);
Point(3) = {cp[0] + e - d, 0, 0, mesh_sz};
Point(4) = {cp[0] + e - d + k_nose, 0, 0, mesh_sz};
Point(5) = {cp[0] + e, c, 0, mesh_sz};
Circle(2) = {5, 3, 4};
arc_pts[] = {4, 3, 5}; Call arc_dxf;
Line(3) = {2, 5};
cL[] = {2, 5}; Call line_dxf;
// cathode stalk
cp[] = Point{1};
c = k_stalk_r * (1 - Cos(k_slope));
d = k_stalk_r * Sin(k_slope);
e = k_stalk - k_stalk_r;
f = cp[0] - (k_stalk - c - cp[1]) / Tan(k_slope);
Point(6) = {f, k_stalk - c, 0, mesh_sz};
Point(7) = {f - d, e, 0, mesh_sz};
Point(8) = {f - d, k_stalk, 0, mesh_sz};
cp[] = Point{8};
Point(9) = {cp[0] - 2 * k_2_a * m_per_mm, k_stalk, 0, mesh_sz};
Point(10) = {cp[0] - 2 * k_2_a * m_per_mm, k_stalk + and_s1, 0, mesh_sz};
Line(4) = {1, 6};
cL[] = {1, 6}; Call line_dxf;
Circle(5) = {6, 7, 8};
arc_pts[] = {6, 7, 8}; Call arc_dxf;
Line(6) = {8, 9};
cL[] = {8, 9}; Call line_dxf;
// neumann, stalk
Line(7) = {9, 10};
cL[] = {9, 10}; Call line_dxf;
// anode
cx[] = Point{2};
cx[0] = cx[0] + and_k * Cos(Pi/2 - k_slope); // define point in front of cathode (on cone)
cx[1] = cx[1] + and_k * Sin(Pi/2 - k_slope);
cp[] = Point{10}; // define first anode radius
rc_arry[] = {0, cp[1], -Tan(k_slope), cx[1] - (-Tan(k_slope) * cx[0]), and_r1}; // Function radius_corner(aL, bL, aR, bR, r)
Call radius_corner;
arc_pts[] = {PR, PC, PL}; Call arc_dxf;
Line(9) = {10, 12};
cL[] = {10, 12}; Call line_dxf;
cp[] = Point{PInt}; // define anode cone to second radius
rc_arry[] = {- Tan(k_slope), cp[1] + Tan(k_slope) * cp[0], 0, and_d2/2, and_r2}; // Function radius_corner(aL, bL, aR, bR, r)
Call radius_corner;
arc_pts[] = {(sign > 0 ? PR: PL), PC, (sign > 0 ? PL: PR)}; Call arc_dxf;
Line(11) = {13, 16};
cL[] = {13, 16}; Call line_dxf;
cp[] = Point{PInt}; // define anode diameter in front of cathode
aL = 0;
bL = and_d2/2;
aR = (and_d3/2 - cp[1])/and_l3;
bR = cp[1] - aR * (cp[0] + and_l2);
rc_arry[] = {aL, bL, aR, bR, and_r3}; // Function radius_corner(aL, bL, aR, bR, r)
Call radius_corner;
arc_pts[] = {(sign > 0 ? PR: PL), PC, (sign > 0 ? PL: PR)}; Call arc_dxf;
Line(13) = {17, 20};
cL[] = {17, 20}; Call line_dxf;
cp[] = Point{PInt};
aL = aR;
bL = bR;
aR = (and_d4 - and_d3)/2/and_l4;
bR = and_d3/2 - aR * (cp[0] + and_l3);
rc_arry[] = {aL, bL, aR, bR, and_r3}; // Function radius_corner(aL, bL, aR, bR, r)
Call radius_corner;
arc_pts[] = {(sign > 0 ? PR: PL), PC, (sign > 0 ? PL: PR)}; Call arc_dxf;
Line(15) = {21, 24};
cL[] = {21, 24}; Call line_dxf;
cp[] = Point{PInt};
aL = aR;
bL = bR;
aR = (tun_d - and_d4)/2/tun_l;
bR = and_d4/2 - aR * (cp[0] + and_l4);
// Printf("aL=%f, bL=%f, aR=%f, bR=%f, and_r3=%f", aL, bL, aR, bR, and_r3);
rc_arry[] = {aL, bL, aR, bR, and_r3}; // Function radius_corner(aL, bL, aR, bR, r)
Call radius_corner;
// Printf("angleL=%f, angleR=%f", angleL, angleR);
// Printf("PInt=%.0f", PInt);
arc_pts[] = {(sign > 0 ? PR: PL), PC, (sign > 0 ? PL: PR)}; Call arc_dxf;
Line(17) = {25, 28};
cL[] = {25, 28}; Call line_dxf;
cp[] = Point{PInt};
Point(newp) = {cp[0] + and_l4, tun_d/2, 0, tun_d/10};
Point(newp) = {cp[0] + and_l4, 0, 0, tun_d/10};
Line(18) = {29, 31};
cL[] = {29, 31}; Call line_dxf;
Line(19) = {31, 32};
cL[] = {31, 32}; Call line_dxf;
Line(20) = {4, 32};
cL[] = {4, 32}; Call line_dxf;
Line Loop(21) = {9, 8, 11, 10, 13, 12, 15, 14, 17, 16, 18, 19, -20, -2, -3, -1, 4, 5, 6, 7};
Plane Surface(22) = {21};
Printf(Str("0", "ENDSEC", "0", "EOF")) >> dxf_file;
Characteristic Length {1, 2} = 0.0001;
Characteristic Length {13, 16} = 0.0005;
Characteristic Length {16, 17} = 0.001;
Characteristic Length {20, 17} = 0.001;
Characteristic Length {2, 5} = 0.0005;
Characteristic Length {4, 32} = 0.002;
Characteristic Length {21, 24} = 0.001;
_______________________________________________
gmsh mailing list
[email protected]
http://www.geuz.org/mailman/listinfo/gmsh