Geometry¶
Import Libraries¶
import os
from pathlib import Path
import numpy as np
import scrapbook as sb
import plotly.offline as po
po.init_notebook_mode(connected=False)
from magnumapi.cadata.CableDatabase import CableDatabase
from magnumapi.geometry.Geometry import HomogenizedCosThetaGeometry
from magnumapi.geometry.GeometryFactory import GeometryFactory
from magnumapi.geometry.GeometryCheck import GeometryCheck
Analysis executed on 2021-12-14 15:04:42
Loaded MagNum API version 0.1.29
Input Parameters¶
cadata_abs_path = os.path.join(Path(os.getcwd()).parent.absolute(), 'input/roxieold_2.cadata')
model_input_rel_path = '../input/SM_CT_exe.json'
full_output = True
Read Geometry¶
cadata = CableDatabase.read_cadata(cadata_abs_path)
geometry = GeometryFactory.init_slotted_with_json(model_input_rel_path, cadata)
roxie_df = geometry.to_block_df()
roxie_df
no | type | nco | radius | phi_r | alpha_r | current | condname | n1 | n2 | imag | turn | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1 | 1 | 4 | 26.0 | 1.101910 | 0.0 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
1 | 2 | 1 | 2 | 26.0 | 3.000000 | 10.5 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
2 | 3 | 1 | 2 | 26.0 | 2.000000 | 12.0 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
3 | 4 | 1 | 2 | 26.0 | 3.500000 | 8.0 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
4 | 5 | 1 | 2 | 26.0 | 5.500000 | 15.0 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
5 | 6 | 1 | 2 | 42.5 | 0.674084 | 0.0 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
6 | 7 | 1 | 2 | 42.5 | 1.500000 | 6.0 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
7 | 8 | 1 | 3 | 42.5 | 3.300000 | 7.8 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
8 | 9 | 1 | 3 | 42.5 | 3.500000 | 8.0 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
9 | 10 | 1 | 2 | 42.5 | 4.000000 | 7.0 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
10 | 11 | 1 | 2 | 42.5 | 2.800000 | 6.8 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
11 | 12 | 1 | 2 | 42.5 | 2.200000 | 1.2 | 15901 | FERMIHFC | 2 | 14 | 0 | 0 |
12 | 13 | 1 | 3 | 59.0 | 0.485563 | 0.0 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
13 | 14 | 1 | 3 | 59.0 | 4.000000 | 5.0 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
14 | 15 | 1 | 3 | 59.0 | 5.000000 | 5.0 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
15 | 16 | 1 | 4 | 59.0 | 5.000000 | 4.5 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
16 | 17 | 1 | 4 | 59.0 | 4.000000 | 4.5 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
17 | 18 | 1 | 4 | 59.0 | 4.000000 | 4.5 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
18 | 19 | 1 | 2 | 59.0 | 1.000000 | 3.0 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
19 | 20 | 1 | 4 | 75.5 | 0.379445 | 0.0 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
20 | 21 | 1 | 4 | 75.5 | 6.500000 | 7.0 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
21 | 22 | 1 | 4 | 75.5 | 9.000000 | 8.5 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
22 | 23 | 1 | 4 | 75.5 | 8.500000 | 8.0 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
23 | 24 | 1 | 6 | 75.5 | 5.800000 | 3.0 | 15901 | FERMILFC | 2 | 20 | 0 | 0 |
Plot Geometry¶
geometry.build_blocks()
if full_output:
geometry.plotly_blocks(figsize=(750, 750), xlim=(0, 95), ylim=(0, 95))
Build Homogenized Geometry¶
homo_geometry = geometry.homogenize()
homo_geometry.build_blocks()
if full_output:
homo_geometry.plotly_blocks(figsize=(750, 750), xlim=(0, 95), ylim=(0, 95))
Check Geometry¶
if GeometryCheck.are_turns_overlapping(geometry):
raise Exception('Inconsistent geometry - turns are overlapping')
if GeometryCheck.is_wedge_tip_too_sharp(geometry, min_value_in_mm=0.5):
raise Exception('Inconsistent geometry - wedge tip length too sharp')
if GeometryCheck.is_outside_of_first_quadrant(geometry):
raise Exception('Inconsistent geometry - some turns are outside of the first quadrant')
if GeometryCheck.is_bending_radius_too_small(geometry, angle_bending_deg_min=10):
raise Exception('Inconsistent geometry - the positioning angle (phi) of the last turn of a last block is less than min angle')
Save Figures of Merit as an Output¶
sb.glue('model_results', data={}, encoder='json')
!jupyter nbconvert --to html $'Geometry.ipynb' --output $'Geometry.html'
[NbConvertApp] Converting notebook Geometry.ipynb to html
/Users/auchmann/opt/anaconda3/lib/python3.8/site-packages/nbconvert/filters/widgetsdatatypefilter.py:69: UserWarning: Your element with mimetype(s) dict_keys(['application/scrapbook.scrap.json+json']) is not able to be represented.
warn("Your element with mimetype(s) {mimetypes}"
[NbConvertApp] Writing 11417969 bytes to Geometry.html