/* ---------------------------------------------------------------------------
   Modell einer Spule
----------------------------------------------------------------------------*/

// Constants
Include "coil_magnet.cst";


/* -------------------------------------------------------------------
   Magnet
------------------------------------------------------------------- */

// Points
Point(101) = { (l_M/2), (b_M/2), (h_M/2),lc_M};
Point(102) = { (l_M/2),-(b_M/2), (h_M/2),lc_M};
Point(103) = {-(l_M/2),-(b_M/2), (h_M/2),lc_M};
Point(104) = {-(l_M/2), (b_M/2), (h_M/2),lc_M};
Point(105) = { (l_M/2), (b_M/2),-(h_M/2),lc_M};
Point(106) = { (l_M/2),-(b_M/2),-(h_M/2),lc_M};
Point(107) = {-(l_M/2),-(b_M/2),-(h_M/2),lc_M};
Point(108) = {-(l_M/2), (b_M/2),-(h_M/2),lc_M};

// Edges
Line(101) = {101,102};
Line(102) = {102,103};
Line(103) = {103,104};
Line(104) = {104,101};
Line(105) = {105,106};
Line(106) = {106,107};
Line(107) = {107,108};
Line(108) = {108,105};
Line(109) = {101,105};
Line(110) = {102,106};
Line(111) = {103,107};
Line(112) = {104,108};

// Surfaces
Line Loop(113) = {105,-110,-101,109};
Plane Surface(114) = {113};
Line Loop(115) = {106,-111,-102,110};
Plane Surface(116) = {115};
Line Loop(117) = {-112,-103,111,107};
Plane Surface(118) = {117};
Line Loop(119) = {108,-109,-104,112};
Plane Surface(120) = {119};
Line Loop(121) = {101,102,103,104};
Plane Surface(122) = {121};
Line Loop(123) = {105,106,107,108};
Plane Surface(124) = {123};

// Volumes
Surface Loop(125) = {114,-124,116,118,120,122};
Complex Volume(100) = {125};
Physical Volume(101) = {100};




/* ---------------------------------------------------------------------------
   Spule
----------------------------------------------------------------------------*/

// Translation
dx = 0.0*mm;
dy = 0.0*mm;
dz = 0.0*mm;

// Points
Point(501) = {      0+dx,      0+dy,  l_S/2+dz, lc_S};
Point(502) = {      0+dx,      0+dy, -l_S/2+dz, lc_S};
Point(503) = { d_Si/2+dx,      0+dy,  l_S/2+dz, lc_S};
Point(504) = {      0+dx, d_Si/2+dy,  l_S/2+dz, lc_S};
Point(505) = {-d_Si/2+dx,      0+dy,  l_S/2+dz, lc_S};
Point(506) = {      0+dx,-d_Si/2+dy,  l_S/2+dz, lc_S};
Point(507) = { d_Si/2+dx,      0+dy, -l_S/2+dz, lc_S};
Point(508) = {      0+dx, d_Si/2+dy, -l_S/2+dz, lc_S};
Point(509) = {-d_Si/2+dx,      0+dy, -l_S/2+dz, lc_S};
Point(510) = {      0+dx,-d_Si/2+dy, -l_S/2+dz, lc_S};
Point(511) = { d_Sa/2+dx,      0+dy,  l_S/2+dz, lc_S};
Point(512) = {      0+dx, d_Sa/2+dy,  l_S/2+dz, lc_S};
Point(513) = {-d_Sa/2+dx,      0+dy,  l_S/2+dz, lc_S};
Point(514) = {      0+dx,-d_Sa/2+dy,  l_S/2+dz, lc_S};
Point(515) = { d_Sa/2+dx,      0+dy, -l_S/2+dz, lc_S};
Point(516) = {      0+dx, d_Sa/2+dy, -l_S/2+dz, lc_S};
Point(517) = {-d_Sa/2+dx,      0+dy, -l_S/2+dz, lc_S};
Point(518) = {      0+dx,-d_Sa/2+dy, -l_S/2+dz, lc_S};

// Lines
Line(501) = {511,515};
Line(502) = {514,518};
Line(503) = {513,517};
Line(504) = {512,516};
Line(505) = {503,507};
Line(506) = {506,510};
Line(507) = {505,509};
Line(508) = {504,508};
Circle(509) = {515,502,518};
Circle(510) = {507,502,510};
Circle(511) = {518,502,517};
Circle(512) = {510,502,509};
Circle(513) = {517,502,516};
Circle(514) = {509,502,508};
Circle(515) = {516,502,515};
Circle(516) = {508,502,507};
Circle(517) = {511,501,514};
Circle(518) = {503,501,506};
Circle(519) = {514,501,513};
Circle(520) = {506,501,505};
Circle(521) = {513,501,512};
Circle(522) = {505,501,504};
Circle(523) = {512,501,511};
Circle(524) = {504,501,503};

