|
8 | 8 | from matplotlib import pyplot as plt |
9 | 9 |
|
10 | 10 | import tidy3d as td |
| 11 | +from tidy3d.components.tcad.simulation.heat_charge import TCADAnalysisTypes |
11 | 12 | from tidy3d.components.tcad.types import ( |
12 | 13 | AugerRecombination, |
13 | 14 | CaugheyThomasMobility, |
@@ -2513,3 +2514,88 @@ def test_generation_recombination(): |
2513 | 2514 | beta_n=1, |
2514 | 2515 | beta_p=1, |
2515 | 2516 | ) |
| 2517 | + |
| 2518 | + |
| 2519 | +def test_heat_only_simulation_with_semiconductor(): |
| 2520 | + """Test that a heat-only simulation with semiconductors does not trigger charge simulation. |
| 2521 | + Charge simulations are only triggered when `analysis_spec` is provided, not just when |
| 2522 | + semiconductors are present in the simulation. |
| 2523 | + """ |
| 2524 | + |
| 2525 | + # Create a semiconductor medium |
| 2526 | + semiconductor_medium = td.MultiPhysicsMedium( |
| 2527 | + optical=td.Medium(permittivity=5, conductivity=0.01), |
| 2528 | + heat=td.SolidMedium(conductivity=3, capacity=2), |
| 2529 | + charge=td.SemiconductorMedium( |
| 2530 | + N_c=td.ConstantEffectiveDOS(N=1e10), |
| 2531 | + N_v=td.ConstantEffectiveDOS(N=1e10), |
| 2532 | + E_g=td.ConstantEnergyBandGap(eg=1), |
| 2533 | + mobility_n=td.ConstantMobilityModel(mu=1500), |
| 2534 | + mobility_p=td.ConstantMobilityModel(mu=1500), |
| 2535 | + ), |
| 2536 | + name="semiconductor", |
| 2537 | + ) |
| 2538 | + |
| 2539 | + # Create a non-semiconductor solid medium |
| 2540 | + solid_medium = td.MultiPhysicsMedium( |
| 2541 | + optical=td.Medium(permittivity=5, conductivity=0.01), |
| 2542 | + heat=td.SolidMedium(conductivity=1, capacity=1), |
| 2543 | + charge=td.ChargeConductorMedium(conductivity=1), |
| 2544 | + name="solid", |
| 2545 | + ) |
| 2546 | + |
| 2547 | + # Create structures with both semiconductor and other materials |
| 2548 | + semiconductor_structure = td.Structure( |
| 2549 | + geometry=td.Box(center=(-0.5, 0, 0), size=(1, 1, 1)), |
| 2550 | + medium=semiconductor_medium, |
| 2551 | + name="semiconductor_structure", |
| 2552 | + ) |
| 2553 | + |
| 2554 | + solid_structure = td.Structure( |
| 2555 | + geometry=td.Box(center=(0.5, 0, 0), size=(1, 1, 1)), |
| 2556 | + medium=solid_medium, |
| 2557 | + name="solid_structure", |
| 2558 | + ) |
| 2559 | + |
| 2560 | + # Create heat-only boundary conditions (no electric BCs) |
| 2561 | + thermal_bc = td.HeatChargeBoundarySpec( |
| 2562 | + condition=td.TemperatureBC(temperature=300), |
| 2563 | + placement=td.StructureBoundary(structure="solid_structure"), |
| 2564 | + ) |
| 2565 | + |
| 2566 | + # Create heat source |
| 2567 | + heat_source = td.HeatSource(structures=["solid_structure"], rate=100) |
| 2568 | + |
| 2569 | + # Create heat monitor (no charge monitors) |
| 2570 | + temp_monitor = td.TemperatureMonitor( |
| 2571 | + center=(0, 0, 0), size=(2, 1, 1), name="temp_monitor", unstructured=True |
| 2572 | + ) |
| 2573 | + |
| 2574 | + # Create heat-only simulation (no analysis_spec, no electric BCs) |
| 2575 | + heat_sim = td.HeatChargeSimulation( |
| 2576 | + medium=td.MultiPhysicsMedium( |
| 2577 | + heat=td.FluidMedium(), charge=td.ChargeInsulatorMedium(), name="air" |
| 2578 | + ), |
| 2579 | + structures=[semiconductor_structure, solid_structure], |
| 2580 | + center=(0, 0, 0), |
| 2581 | + size=(3, 3, 3), |
| 2582 | + boundary_spec=[thermal_bc], |
| 2583 | + grid_spec=td.UniformUnstructuredGrid(dl=0.1), |
| 2584 | + sources=[heat_source], |
| 2585 | + monitors=[temp_monitor], |
| 2586 | + # No analysis_spec - this is key: without ChargeTypes analysis_spec, |
| 2587 | + # charge simulation should NOT be triggered even though semiconductors are present |
| 2588 | + ) |
| 2589 | + |
| 2590 | + # Verify that only HEAT simulation type is returned, not CHARGE |
| 2591 | + simulation_types = heat_sim._get_simulation_types() |
| 2592 | + assert TCADAnalysisTypes.HEAT in simulation_types, ( |
| 2593 | + "Heat simulation should be triggered when heat sources/BCs are present." |
| 2594 | + ) |
| 2595 | + assert TCADAnalysisTypes.CHARGE not in simulation_types, ( |
| 2596 | + "Charge simulation should NOT be triggered when ChargeTypes analysis_spec is not provided, " |
| 2597 | + "even if semiconductors are present in the simulation." |
| 2598 | + ) |
| 2599 | + assert TCADAnalysisTypes.CONDUCTION not in simulation_types, ( |
| 2600 | + "Conduction simulation should NOT be triggered when no electric BCs are present." |
| 2601 | + ) |
0 commit comments