@@ -220,6 +220,8 @@ def monitors():
220
220
221
221
free_carrier_mnt1 = td .SteadyFreeCarrierMonitor (size = (1.6 , 2 , 3 ), name = "carrier_test" )
222
222
223
+ energy_band_mnt1 = td .SteadyEnergyBandMonitor (size = (1.6 , 2 , 3 ), name = "bandgap_test" )
224
+
223
225
return [
224
226
temp_mnt1 ,
225
227
temp_mnt2 ,
@@ -231,6 +233,7 @@ def monitors():
231
233
volt_mnt4 ,
232
234
capacitance_mnt1 ,
233
235
free_carrier_mnt1 ,
236
+ energy_band_mnt1 ,
234
237
]
235
238
236
239
@@ -478,7 +481,7 @@ def temperature_monitor_data(monitors):
478
481
@pytest .fixture (scope = "module" )
479
482
def voltage_monitor_data (monitors ):
480
483
"""Creates different voltage monitor data."""
481
- _ , _ , _ , _ , volt_mnt1 , volt_mnt2 , volt_mnt3 , volt_mnt4 , _ , _ = monitors
484
+ _ , _ , _ , _ , volt_mnt1 , volt_mnt2 , volt_mnt3 , volt_mnt4 , _ , _ , _ = monitors
482
485
483
486
# SpatialDataArray
484
487
nx , ny , nz = 9 , 6 , 5
@@ -551,7 +554,7 @@ def voltage_monitor_data(monitors):
551
554
@pytest .fixture (scope = "module" )
552
555
def capacitance_monitor_data (monitors ):
553
556
"""Creates different voltage monitor data."""
554
- _ , _ , _ , _ , _ , _ , _ , _ , cap_mt1 , _ = monitors
557
+ cap_mt1 = monitors [ 8 ]
555
558
556
559
# SpatialDataArray
557
560
cap_data1 = td .SteadyCapacitanceData (monitor = cap_mt1 )
@@ -563,7 +566,7 @@ def capacitance_monitor_data(monitors):
563
566
@pytest .fixture (scope = "module" )
564
567
def free_carrier_monitor_data (monitors ):
565
568
"""Creates different voltage monitor data."""
566
- _ , _ , _ , _ , _ , _ , _ , _ , _ , fc_mnt = monitors
569
+ fc_mnt = monitors [ 9 ]
567
570
568
571
# SpatialDataArray
569
572
fc_data1 = td .SteadyFreeCarrierData (monitor = fc_mnt )
@@ -582,6 +585,28 @@ def free_carrier_monitor_data(monitors):
582
585
return (fc_data1 ,)
583
586
584
587
588
+ @pytest .fixture (scope = "module" )
589
+ def energy_band_monitor_data (monitors ):
590
+ """Creates different voltage monitor data."""
591
+ eb_mnt = monitors [10 ]
592
+
593
+ # SpatialDataArray
594
+ eb_data1 = td .SteadyEnergyBandData (monitor = eb_mnt )
595
+ eb_data2 = eb_data1 .symmetry_expanded_copy
596
+ assert eb_data2 is not None
597
+
598
+ field_components = eb_data1 .field_components
599
+
600
+ eb_fields = eb_data1 .field_name ("abs^2" )
601
+ assert eb_fields is not None
602
+ eb_fields_default = eb_data1 .field_name ()
603
+ assert eb_fields_default is not None
604
+
605
+ assert field_components is not None
606
+
607
+ return (eb_data1 ,)
608
+
609
+
585
610
@pytest .fixture (scope = "module" )
586
611
def simulation_data (
587
612
heat_simulation ,
@@ -592,6 +617,7 @@ def simulation_data(
592
617
voltage_monitor_data ,
593
618
capacitance_monitor_data ,
594
619
free_carrier_monitor_data ,
620
+ energy_band_monitor_data ,
595
621
):
596
622
"""Creates 'HeatChargeSimulationData' for both Heat and Conduction simulations."""
597
623
heat_sim_data = td .HeatChargeSimulationData (
@@ -1325,6 +1351,181 @@ def test_plotting_functions(simulation_data):
1325
1351
heat_sim_data .plot_field ("test" , invalid_param = 0 )
1326
1352
1327
1353
1354
+ def test_bandgap_monitor ():
1355
+ """Test energy bandgap monitor ploting function."""
1356
+ # create a triangle grid
1357
+ tri_grid_points = td .PointDataArray (
1358
+ [[0.0 , 0.0 ], [1.0 , 0.0 ], [0.0 , 1.0 ], [1.0 , 1.0 ]],
1359
+ dims = ("index" , "axis" ),
1360
+ )
1361
+
1362
+ tri_grid_cells = td .CellDataArray (
1363
+ [[0 , 1 , 2 ], [1 , 2 , 3 ]],
1364
+ dims = ("cell_index" , "vertex_index" ),
1365
+ )
1366
+
1367
+ tri_grid_values_single_voltage = td .IndexedVoltageDataArray (
1368
+ [[0.0 ], [0 ], [3 ], [3 ]],
1369
+ coords = dict (index = np .arange (4 ), voltage = [1 ]),
1370
+ name = "test" ,
1371
+ )
1372
+
1373
+ tri_grid_values_multi_voltage = td .IndexedVoltageDataArray (
1374
+ [[0.0 , 0.0 ], [0 , 0 ], [3 , - 3 ], [3 , - 3 ]],
1375
+ coords = dict (index = np .arange (4 ), voltage = [- 1 , 1 ]),
1376
+ name = "test" ,
1377
+ )
1378
+
1379
+ tri_grid_single_voltage = td .TriangularGridDataset (
1380
+ normal_axis = 1 ,
1381
+ normal_pos = 0 ,
1382
+ points = tri_grid_points ,
1383
+ cells = tri_grid_cells ,
1384
+ values = tri_grid_values_single_voltage ,
1385
+ )
1386
+
1387
+ tri_grid_multi_voltage = td .TriangularGridDataset (
1388
+ normal_axis = 1 ,
1389
+ normal_pos = 0 ,
1390
+ points = tri_grid_points ,
1391
+ cells = tri_grid_cells ,
1392
+ values = tri_grid_values_multi_voltage ,
1393
+ )
1394
+
1395
+ # create a tet mesh
1396
+ tet_grid_points = td .PointDataArray (
1397
+ [
1398
+ [0.0 , 0.0 , 0.0 ],
1399
+ [1.0 , 0.0 , 0.0 ],
1400
+ [0.0 , 1.0 , 0.0 ],
1401
+ [1.0 , 1.0 , 0.0 ],
1402
+ [0.0 , 0.0 , 1.0 ],
1403
+ [1.0 , 0.0 , 1.0 ],
1404
+ [0.0 , 1.0 , 1.0 ],
1405
+ [1.0 , 1.0 , 1.0 ],
1406
+ ],
1407
+ dims = ("index" , "axis" ),
1408
+ )
1409
+
1410
+ tet_grid_cells = td .CellDataArray (
1411
+ [[0 , 1 , 3 , 7 ], [0 , 2 , 7 , 3 ], [0 , 2 , 6 , 7 ], [0 , 4 , 7 , 6 ], [0 , 4 , 5 , 7 ], [0 , 1 , 7 , 5 ]],
1412
+ dims = ("cell_index" , "vertex_index" ),
1413
+ )
1414
+
1415
+ tet_grid_values_single_voltage = td .IndexedVoltageDataArray (
1416
+ [[0.0 ], [0.0 ], [0.0 ], [0.0 ], [3.0 ], [3.0 ], [3.0 ], [3.0 ]],
1417
+ coords = dict (index = np .arange (8 ), voltage = [1 ]),
1418
+ name = "test_tet" ,
1419
+ )
1420
+
1421
+ tet_grid_values_multi_voltage = td .IndexedVoltageDataArray (
1422
+ [
1423
+ [0.0 , 0.5 ],
1424
+ [0.0 , 0.5 ],
1425
+ [0.0 , 0.5 ],
1426
+ [0.0 , 0.5 ],
1427
+ [3.0 , 3.5 ],
1428
+ [3.0 , 3.5 ],
1429
+ [3.0 , 3.5 ],
1430
+ [3.0 , 3.5 ],
1431
+ ],
1432
+ coords = dict (index = np .arange (8 ), voltage = [- 1 , 1 ]),
1433
+ name = "test_tet" ,
1434
+ )
1435
+
1436
+ tet_grid_single_voltage = td .TetrahedralGridDataset (
1437
+ points = tet_grid_points ,
1438
+ cells = tet_grid_cells ,
1439
+ values = tet_grid_values_single_voltage ,
1440
+ )
1441
+
1442
+ tet_grid_multi_voltage = td .TetrahedralGridDataset (
1443
+ points = tet_grid_points ,
1444
+ cells = tet_grid_cells ,
1445
+ values = tet_grid_values_multi_voltage ,
1446
+ )
1447
+
1448
+ aux_monitor_2D = td .SteadyEnergyBandMonitor (
1449
+ center = (0 , 0.14 , 0 ), size = (0.6 , 0.3 , 0 ), name = "bands_2D" , unstructured = True
1450
+ )
1451
+
1452
+ aux_monitor_3D = td .SteadyEnergyBandMonitor (
1453
+ center = (0 , 0.14 , 0.0 ), size = (0.6 , 0.3 , 0.5 ), name = "bands_3D" , unstructured = True
1454
+ )
1455
+
1456
+ tri_single_voltage_data = td .SteadyEnergyBandData (
1457
+ monitor = aux_monitor_2D ,
1458
+ Ec = tri_grid_single_voltage ,
1459
+ Ev = tri_grid_single_voltage ,
1460
+ Ei = tri_grid_single_voltage ,
1461
+ Efn = tri_grid_single_voltage ,
1462
+ Efp = tri_grid_single_voltage ,
1463
+ )
1464
+
1465
+ tri_multi_voltage_data = td .SteadyEnergyBandData (
1466
+ monitor = aux_monitor_2D ,
1467
+ Ec = tri_grid_multi_voltage ,
1468
+ Ev = tri_grid_multi_voltage ,
1469
+ Ei = tri_grid_multi_voltage ,
1470
+ Efn = tri_grid_multi_voltage ,
1471
+ Efp = tri_grid_multi_voltage ,
1472
+ )
1473
+
1474
+ tet_single_voltage_data = td .SteadyEnergyBandData (
1475
+ monitor = aux_monitor_3D ,
1476
+ Ec = tet_grid_single_voltage ,
1477
+ Ev = tet_grid_single_voltage ,
1478
+ Ei = tet_grid_single_voltage ,
1479
+ Efn = tet_grid_single_voltage ,
1480
+ Efp = tet_grid_single_voltage ,
1481
+ )
1482
+
1483
+ tet_multi_voltage_data = td .SteadyEnergyBandData (
1484
+ monitor = aux_monitor_3D ,
1485
+ Ec = tet_grid_multi_voltage ,
1486
+ Ev = tet_grid_multi_voltage ,
1487
+ Ei = tet_grid_multi_voltage ,
1488
+ Efn = tet_grid_multi_voltage ,
1489
+ Efp = tet_grid_multi_voltage ,
1490
+ )
1491
+
1492
+ # test check for the voltage value in the list of arguments
1493
+
1494
+ tri_single_voltage_data .plot (x = 0.0 )
1495
+ tri_multi_voltage_data .plot (x = 0.0 , voltage = 1.0 )
1496
+
1497
+ with pytest .raises (DataError ):
1498
+ tri_multi_voltage_data .plot (x = 0.0 )
1499
+
1500
+ tet_single_voltage_data .plot (x = 0.0 , y = 0.0 )
1501
+ tet_multi_voltage_data .plot (x = 0.0 , y = 0.0 , voltage = 1.0 )
1502
+
1503
+ with pytest .raises (DataError ):
1504
+ tri_multi_voltage_data .plot (x = 0.0 , y = 0.0 )
1505
+
1506
+ # test check for the number of coordinates in the list of arguments
1507
+
1508
+ with pytest .raises (DataError ):
1509
+ tri_single_voltage_data .plot ()
1510
+
1511
+ with pytest .raises (DataError ):
1512
+ tri_single_voltage_data .plot (x = 0.0 , y = 0.0 )
1513
+
1514
+ with pytest .raises (DataError ):
1515
+ tet_single_voltage_data .plot ()
1516
+
1517
+ with pytest .raises (DataError ):
1518
+ tet_single_voltage_data .plot (x = 0.0 )
1519
+
1520
+ with pytest .raises (DataError ):
1521
+ tet_single_voltage_data .plot (x = 0.0 , y = 0.0 , z = 0.0 )
1522
+
1523
+ # test check for the incorrect cross-section plane
1524
+
1525
+ with pytest .raises (DataError ):
1526
+ tri_single_voltage_data .plot (y = 0.0 )
1527
+
1528
+
1328
1529
def test_additional_edge_cases ():
1329
1530
"""Test additional edge cases and error handling."""
1330
1531
# Attempt to create a monitor with zero size
0 commit comments