@@ -1170,23 +1170,30 @@ def Si_p(self):
11701170 semiconductor = CHARGE_SIMULATION .intrinsic_Si .charge
11711171 semiconductor = semiconductor .updated_copy (
11721172 N_a = CHARGE_SIMULATION .acceptors ,
1173+ )
1174+ return CHARGE_SIMULATION .intrinsic_Si .updated_copy (
1175+ charge = semiconductor ,
1176+ heat = td .SolidMedium (conductivity = 1 ),
11731177 name = "Si_p" ,
11741178 )
1175- return CHARGE_SIMULATION .intrinsic_Si .updated_copy (charge = semiconductor )
11761179
11771180 @pytest .fixture (scope = "class" )
11781181 def Si_n (self ):
11791182 semiconductor = CHARGE_SIMULATION .intrinsic_Si .charge
11801183 semiconductor = semiconductor .updated_copy (
11811184 N_d = CHARGE_SIMULATION .donors ,
1185+ )
1186+ return CHARGE_SIMULATION .intrinsic_Si .updated_copy (
1187+ charge = semiconductor ,
1188+ heat = td .SolidMedium (conductivity = 1 ),
11821189 name = "Si_n" ,
11831190 )
1184- return CHARGE_SIMULATION .intrinsic_Si .updated_copy (charge = semiconductor )
11851191
11861192 @pytest .fixture (scope = "class" )
11871193 def SiO2 (self ):
11881194 return td .MultiPhysicsMedium (
11891195 charge = td .ChargeInsulatorMedium (permittivity = 3.9 ),
1196+ heat = td .SolidMedium (conductivity = 2 ),
11901197 name = "SiO2" ,
11911198 )
11921199
@@ -1267,18 +1274,13 @@ def capacitance_global_mnt(self):
12671274 # Define charge settings as fixtures within the class
12681275 @pytest .fixture (scope = "class" )
12691276 def charge_tolerance (self ):
1270- return td .IsothermalSteadyChargeDCAnalysis (
1271- temperature = 300 ,
1272- tolerance_settings = td .ChargeToleranceSpec (rel_tol = 1e5 , abs_tol = 1e3 , max_iters = 400 ),
1273- fermi_dirac = True ,
1274- )
1275-
1276- @pytest .fixture (scope = "class" )
1277- def charge_dc_regime (self ):
1278- return td .DCVoltageSource (voltage = [1 ])
1277+ return td .ChargeToleranceSpec (rel_tol = 1e5 , abs_tol = 1e3 , max_iters = 400 )
12791278
12801279 def test_charge_simulation (
12811280 self ,
1281+ Si_n ,
1282+ Si_p ,
1283+ SiO2 ,
12821284 oxide ,
12831285 p_side ,
12841286 n_side ,
@@ -1288,9 +1290,14 @@ def test_charge_simulation(
12881290 bc_n ,
12891291 bc_p ,
12901292 charge_tolerance ,
1291- charge_dc_regime ,
12921293 ):
12931294 """Ensure charge simulation produces the correct errors when needed."""
1295+ # NOTE: start tests with isothermal spec
1296+ isothermal_spec = td .IsothermalSteadyChargeDCAnalysis (
1297+ temperature = 300 ,
1298+ tolerance_settings = charge_tolerance ,
1299+ fermi_dirac = True ,
1300+ )
12941301 sim = td .HeatChargeSimulation (
12951302 structures = [oxide , p_side , n_side ],
12961303 medium = td .MultiPhysicsMedium (
@@ -1301,7 +1308,7 @@ def test_charge_simulation(
13011308 size = CHARGE_SIMULATION .sim_size ,
13021309 grid_spec = td .UniformUnstructuredGrid (dl = 0.05 ),
13031310 boundary_spec = [bc_n , bc_p ],
1304- analysis_spec = charge_tolerance ,
1311+ analysis_spec = isothermal_spec ,
13051312 )
13061313
13071314 # At least one ChargeSimulationMonitor should be added
@@ -1336,6 +1343,45 @@ def test_charge_simulation(
13361343 )
13371344 _ = sim .updated_copy (boundary_spec = [new_bc_p , bc_n ])
13381345
1346+ # test non isothermal spec
1347+ non_isothermal_spec = td .SteadyChargeDCAnalysis (tolerance_settings = charge_tolerance )
1348+
1349+ sim = sim .updated_copy (analysis_spec = non_isothermal_spec )
1350+ with pytest .raises (pd .ValidationError ):
1351+ # remove heat from mediums
1352+ new_structs = []
1353+ for struct in sim .structures :
1354+ new_structs .append (
1355+ struct .updated_copy (medium = struct .medium .updated_copy (heat = None ))
1356+ )
1357+ _ = sim .updated_copy (structures = new_structs )
1358+
1359+ with pytest .raises (pd .ValidationError ):
1360+ # remove charge from mediums
1361+ new_structs = []
1362+ for struct in sim .structures :
1363+ new_structs .append (
1364+ struct .updated_copy (medium = struct .medium .updated_copy (charge = None ))
1365+ )
1366+ _ = sim .updated_copy (structures = new_structs )
1367+
1368+ with pytest .raises (pd .ValidationError ):
1369+ # make sure there is at least one semiconductor
1370+ new_structs = []
1371+ for struct in sim .structures :
1372+ if isinstance (struct .medium .charge , td .SemiconductorMedium ):
1373+ new_structs .append (
1374+ struct .updated_copy (
1375+ medium = struct .medium .updated_copy (
1376+ charge = td .ChargeInsulatorMedium (permittivity = 1 ),
1377+ heat = None ,
1378+ )
1379+ )
1380+ )
1381+ else :
1382+ new_structs .append (struct )
1383+ _ = sim .updated_copy (structures = new_structs )
1384+
13391385 def test_doping_distributions (self ):
13401386 """Test doping distributions."""
13411387 # Implementation needed
0 commit comments