@@ -1414,6 +1414,33 @@ def __init__(self, app, name, props=None, boundarytype=None):
1414
1414
self .type = boundarytype
1415
1415
self ._boundary_name = self .name
1416
1416
self .auto_update = True
1417
+ self .__reduced_matrices = None
1418
+ self .matrix_assignment = None
1419
+
1420
+ @property
1421
+ def reduced_matrices (self ):
1422
+ """List of reduced matrix groups for the parent matrix.
1423
+
1424
+ Returns
1425
+ -------
1426
+ dict
1427
+ Dictionary of reduced matrices where the key is the name of the parent matrix
1428
+ and the values are in a list of reduced matrix groups.
1429
+ """
1430
+ if self ._app .solution_type == "EddyCurrent" :
1431
+ self .__reduced_matrices = {}
1432
+ cc = self ._app .odesign .GetChildObject ("Parameters" )
1433
+ parents = cc .GetChildNames ()
1434
+ if self .name in parents :
1435
+ parent_object = self ._app .odesign .GetChildObject ("Parameters" ).GetChildObject (self .name )
1436
+ parent_type = parent_object .GetPropValue ("Type" )
1437
+ if parent_type == "Matrix" :
1438
+ self .matrix_assignment = parent_object .GetPropValue ("Selection" ).split ("," )
1439
+ child_names = parent_object .GetChildNames ()
1440
+ self .__reduced_matrices = []
1441
+ for r in child_names :
1442
+ self .__reduced_matrices .append (MaxwellMatrix (self ._app , self .name , r ))
1443
+ return self .__reduced_matrices
1417
1444
1418
1445
@property
1419
1446
def object_properties (self ):
@@ -1530,6 +1557,9 @@ def update(self):
1530
1557
1531
1558
@pyaedt_function_handler ()
1532
1559
def _create_matrix_reduction (self , red_type , sources , matrix_name = None , join_name = None ):
1560
+ if not self ._app .solution_type == "EddyCurrent" :
1561
+ self ._app .logger .error ("Matrix reduction is possible only in Eddy current solvers." )
1562
+ return False , False
1533
1563
if not matrix_name :
1534
1564
matrix_name = generate_unique_name ("ReducedMatrix" , n = 3 )
1535
1565
if not join_name :
@@ -1592,8 +1622,94 @@ def join_parallel(self, sources, matrix_name=None, join_name=None):
1592
1622
)
1593
1623
1594
1624
1625
+ class MaxwellMatrix (object ):
1626
+ def __init__ (self , app , parent_name , reduced_name ):
1627
+ self ._app = app
1628
+ self .parent_matrix = parent_name
1629
+ self .name = reduced_name
1630
+ self .__sources = None
1631
+
1632
+ @property
1633
+ def sources (self ):
1634
+ """List of matrix sources."""
1635
+ if self ._app .solution_type == "EddyCurrent" :
1636
+ sources = (
1637
+ self ._app .odesign .GetChildObject ("Parameters" )
1638
+ .GetChildObject (self .parent_matrix )
1639
+ .GetChildObject (self .name )
1640
+ .GetChildNames ()
1641
+ )
1642
+ self .__sources = {}
1643
+ for s in sources :
1644
+ excitations = (
1645
+ self ._app .odesign .GetChildObject ("Parameters" )
1646
+ .GetChildObject (self .parent_matrix )
1647
+ .GetChildObject (self .name )
1648
+ .GetChildObject (s )
1649
+ .GetPropValue ("Source" )
1650
+ )
1651
+ self .__sources [s ] = excitations
1652
+ return self .__sources
1653
+
1654
+ @pyaedt_function_handler ()
1655
+ def update (self , old_source , source_type , new_source = None , new_excitations = None ):
1656
+ """Update the reduced matrix.
1657
+
1658
+ Parameters
1659
+ ----------
1660
+ old_source : str
1661
+ Original name of the source to update.
1662
+ source_type : str
1663
+ Source type, which can be ``Series`` or ``Parallel``.
1664
+ new_source : str, optional
1665
+ New name of the source to update.
1666
+ The default value is the old source name.
1667
+ new_excitations : str, optional
1668
+ List of excitations to include in the matrix reduction.
1669
+ The default values are excitations included in the source to update.
1670
+
1671
+ Returns
1672
+ -------
1673
+ bool
1674
+ ``True`` when successful, ``False`` when failed.
1675
+ """
1676
+ if old_source not in self .sources .keys ():
1677
+ self ._app .logger .error ("Source does not exist." )
1678
+ return False
1679
+ else :
1680
+ new_excitations = self .sources [old_source ] if not new_excitations else new_excitations
1681
+ if source_type .lower () not in ["series" , "parallel" ]:
1682
+ self ._app .logger .error ("Join type not valid." )
1683
+ return False
1684
+ if not new_source :
1685
+ new_source = old_source
1686
+ args = ["NAME:" + new_source , "Type:=" , "Join in " + source_type , "Sources:=" , new_excitations ]
1687
+ self ._app .o_maxwell_parameters .EditReduceOp (self .parent_matrix , self .name , old_source , args )
1688
+ return True
1689
+
1690
+ @pyaedt_function_handler ()
1691
+ def delete (self , source ):
1692
+ """Delete a specified source in a reduced matrix.
1693
+
1694
+ Parameters
1695
+ ----------
1696
+ source : string
1697
+ Name of the source to delete.
1698
+
1699
+ Returns
1700
+ -------
1701
+ bool
1702
+ ``True`` when successful, ``False`` when failed.
1703
+ """
1704
+ if source not in self .sources .keys ():
1705
+ self ._app .logger .error ("Invalid source name." )
1706
+ return False
1707
+ self ._app .o_maxwell_parameters .DeleteReduceOp (self .parent_matrix , self .name , source )
1708
+ return True
1709
+
1710
+
1595
1711
class FieldSetup (BoundaryCommon , object ):
1596
- """Manages Far Field and Near Field Component data and execution.
1712
+ """Manages far field and near field component data and execution.
1597
1713
1598
1714
Examples
1599
1715
--------
0 commit comments