109109HeatSourceTypes = (UniformHeatSource , HeatSource , HeatFromElectricSource )
110110ChargeSourceTypes = ()
111111ElectricBCTypes = (VoltageBC , CurrentBC , InsulatingBC )
112+ ChargeTypes = (
113+ SteadyChargeDCAnalysis ,
114+ IsothermalSteadyChargeDCAnalysis ,
115+ SSACAnalysis ,
116+ IsothermalSSACAnalysis ,
117+ )
118+ ChargeMonitorTypes = (
119+ SteadyPotentialMonitor ,
120+ SteadyFreeCarrierMonitor ,
121+ SteadyCapacitanceMonitor ,
122+ SteadyCurrentDensityMonitor ,
123+ )
112124
113125AnalysisSpecType = Union [ElectricalAnalysisType , UnsteadyHeatAnalysis ]
114126
@@ -683,13 +695,6 @@ def check_freqs_requires_ac_source(cls, values):
683695 def check_charge_simulation (cls , values ):
684696 """Makes sure that Charge simulations are set correctly."""
685697
686- ChargeMonitorType = (
687- SteadyPotentialMonitor ,
688- SteadyFreeCarrierMonitor ,
689- SteadyCapacitanceMonitor ,
690- SteadyCurrentDensityMonitor ,
691- )
692-
693698 simulation_types = cls ._check_simulation_types (values = values )
694699
695700 if TCADAnalysisTypes .CHARGE in simulation_types :
@@ -707,7 +712,7 @@ def check_charge_simulation(cls, values):
707712
708713 # check that we have at least one charge monitor
709714 monitors = values ["monitors" ]
710- if not any (isinstance (mnt , ChargeMonitorType ) for mnt in monitors ):
715+ if not any (isinstance (mnt , ChargeMonitorTypes ) for mnt in monitors ):
711716 raise SetupError (
712717 "Charge simulations require the definition of, at least, one of these monitors: "
713718 "'[SteadyPotentialMonitor, SteadyFreeCarrierMonitor, SteadyCapacitanceMonitor, SteadyCurrentDensityMonitor]' "
@@ -723,7 +728,17 @@ def check_charge_simulation(cls, values):
723728 "Currently, Charge simulations support only unstructured monitors. Please set "
724729 f"monitor '{ mnt .name } ' to 'unstructured = True'."
725730 )
726-
731+ # check that we have at least one semiconductor medium
732+ structures = values ["structures" ]
733+ sc_present = False
734+ for structure in structures :
735+ if isinstance (structure .medium .charge , SemiconductorMedium ):
736+ sc_present = True
737+ break
738+ if not sc_present :
739+ raise SetupError (
740+ f"{ TCADAnalysisTypes .CHARGE } simulations require the definition of, at least, one semiconductor medium."
741+ )
727742 return values
728743
729744 @pd .root_validator (skip_on_failure = True )
@@ -880,23 +895,23 @@ def _check_simulation_types(
880895
881896 boundaries = list (values ["boundary_spec" ])
882897 sources = list (values ["sources" ])
898+ analysis_spec = values ["analysis_spec" ]
883899
884900 structures = list (values ["structures" ])
901+
902+ if isinstance (analysis_spec , ChargeTypes ):
903+ simulation_types .append (TCADAnalysisTypes .CHARGE )
904+
885905 semiconductor_present = HeatChargeSimulation ._check_if_semiconductor_present (
886906 structures = structures
887907 )
888- if semiconductor_present :
889- simulation_types .append (TCADAnalysisTypes .CHARGE )
890908
891909 for boundary in boundaries :
892910 if isinstance (boundary .condition , HeatBCTypes ):
893911 simulation_types .append (TCADAnalysisTypes .HEAT )
894912 if isinstance (boundary .condition , ElectricBCTypes ):
895- # for the time being, assume tha the simulation will be of
896- # type CHARGE if we have semiconductors
897- if semiconductor_present :
898- simulation_types .append (TCADAnalysisTypes .CHARGE )
899- else :
913+ # type CONDUCTION if we have no semiconductors
914+ if not semiconductor_present :
900915 simulation_types .append (TCADAnalysisTypes .CONDUCTION )
901916
902917 for source in sources :
@@ -1933,17 +1948,8 @@ def _get_simulation_types(self) -> list[TCADAnalysisTypes]:
19331948 """
19341949 simulation_types = []
19351950
1936- # NOTE: for the time being, if a simulation has SemiconductorMedium
1937- # then we consider it of being a 'TCADAnalysisTypes.CHARGE'
1938- ChargeTypes = (
1939- SteadyChargeDCAnalysis ,
1940- IsothermalSteadyChargeDCAnalysis ,
1941- SSACAnalysis ,
1942- IsothermalSSACAnalysis ,
1943- )
19441951 if isinstance (self .analysis_spec , ChargeTypes ):
1945- if self ._check_if_semiconductor_present (self .structures ):
1946- return [TCADAnalysisTypes .CHARGE ]
1952+ return [TCADAnalysisTypes .CHARGE ]
19471953
19481954 # check if unsteady heat
19491955 if isinstance (self .analysis_spec , UnsteadyHeatAnalysis ):
0 commit comments