@@ -897,6 +897,38 @@ def test_heat_charge_bcs_validation(boundary_conditions):
897
897
with pytest .raises (pd .ValidationError ):
898
898
td .VoltageBC (source = td .DCVoltageSource (voltage = np .array ([td .inf , 0 , 1 ])))
899
899
900
+ # Invalid ACVoltageSource: infinite voltage
901
+ with pytest .raises (pd .ValidationError ):
902
+ td .VoltageBC (
903
+ source = td .ACVoltageSource (
904
+ voltage = np .array ([td .inf , 0 , 1 ]), frequency = [1e2 , 1e3 ], amplitude = 1e-2
905
+ )
906
+ )
907
+
908
+ # Invalid ACVoltageSource: infinite frequency
909
+ with pytest .raises (pd .ValidationError ):
910
+ td .VoltageBC (
911
+ source = td .ACVoltageSource (
912
+ voltage = np .array ([- 0.1 , 0.2 , 0.3 ]), frequency = [1e2 , td .inf , 1e4 ], amplitude = 1e-2
913
+ )
914
+ )
915
+
916
+ # Invalid ACVoltageSource: negative frequency
917
+ with pytest .raises (pd .ValidationError ):
918
+ td .VoltageBC (
919
+ source = td .ACVoltageSource (
920
+ voltage = np .array ([- 0.1 , 0.2 , 0.3 ]), frequency = [- 1e2 , 1e1 , 1e2 ], amplitude = 1e-2
921
+ )
922
+ )
923
+
924
+ # Invalid ACVoltageSource: infinite amplitude
925
+ with pytest .raises (pd .ValidationError ):
926
+ td .VoltageBC (
927
+ source = td .ACVoltageSource (
928
+ voltage = np .array ([- 0.1 , 0.2 , 0.3 ]), frequency = [1e2 , 1e3 , 1e4 ], amplitude = td .inf
929
+ )
930
+ )
931
+
900
932
901
933
def test_vertical_natural_convection ():
902
934
solid_box_l = td .Box (center = (0 , 0 , 0 ), size = (2 , 2 , 2 ))
@@ -1220,6 +1252,54 @@ def test_heat_charge_simulation(simulation_data):
1220
1252
assert mesher is not None , "VolumeMesher should be created successfully."
1221
1253
1222
1254
1255
+ def test_heat_charge_multiple_ac_sources (grid_specs ):
1256
+ """Tests that a ValidationError is raised when multiple AC sources are defined."""
1257
+ solid_box_1 = td .Box (center = (0 , 0 , 0 ), size = (2 , 2 , 2 ))
1258
+ solid_box_2 = td .Box (center = (2 , 2 , 2 ), size = (2 , 2 , 2 ))
1259
+ solid_box_3 = td .Box (center = (4 , 4 , 4 ), size = (2 , 2 , 2 ))
1260
+
1261
+ solid_medium = td .MultiPhysicsMedium (
1262
+ heat = td .SolidMedium (conductivity = 1 , capacity = 1 ), name = "solid"
1263
+ )
1264
+ air = td .MultiPhysicsMedium (heat = td .FluidMedium (), name = "air" )
1265
+
1266
+ def createSolid (geometry , name ):
1267
+ return td .Structure (geometry = geometry , medium = solid_medium , name = name )
1268
+
1269
+ solid_structure_1 = createSolid (solid_box_1 , "solid_1" )
1270
+ solid_structure_2 = createSolid (solid_box_2 , "solid_2" )
1271
+ solid_structure_3 = createSolid (solid_box_3 , "solid_3" )
1272
+
1273
+ bc_ssac1 = td .VoltageBC (
1274
+ source = td .ACVoltageSource (
1275
+ voltage = [0 , 1 ], frequency = [1e3 , 1e4 ], amplitude = 1e-3 , name = "ac_source1"
1276
+ )
1277
+ )
1278
+ bc_ssac2 = td .VoltageBC (
1279
+ source = td .ACVoltageSource (
1280
+ voltage = [0 , 1 ], frequency = [1e3 , 1e4 ], amplitude = 1e-3 , name = "ac_source2"
1281
+ )
1282
+ )
1283
+
1284
+ placement1 = td .StructureStructureInterface (structures = ["solid_1" , "solid_2" ])
1285
+ placement2 = td .StructureStructureInterface (structures = ["solid_2" , "solid_3" ])
1286
+
1287
+ boundary_spec = [
1288
+ td .HeatChargeBoundarySpec (condition = bc_ssac1 , placement = placement1 ),
1289
+ td .HeatChargeBoundarySpec (condition = bc_ssac2 , placement = placement2 ),
1290
+ ]
1291
+
1292
+ with pytest .raises (pd .ValidationError , match = "Only a single AC source can be supplied" ):
1293
+ td .HeatChargeSimulation (
1294
+ structures = [solid_structure_1 , solid_structure_2 , solid_structure_3 ],
1295
+ center = (2 , 2 , 2 ),
1296
+ size = (6 , 6 , 6 ),
1297
+ boundary_spec = boundary_spec ,
1298
+ medium = air ,
1299
+ grid_spec = grid_specs ["uniform" ],
1300
+ )
1301
+
1302
+
1223
1303
def test_sim_data_plotting (simulation_data ):
1224
1304
"""Tests whether simulation data can be plotted and appropriate errors are raised."""
1225
1305
heat_sim_data , cond_sim_data , cap_sim_data , fc_sim_data , mesh_data = simulation_data
0 commit comments