@@ -952,23 +952,30 @@ def Si_p(self):
952
952
semiconductor = CHARGE_SIMULATION .intrinsic_Si .charge
953
953
semiconductor = semiconductor .updated_copy (
954
954
N_a = CHARGE_SIMULATION .acceptors ,
955
+ )
956
+ return CHARGE_SIMULATION .intrinsic_Si .updated_copy (
957
+ charge = semiconductor ,
958
+ heat = td .SolidMedium (conductivity = 1 ),
955
959
name = "Si_p" ,
956
960
)
957
- return CHARGE_SIMULATION .intrinsic_Si .updated_copy (charge = semiconductor )
958
961
959
962
@pytest .fixture (scope = "class" )
960
963
def Si_n (self ):
961
964
semiconductor = CHARGE_SIMULATION .intrinsic_Si .charge
962
965
semiconductor = semiconductor .updated_copy (
963
966
N_d = CHARGE_SIMULATION .donors ,
967
+ )
968
+ return CHARGE_SIMULATION .intrinsic_Si .updated_copy (
969
+ charge = semiconductor ,
970
+ heat = td .SolidMedium (conductivity = 1 ),
964
971
name = "Si_n" ,
965
972
)
966
- return CHARGE_SIMULATION .intrinsic_Si .updated_copy (charge = semiconductor )
967
973
968
974
@pytest .fixture (scope = "class" )
969
975
def SiO2 (self ):
970
976
return td .MultiPhysicsMedium (
971
977
charge = td .ChargeInsulatorMedium (permittivity = 3.9 ),
978
+ heat = td .SolidMedium (conductivity = 2 ),
972
979
name = "SiO2" ,
973
980
)
974
981
@@ -1049,18 +1056,13 @@ def capacitance_global_mnt(self):
1049
1056
# Define charge settings as fixtures within the class
1050
1057
@pytest .fixture (scope = "class" )
1051
1058
def charge_tolerance (self ):
1052
- return td .IsothermalSteadyChargeDCAnalysis (
1053
- temperature = 300 ,
1054
- tolerance_settings = td .ChargeToleranceSpec (rel_tol = 1e5 , abs_tol = 1e3 , max_iters = 400 ),
1055
- fermi_dirac = True ,
1056
- )
1057
-
1058
- @pytest .fixture (scope = "class" )
1059
- def charge_dc_regime (self ):
1060
- return td .DCVoltageSource (voltage = [1 ])
1059
+ return td .ChargeToleranceSpec (rel_tol = 1e5 , abs_tol = 1e3 , max_iters = 400 )
1061
1060
1062
1061
def test_charge_simulation (
1063
1062
self ,
1063
+ Si_n ,
1064
+ Si_p ,
1065
+ SiO2 ,
1064
1066
oxide ,
1065
1067
p_side ,
1066
1068
n_side ,
@@ -1070,9 +1072,14 @@ def test_charge_simulation(
1070
1072
bc_n ,
1071
1073
bc_p ,
1072
1074
charge_tolerance ,
1073
- charge_dc_regime ,
1074
1075
):
1075
1076
"""Ensure charge simulation produces the correct errors when needed."""
1077
+ # NOTE: start tests with isothermal spec
1078
+ isothermal_spec = td .IsothermalSteadyChargeDCAnalysis (
1079
+ temperature = 300 ,
1080
+ tolerance_settings = charge_tolerance ,
1081
+ fermi_dirac = True ,
1082
+ )
1076
1083
sim = td .HeatChargeSimulation (
1077
1084
structures = [oxide , p_side , n_side ],
1078
1085
medium = td .MultiPhysicsMedium (
@@ -1083,7 +1090,7 @@ def test_charge_simulation(
1083
1090
size = CHARGE_SIMULATION .sim_size ,
1084
1091
grid_spec = td .UniformUnstructuredGrid (dl = 0.05 ),
1085
1092
boundary_spec = [bc_n , bc_p ],
1086
- analysis_spec = charge_tolerance ,
1093
+ analysis_spec = isothermal_spec ,
1087
1094
)
1088
1095
1089
1096
# At least one ChargeSimulationMonitor should be added
@@ -1118,6 +1125,35 @@ def test_charge_simulation(
1118
1125
)
1119
1126
_ = sim .updated_copy (boundary_spec = [new_bc_p , bc_n ])
1120
1127
1128
+ # test non isothermal spec
1129
+ non_isothermal_spec = td .SteadyChargeDCAnalysis (tolerance_settings = charge_tolerance )
1130
+
1131
+ sim = sim .updated_copy (analysis_spec = non_isothermal_spec )
1132
+ with pytest .raises (pd .ValidationError ):
1133
+ # remove heat from mediums
1134
+ new_structs = []
1135
+ for struct in sim .structures :
1136
+ new_structs .append (
1137
+ struct .updated_copy (medium = struct .medium .updated_copy (heat = None ))
1138
+ )
1139
+ _ = sim .updated_copy (structures = new_structs )
1140
+
1141
+ with pytest .raises (pd .ValidationError ):
1142
+ # make sure there is at least one semiconductor
1143
+ new_structs = []
1144
+ for struct in sim .structures :
1145
+ if isinstance (struct .medium .charge , td .SemiconductorMedium ):
1146
+ new_structs .append (
1147
+ struct .updated_copy (
1148
+ medium = struct .medium .updated_copy (
1149
+ charge = td .ChargeInsulatorMedium (permittivity = 1 )
1150
+ )
1151
+ )
1152
+ )
1153
+ else :
1154
+ new_structs .append (struct )
1155
+ _ = sim .updated_copy (structures = new_structs )
1156
+
1121
1157
def test_doping_distributions (self ):
1122
1158
"""Test doping distributions."""
1123
1159
# Implementation needed
0 commit comments