// Surfaces
Line Loop(525) = {517,519,521,523};
Line Loop(526) = {518,520,522,524};
Plane Surface(527) = {525,526};
Line Loop(528) = {509,511,513,515};
Line Loop(529) = {510,512,514,516};
Plane Surface(530) = {528,529};
Line Loop(531) = {-(502),-(517),501,509};
Ruled Surface(532) = {531};
Line Loop(533) = {-(503),-(519),502,511};
Ruled Surface(534) = {533};
Line Loop(535) = {513,-(504),-(521),503};
Ruled Surface(536) = {535};
Line Loop(537) = {515,-(501),-(523),504};
Ruled Surface(538) = {537};
Line Loop(539) = {510,-(506),-(518),505};
Ruled Surface(540) = {539};
Line Loop(541) = {512,-(507),-(520),506};
Ruled Surface(542) = {541};
Line Loop(543) = {514,-(508),-(522),507};
Ruled Surface(544) = {543};
Line Loop(545) = {516,-(505),-(524),508};
Ruled Surface(546) = {545};

// Volumes
Surface Loop(501) = {532,534,536,530,538,527,540,542,544,546};
Complex Volume(502) = {501};
Physical Volume(500) = {502};



/* ---------------------------------------------------------------------------
   Umgebung (Element-Nummernkreis 900)
----------------------------------------------------------------------------*/

// Translation
dx =  0.0*mm;
dy =  0.0*mm;
dz =  0.0*mm;

// Points (Innere Umgebung)
Point(900) = {0.0+dx,0.0+dy,0.0+dz,lc_Li};
Point(901) = {dx+r_i,dy+0.0,dz+0.0,lc_Li};
Point(902) = {0.0+dx,dy+r_i,0.0+dz,lc_Li};
Point(903) = {dx-r_i,dy+0.0,dz+0.0,lc_Li};
Point(904) = {0.0+dx,dy-r_i,0.0+dz,lc_Li};
Point(905) = {0.0+dx,dy+0.0,dz+r_i,lc_Li};
Point(906) = {0.0+dx,dy+0.0,dz-r_i,lc_Li};
// Points (Äußere Umgebung)
Point(921) = {dx+r_a,dy+0.0,dz+0.0,lc_La};
Point(922) = {0.0+dx,dy+r_a,0.0+dz,lc_La};
Point(923) = {dx-r_a,dy+0.0,dz+0.0,lc_La};
Point(924) = {0.0+dx,dy-r_a,0.0+dz,lc_La};
Point(925) = {0.0+dx,dy+0.0,dz+r_a,lc_La};
Point(926) = {0.0+dx,dy+0.0,dz-r_a,lc_La};

// Lines (Innere Umgebung)
Circle(900) = {901,900,902};
Circle(901) = {902,900,903};
Circle(902) = {903,900,904};
Circle(903) = {904,900,901};
Circle(904) = {901,900,905};
Circle(905) = {905,900,903};
Circle(906) = {903,900,906};
Circle(907) = {906,900,901};
Circle(908) = {902,900,905};
Circle(909) = {905,900,904};
Circle(910) = {904,900,906};
Circle(911) = {906,900,902};
// Lines (Äußere Umgebung)
Circle(920) = {921,900,922};
Circle(921) = {922,900,923};
Circle(922) = {923,900,924};
Circle(923) = {924,900,921};
Circle(924) = {921,900,925};
Circle(925) = {925,900,923};
Circle(926) = {923,900,926};
Circle(927) = {926,900,921};
Circle(928) = {922,900,925};
Circle(929) = {925,900,924};
Circle(930) = {924,900,926};
Circle(931) = {926,900,922};

// Surfaces (Innere Umgebung)
Line Loop(932) = {-904,900,908};
Ruled Surface(933) = {932};
Line Loop(934) = {903,904,909};
Ruled Surface(935) = {934};
Line Loop(936) = {902,-909,905};
Ruled Surface(937) = {936};
Line Loop(938) = {905,-901,908};
Ruled Surface(939) = {938};
Line Loop(940) = {-900,-907,911};
Ruled Surface(941) = {940};
Line Loop(942) = {911,901,906};
Ruled Surface(943) = {942};
Line Loop(944) = {-906,902,910};
Ruled Surface(945) = {944};
Line Loop(946) = {-903,910,907};
Ruled Surface(947) = {946};
// Surfaces (Äußere Umgebung)
Line Loop(948) = {-928,-920,924};
Ruled Surface(949) = {948};
Line Loop(950) = {925,-921,928};
Ruled Surface(951) = {950};
Line Loop(952) = {922,-929,925};
Ruled Surface(953) = {952};
Line Loop(954) = {923,924,929};
Ruled Surface(955) = {954};
Line Loop(956) = {927,-923,930};
Ruled Surface(957) = {956};
Line Loop(958) = {-930,-922,926};
Ruled Surface(959) = {958};
Line Loop(960) = {921,926,931};
Ruled Surface(961) = {960};
Line Loop(962) = {920,-931,927};
Ruled Surface(963) = {962};

// Volumes (Innere Umgebung)
Surface Loop(964) = {943,-941,-933,-935,-947,945,-937,939};
Complex Volume(965) = {964,501};
Physical Volume(901) = {965};
// Volumes (Äußere Umgebung)
Surface Loop(966) = {963,949,951,-953,-959,-957,-955,961};
Complex Volume(967) = {966,964};
Physical Volume(902) = {967};

// Boundary
Physical Surface(999) = {963,957,959,961,951,949,955,953};
