@@ -1241,8 +1241,8 @@ def get_universe_index(self, idx):
1241
1241
else :
1242
1242
i_within = 5 * g - z
1243
1243
1244
- if ( self ._orientation == 'x' ) and ( i_within > 0 ) :
1245
- i_within = 6 * ( self . _num_rings - i_ring - 1 ) - i_within_
1244
+ if self ._orientation == 'x' and g > 0 :
1245
+ i_within = ( i_within + 5 * g ) % ( 6 * g )
1246
1246
1247
1247
if self .num_axial is None :
1248
1248
return (i_ring , i_within )
@@ -1376,6 +1376,7 @@ def from_xml_element(cls, elem, get_universe):
1376
1376
lat = cls (lat_id , name )
1377
1377
lat .center = [float (i ) for i in get_text (elem , 'center' ).split ()]
1378
1378
lat .pitch = [float (i ) for i in get_text (elem , 'pitch' ).split ()]
1379
+ lat .orientation = get_text (elem , 'orientation' , 'y' )
1379
1380
outer = get_text (elem , 'outer' )
1380
1381
if outer is not None :
1381
1382
lat .outer = get_universe (int (outer ))
@@ -1390,7 +1391,7 @@ def from_xml_element(cls, elem, get_universe):
1390
1391
if n_axial > 1 :
1391
1392
univs = [deepcopy (univs ) for i in range (n_axial )]
1392
1393
1393
- # Get flat array of universes numbers
1394
+ # Get flat array of universes
1394
1395
uarray = np .array ([get_universe (int (i )) for i in
1395
1396
get_text (elem , 'universes' ).split ()])
1396
1397
@@ -1400,28 +1401,53 @@ def from_xml_element(cls, elem, get_universe):
1400
1401
# Get list for a single axial level
1401
1402
axial_level = univs [z ] if n_axial > 1 else univs
1402
1403
1403
- # Start iterating from top
1404
- x , alpha = 0 , n_rings - 1
1405
- while True :
1406
- # Set entry in list based on (x,alpha,z) coordinates
1407
- _ , i_ring , i_within = lat .get_universe_index ((x , alpha , z ))
1408
- axial_level [i_ring ][i_within ] = uarray [j ]
1409
-
1410
- # Move to the right
1411
- x += 2
1412
- alpha -= 1
1413
- if not lat .is_valid_index ((x , alpha , z )):
1414
- # Move down in y direction
1415
- alpha += x - 1
1416
- x = 1 - x
1404
+ if lat .orientation == 'y' :
1405
+ # Start iterating from top
1406
+ x , alpha = 0 , n_rings - 1
1407
+ while True :
1408
+ # Set entry in list based on (x,alpha,z) coordinates
1409
+ _ , i_ring , i_within = lat .get_universe_index ((x , alpha , z ))
1410
+ axial_level [i_ring ][i_within ] = uarray [j ]
1411
+
1412
+ # Move to the right
1413
+ x += 2
1414
+ alpha -= 1
1417
1415
if not lat .is_valid_index ((x , alpha , z )):
1418
- # Move to the right
1419
- x += 2
1420
- alpha - = 1
1416
+ # Move down in y direction
1417
+ alpha += x - 1
1418
+ x = 1 - x
1421
1419
if not lat .is_valid_index ((x , alpha , z )):
1422
- # Reached the bottom
1420
+ # Move to the right
1421
+ x += 2
1422
+ alpha -= 1
1423
+ if not lat .is_valid_index ((x , alpha , z )):
1424
+ # Reached the bottom
1425
+ break
1426
+ j += 1
1427
+ else :
1428
+ # Start iterating from top
1429
+ alpha , y = 1 - n_rings , n_rings - 1
1430
+ while True :
1431
+ # Set entry in list based on (alpha,y,z) coordinates
1432
+ _ , i_ring , i_within = lat .get_universe_index ((alpha , y , z ))
1433
+ axial_level [i_ring ][i_within ] = uarray [j ]
1434
+
1435
+ # Move to the right
1436
+ alpha += 1
1437
+ if not lat .is_valid_index ((alpha , y , z )):
1438
+ # Move down to next row
1439
+ alpha = 1 - n_rings
1440
+ y -= 1
1441
+
1442
+ # Check if we've reached the bottom
1443
+ if y == - n_rings :
1423
1444
break
1424
- j += 1
1445
+
1446
+ while not lat .is_valid_index ((alpha , y , z )):
1447
+ # Move to the right
1448
+ alpha += 1
1449
+ j += 1
1450
+
1425
1451
lat .universes = univs
1426
1452
return lat
1427
1453
@@ -1469,7 +1495,7 @@ def _repr_axial_slice_x(self, universes):
1469
1495
theta = 0
1470
1496
y = middle
1471
1497
1472
- # Climb up the top -right.
1498
+ # Climb down the bottom -right
1473
1499
for i in range (r ):
1474
1500
# Add the universe.
1475
1501
universe = universes [r_prime ][theta ]
@@ -1479,7 +1505,7 @@ def _repr_axial_slice_x(self, universes):
1479
1505
y += 1
1480
1506
theta += 1
1481
1507
1482
- # Climb left the top-left.
1508
+ # Climb left across the bottom
1483
1509
for i in range (r ):
1484
1510
# Add the universe.
1485
1511
universe = universes [r_prime ][theta ]
@@ -1488,7 +1514,7 @@ def _repr_axial_slice_x(self, universes):
1488
1514
# Translate the indices.
1489
1515
theta += 1
1490
1516
1491
- # Climb down the middle left.
1517
+ # Climb up the bottom- left
1492
1518
for i in range (r ):
1493
1519
# Add the universe.
1494
1520
universe = universes [r_prime ][theta ]
@@ -1498,7 +1524,7 @@ def _repr_axial_slice_x(self, universes):
1498
1524
y -= 1
1499
1525
theta += 1
1500
1526
1501
- # Climb down the down left.
1527
+ # Climb up the top- left
1502
1528
for i in range (r ):
1503
1529
# Add the universe.
1504
1530
universe = universes [r_prime ][theta ]
@@ -1508,7 +1534,7 @@ def _repr_axial_slice_x(self, universes):
1508
1534
y -= 1
1509
1535
theta += 1
1510
1536
1511
- # Climb right the down right.
1537
+ # Climb right across the top
1512
1538
for i in range (r ):
1513
1539
# Add the universe.
1514
1540
universe = universes [r_prime ][theta ]
@@ -1517,7 +1543,7 @@ def _repr_axial_slice_x(self, universes):
1517
1543
# Translate the indices.
1518
1544
theta += 1
1519
1545
1520
- # Climb up the middle -right.
1546
+ # Climb down the top -right
1521
1547
for i in range (r ):
1522
1548
# Add the universe.
1523
1549
universe = universes [r_prime ][theta ]
@@ -1528,7 +1554,7 @@ def _repr_axial_slice_x(self, universes):
1528
1554
theta += 1
1529
1555
1530
1556
# Flip the rows and join each row into a single string.
1531
- rows = [pad .join (x ) for x in rows [:: - 1 ] ]
1557
+ rows = [pad .join (x ) for x in rows ]
1532
1558
1533
1559
# Pad the beginning of the rows so they line up properly.
1534
1560
for y in range (self ._num_rings - 1 ):
@@ -1806,41 +1832,41 @@ def _show_indices_x(num_rings):
1806
1832
y = middle
1807
1833
1808
1834
for i in range (r ):
1809
- # Climb up the top -right.
1835
+ # Climb down the bottom -right
1810
1836
rows [y ].append (str_form .format (r_prime , theta ))
1811
1837
y += 1
1812
1838
theta += 1
1813
1839
1814
1840
for i in range (r ):
1815
- # Climb left the top-left.
1841
+ # Climb left across the bottom
1816
1842
rows [y ].insert (0 , str_form .format (r_prime , theta ))
1817
1843
theta += 1
1818
1844
1819
1845
for i in range (r ):
1820
- # Climb down the middle left.
1846
+ # Climb up the bottom- left
1821
1847
rows [y ].insert (0 , str_form .format (r_prime , theta ))
1822
1848
y -= 1
1823
1849
theta += 1
1824
1850
1825
1851
for i in range (r ):
1826
- # Climb down the down left.
1852
+ # Climb up the top- left
1827
1853
rows [y ].insert (0 , str_form .format (r_prime , theta ))
1828
1854
y -= 1
1829
1855
theta += 1
1830
1856
1831
1857
for i in range (r ):
1832
- # Climb right the down right.
1858
+ # Climb right across the top
1833
1859
rows [y ].append (str_form .format (r_prime , theta ))
1834
1860
theta += 1
1835
1861
1836
1862
for i in range (r ):
1837
- # Climb up the middle -right.
1863
+ # Climb down the top -right
1838
1864
rows [y ].append (str_form .format (r_prime , theta ))
1839
1865
y += 1
1840
1866
theta += 1
1841
1867
1842
1868
# Flip the rows and join each row into a single string.
1843
- rows = [pad .join (x ) for x in rows [:: - 1 ] ]
1869
+ rows = [pad .join (x ) for x in rows ]
1844
1870
1845
1871
# Pad the beginning of the rows so they line up properly.
1846
1872
for y in range (num_rings - 1 ):
0 commit comments