Skip to content
Snippets Groups Projects
Commit bb10fad3 authored by François Henrotte's avatar François Henrotte
Browse files

new models

parent 726809aa
No related branches found
No related tags found
No related merge requests found
Pipeline #5681 canceled
Include "wires_common.pro";
// global Gmsh options
Mesh.Optimize = 1; // optimize quality of tetrahedra
Mesh.VolumeEdges = 0; // hide volume edges
Geometry.ExactExtrusion = 0; // to allow rotation of extruded shapes
Solver.AutoMesh = 2; // always remesh if necessary (don't reuse mesh on disk)
lc1 = (Flag_Thin==0) ? MeshSizeWire*mm : rs ;
lc2 = box/10; // mesh size at outer surface
llWires[] = {};
centerWires[] = {};
surfWires[] = {};
If( Flag_Thin != 1)
// then circles are in the geometry
// their radius is R= WX~{i} in the real case (Flag_Thin == 0)
// or R=rs in the "regular sleeve case" (Flag_Thin == 2)
For i In {1:NumWires}
R = (Flag_Thin == 0 ) ? rw : rs;
pC = newp; Point(pC) = {WX~{i} , WY~{i} , 0, lc1};
p1 = newp; Point(p1) = {WX~{i}+R, WY~{i} , 0, lc1};
p2 = newp; Point(p2) = {WX~{i} , WY~{i}+R, 0, lc1};
p3 = newp; Point(p3) = {WX~{i}-R, WY~{i} , 0, lc1};
p4 = newp; Point(p4) = {WX~{i} , WY~{i}-R, 0, lc1};
c1 = newl; Circle(c1) = {p1,pC,p2};
c2 = newl; Circle(c2) = {p2,pC,p3};
c3 = newl; Circle(c3) = {p3,pC,p4};
c4 = newl; Circle(c4) = {p4,pC,p1};
l1 = newl; Line(l1) = {pC,p1};
l2 = newl; Line(l2) = {pC,p2};
l3 = newl; Line(l3) = {pC,p3};
l4 = newl; Line(l4) = {pC,p4};
ll1 = newll; Line Loop(ll1) = {l1,c1,-l2};
s1 = news; Plane Surface(s1) = {ll1};
ll2 = newll; Line Loop(ll2) = {l2,c2,-l3};
s2 = news; Plane Surface(s2) = {ll2};
ll3 = newll; Line Loop(ll3) = {l3,c3,-l4};
s3 = news; Plane Surface(s3) = {ll3};
ll4 = newll; Line Loop(ll4) = {l4,c4,-l1};
s4 = news; Plane Surface(s4) = {ll4};
llWires[] += {ll1,ll2,ll3,ll4};
surfWires~{i-1}[] = {s1,s2,s3,s4};
surfWires[] += surfWires~{i-1}[];
centerWires[] += {pC};
EndFor
Else
For i In {1:NumWires}
pC = newp; Point(pC) = {WX~{i} , WY~{i} , 0, lc1};
centerWires[] += {pC};
EndFor
EndIf
// create air box around wires
BoundingBox; // recompute model bounding box
cx = (General.MinX + General.MaxX) / 2;
cy = (General.MinY + General.MaxY) / 2;
cz = (General.MinZ + General.MaxZ) / 2;
/* lx = 2*inf + General.MaxX - General.MinX; */
/* ly = 2*inf + General.MaxY - General.MinZ; */
lx = 2*box;
ly = 2*box;
p1 = newp; Point (p1) = {cx-lx/2, cy-ly/2, 0, lc2};
p2 = newp; Point (p2) = {cx+lx/2, cy-ly/2, 0, lc2};
p3 = newp; Point (p3) = {cx+lx/2, cy+ly/2, 0, lc2};
p4 = newp; Point (p4) = {cx-lx/2, cy+ly/2, 0, lc2};
l1 = newl; Line(l1) = {p1, p2};
l2 = newl; Line(l2) = {p2, p3};
l3 = newl; Line(l3) = {p3, p4};
l4 = newl; Line(l4) = {p4, p1};
ll1 = newll; Line Loop(ll1) = {l1,l2,l3,l4};
Physical Line("INF", 2) = { l1, l2, l3, l4 };
If( !Flag_3D )
If( Flag_Thin == 0 ) // Real
s1 = news; Plane Surface(s1) = {ll1,-llWires[]};
Physical Surface("AIR", 1) = { s1 };
For i In {1:NumWires}
Physical Surface(Sprintf("VWIRE_%g",i), 10+i) = { surfWires~{i-1}[] };
Physical Point (Sprintf("LWIRE_%g",i), 50+i) = { centerWires[i-1] };
EndFor
ElseIf( Flag_Thin == 1 ) // 1D raw sleeve
s1 = news; Plane Surface(s1) = {ll1};
Physical Surface("AIR", 1) = { s1 };
For i In {1:NumWires}
Physical Point (Sprintf("LWIRE_%g",i), 50+i) = { centerWires[i-1] };
Point { centerWires[i-1] } In Surface { s1 };
EndFor
Else // 1D regular sleeve
s1 = news; Plane Surface(s1) = {ll1,-llWires[]};
Physical Surface("AIR", 1) = { s1, surfWires[] };
For i In {1:NumWires}
Physical Point (Sprintf("LWIRE_%g",i), 50+i) = { centerWires[i-1] };
Point { centerWires[i-1] } In Surface { s1 };
EndFor
EndIf
Else
For i In {1:NumWires}
e[] = Extrude {0,0,Lz} { Surface{ surfWires[i-1] } ; Layers{1}; Recombine; } ;
Printf("%g", #e[]);
Printf("%g %g %g %g %g %g", e[0], e[1], e[2], e[3], e[4], e[5]);
Physical Volume (Sprintf("VWIRE_%g",i), 10+i) = { e[1] };
Physical Surface(Sprintf("SANODE_%g",i), 20+i) = { surfWires[i-1] };
Physical Surface(Sprintf("SCATHODE_%g",i), 30+i) = { e[0] };
e[] = Extrude {0,0,Lz} { Point{ centerWires[i-1] } ; Layers{1}; Recombine; } ;
Physical Line (Sprintf("LWIRE_%g",i), 50+i) = { e[1] };
Physical Point (Sprintf("PANODE_%g",i), 60+i) = { centerWires[i-1] };
Physical Point (Sprintf("PCATHODE_%g",i), 70+i) = { e[0] };
EndFor
e[] = Extrude {0,0,Lz} { Surface{ s1 } ; Layers{1}; Recombine; } ;
Physical Volume ("AIR", 1) = { e[1] };
Physical Surface("INF", 2) = { s1, e[0], e[2], e[3], e[4], e[5] };
//Physical Surface("INF", 1) = { CombinedBoundary{ Volume{ e[1]}; } };
EndIf
This diff is collapsed.
mm = 1e-3;
deg = 180/Pi;
DefineConstant[
NumWires = {1, Name "Parameters/0Number of wires",
Choices {1="1", 2="2", 3="3"}, Visible 1}
Flag_Thin = {1, Name "Parameters/1Wire representation",
Choices {0="Real", 1="1D (raw sleeve)", 2="1D (regular sleeve)", 3="1D (naive)"}}
Flag_3D = {0, Name "Parameters/2Extruded model", Choices {0,1}, Visible 0}
Flag_Maps = {1, Name "Input/2Display maps", Choices {0,1}, Visible 1}
LogFreq = {4, Min 0, Max 8, Step 1, Name "Input/4Log of frequency"}
Freq = 10^LogFreq
WireRadius = {0.564189, Name "Parameters/5Wire radius [mm]"}
MeshSizeWire = {0.2, Name "Parameters/6Mesh size on wire [mm]"}
SleeveRadius = {2, Name "Parameters/7Sleeve radius [mm]"}
box = {100*mm, Name "Parameters/7box half-width [m]"}
rw = WireRadius*mm
rs = SleeveRadius*mm
A_c = Pi*rw^2 // wire cross section
rout = box
Lz = 1*mm
/* 'WireRadius' is the actual radius of the wire.
'MeshSizeWire' is the imposed mesh size at the nodes of the wire,
and thus also the practical approximative value of the radius of the sleeve.
The 'rs' and 'rw' parameters are assumed identical for all wires.
*/
];
Xlocs() = { 0, 5*mm, -5*mm};
Ylocs() = { 0, 0, 0};
For i In {1:NumWires}
DefineConstant[
WX~{i} = { Xlocs(i-1), // place wires symmetrically around x=0
Name Sprintf("Parameters/Wire %g/0X position [m]", i), Closed }
WY~{i} = { Ylocs(i-1), Name Sprintf("Parameters/Wire %g/0Y position [m]", i) }
WI~{i} = { 1, Name Sprintf("Parameters/Wire %g/2Current [A]", i) }
WP~{i} = { 0*NumWires*(i-1),
Name Sprintf("Parameters/Wire %g/3Phase [deg]", i) }
];
EndFor
Include "w3d_common.pro";
// global Gmsh options
Mesh.Optimize = 1; // optimize quality of tetrahedra
Mesh.VolumeEdges = 0; // hide volume edges
Geometry.ExactExtrusion = 0; // to allow rotation of extruded shapes
Solver.AutoMesh = 2; // always remesh if necessary (don't reuse mesh on disk)
lc1 = (Flag_Thin) ? MeshSizeThinWire*mm : MeshSizeThinWire*mm ;
lc2 = box/10; // mesh size at outer surface
llWires[] = {};
centerWires[] = {};
surfWires[] = {};
If( !Flag_Thin || (Flag_Thin && Flag_Corr==2))
// then circles are in the geometry
// their radius is R=rw if Flag_Thin != 0
// or R=rs in the "regular sleeve case" (Flag_Corr == 2)
R = ( !Flag_Thin ) ? rw : rs;
For i In {1:NumWires}
pC = newp; Point(pC) = {WX~{i} , WY~{i} , 0, lc1};
p1 = newp; Point(p1) = {WX~{i}+R, WY~{i} , 0, lc1};
p2 = newp; Point(p2) = {WX~{i} , WY~{i}+R, 0, lc1};
p3 = newp; Point(p3) = {WX~{i}-R, WY~{i} , 0, lc1};
p4 = newp; Point(p4) = {WX~{i} , WY~{i}-R, 0, lc1};
c1 = newl; Circle(c1) = {p1,pC,p2};
c2 = newl; Circle(c2) = {p2,pC,p3};
c3 = newl; Circle(c3) = {p3,pC,p4};
c4 = newl; Circle(c4) = {p4,pC,p1};
l1 = newl; Line(l1) = {pC,p1};
l2 = newl; Line(l2) = {pC,p2};
l3 = newl; Line(l3) = {pC,p3};
l4 = newl; Line(l4) = {pC,p4};
ll1 = newll; Line Loop(ll1) = {l1,c1,-l2};
s1 = news; Plane Surface(s1) = {ll1};
ll2 = newll; Line Loop(ll2) = {l2,c2,-l3};
s2 = news; Plane Surface(s2) = {ll2};
ll3 = newll; Line Loop(ll3) = {l3,c3,-l4};
s3 = news; Plane Surface(s3) = {ll3};
ll4 = newll; Line Loop(ll4) = {l4,c4,-l1};
s4 = news; Plane Surface(s4) = {ll4};
ll5 = newll;
Line Loop(ll5) = {c1,c2,c3,c4};
llWires[] += { ll5 };
surfWires~{i-1}[] = {s1,s2,s3,s4};
surfWires[] += surfWires~{i-1}[];
centerWires[] += {pC};
EndFor
Else
// then geometry only contains line conductors
For i In {1:NumWires}
pC = newp; Point(pC) = {WX~{i}, WY~{i}, 0, lc1};
centerWires[] += {pC};
EndFor
EndIf
// create air box around wires
BoundingBox; // recompute model bounding box
cx = (General.MinX + General.MaxX) / 2;
cy = (General.MinY + General.MaxY) / 2;
cz = (General.MinZ + General.MaxZ) / 2;
// lx = 2*inf + General.MaxX - General.MinX;
// ly = 2*inf + General.MaxY - General.MinZ;
lx = 2*box;
ly = 2*box;
p1 = newp; Point (p1) = {cx-lx/2, cy-ly/2, 0, lc2};
p2 = newp; Point (p2) = {cx+lx/2, cy-ly/2, 0, lc2};
p3 = newp; Point (p3) = {cx+lx/2, cy+ly/2, 0, lc2};
p4 = newp; Point (p4) = {cx-lx/2, cy+ly/2, 0, lc2};
l1 = newl; Line(l1) = {p1, p2};
l2 = newl; Line(l2) = {p2, p3};
l3 = newl; Line(l3) = {p3, p4};
l4 = newl; Line(l4) = {p4, p1};
ll1 = newll; Line Loop(ll1) = {l1,l2,l3,l4};
Skin[] = {};
If( !Flag_Thin ) // Wires with finite radius
For i In {1:NumWires}
e[] = Extrude {0,0,Lz}
{ Surface{ surfWires~{i-1}[] } ; /*Layers{1}; Recombine;*/ } ;
Physical Volume (Sprintf("VWIRE_%g",i), 10+i) = { e[ {1,6,11,16} ] };
Physical Surface(Sprintf("SANODE_%g",i), 20+i) = { surfWires~{i-1}[] };
Physical Surface(Sprintf("SCATHODE_%g",i), 30+i) = { e[ {0,5,10,15} ] };
Skin[] += e[ {3,8,13,18} ];
EndFor
s1 = news; Plane Surface(s1) = {ll1,-llWires[]};
e[] = Extrude {0,0,Lz} { Surface{ s1 } ; /*Layers{1}; Recombine;*/ } ;
Physical Volume ("AIR", 1) = { e[1] };
ElseIf( Flag_Corr == 2 ) // regular sleeve
Wires[]= {};
For i In {1:NumWires}
e[] = Extrude {0,0,Lz} { Point{ centerWires[i-1] } ; /*Layers{1};*/ } ;
Physical Line (Sprintf("LWIRE_%g",i), 50+i) = { e[1] };
Physical Point (Sprintf("PANODE_%g",i), 60+i) = { centerWires[i-1] };
Physical Point (Sprintf("PCATHODE_%g",i), 70+i) = { e[0] };
e[] = Extrude {0,0,Lz} { Surface{ surfWires~{i-1}[] } ;
/*Layers{1}; Recombine;*/ } ;
Wires() += e[ {1,6,11,16} ];
Physical Volume (Sprintf("VWIRE_%g",i), 10+i) = { e[ {1,6,11,16} ] };
Physical Surface(Sprintf("SANODE_%g",i), 20+i) = { surfWires~{i-1}[] };
Physical Surface(Sprintf("SCATHODE_%g",i), 30+i) = { e[ {0,5,10,15} ] };
EndFor
s1 = news; Plane Surface(s1) = {ll1,-llWires[]};
e[] = Extrude {0,0,Lz} { Surface{ s1 } ; /*Layers{1}; Recombine;*/ } ;
Physical Volume ("AIR", 1) = { e[1], Wires[] };
Else
s1 = news; Plane Surface(s1) = {ll1};
e[] = Extrude {0,0,Lz} { Surface{ s1 } ; /*Layers{1}; Recombine;*/ } ;
s2 = e[0];
v1 = e[1];
For i In {1:NumWires}
e[] = Extrude {0,0,Lz} { Point{ centerWires[i-1] } ; /*Layers{1};*/ } ;
//Printf("e=", e[]);
Physical Line (Sprintf("LWIRE_%g",i), 50+i) = { e[1] };
Physical Point (Sprintf("PANODE_%g",i), 60+i) = { centerWires[i-1] };
Physical Point (Sprintf("PCATHODE_%g",i), 70+i) = { e[0] };
Physical Volume ("AIR", 1) = { v1 };
// embed line conductors in mesh
Point { centerWires[i-1] } In Surface { s1 };
Point { e[0] } In Surface { s2 };
Curve { e[1] } In Volume { v1 };
EndFor
EndIf
Physical Surface("INF", 2) = { CombinedBoundary{ Volume{ : }; } };
Physical Surface("SKIN", 3) = Skin[];
Electrodes[] = {};
If( !Flag_Thin ) // Wires with finite radius
For i In {1:NumWires}
Electrodes[] += {20+i, 30+i};
EndFor
EndIf
Physical Line("LINTREE", 4) = { Boundary { Physical Surface { Electrodes[] }; } };
This diff is collapsed.
mm = 1e-3;
deg = 180/Pi;
/*
Expected inductance of a rectilinear 1mm radius wire: 4 nH/cm
*/
DefineConstant[
NumWires = {1, Name "Parameters/0Number of wires",
Choices {1="1", 2="2", 3="3"}, Visible 1}
Flag_Form = {2, Name "Parameters/1Conductor type", Visible 1,
Choices {1="Massive", 2="Stranded"}}
Flag_Thin = {1, Name "Parameters/2Use thin wires", Choices {0,1}, Visible 1}
Flag_Corr = {1, Name "Parameters/3Correction method",
Visible (Flag_Form==2) && Flag_Thin,
Choices {0="None", 1="Raw sleeve", 2="regular sleeve"}}
Flag_U = {0, Name "Parameters/4Impose U", Choices {0,1}, Visible 1}
Flag_Maps = {1, Name "Input/2Display maps", Choices {0,1}, Visible 1}
LogFreq = {4, Min 1, Max 8, Step 0.25, Name "Input/4Log of frequency"}
Freq = 10^LogFreq
WireRadius = {1, Name "Parameters/5Wire radius [mm]"}
MeshSizeWire = {1, Name "Parameters/6Mesh size in wire [mm]",
Visible !Flag_Thin}
MeshSizeThinWire = {1, Name "Parameters/7Mesh size on thin wire [mm]",
Visible Flag_Thin}
SleeveRadius = {2, Name "Parameters/8Sleeve radius [mm]"}
box = {100*mm, Name "Parameters/9box half-width [m]"}
rw = WireRadius*mm
rs = SleeveRadius*mm
A_c = Pi*rw^2 // wire cross section
rout = box
Lz = 10*mm
/* 'WireRadius' is the actual radius of the wire.
'MeshSizeWire' is the imposed mesh size at the nodes of the wire,
and thus also the practical approximative value of the radius of the sleeve.
The 'rs' and 'rw' parameters are assumed identical for all wires.
*/
];
Xlocs() = { 0, 5*mm, -5*mm};
Ylocs() = { 0, 0, 0};
For i In {1:NumWires}
DefineConstant[
WX~{i} = { Xlocs(i-1), // place wires symmetrically around x=0
Name Sprintf("Parameters/Wire %g/0X position [m]", i), Closed }
WY~{i} = { Ylocs(i-1), Name Sprintf("Parameters/Wire %g/0Y position [m]", i) }
WI~{i} = { 1.23456, Name Sprintf("Parameters/Wire %g/2Current [A]", i) }
WP~{i} = { 0*NumWires*(i-1),
Name Sprintf("Parameters/Wire %g/3Phase [deg]", i) }
];
EndFor
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment