Skip to content

[FXC-1504]: Adding support for current density monitor #2651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 21, 2025

Conversation

marc-flex
Copy link
Contributor

@marc-flex marc-flex commented Jul 10, 2025

Greptile Summary

This PR adds support for current density monitoring in TCAD (Technology Computer-Aided Design) simulations, specifically for Charge and Conduction simulations. The implementation introduces a new SteadyCurrentDensityMonitor class that follows the established pattern of other steady-state monitors in the codebase.

The key changes include:

  1. New Monitor Class: Added SteadyCurrentDensityMonitor in tidy3d/components/tcad/monitors/charge.py that follows the same structure as SteadyElectricFieldMonitor, using unstructured grids and appropriate validation.

  2. Data Storage: Created SteadyCurrentDensityData class in tidy3d/components/tcad/data/monitor_data/charge.py to store current density vector field data (J) in units of A/μm², complete with validation, symmetry handling, and field plotting capabilities.

  3. Type System Integration: Updated type definitions in types.py files to include the new monitor and data types in the appropriate unions (HeatChargeMonitorType and TCADMonitorDataType).

  4. Simulation Integration: Modified the heat-charge simulation module to recognize and validate the new monitor type, updating error messages and validation logic accordingly.

  5. Testing Infrastructure: Enhanced tests to cover the new current density monitoring functionality, using a refactored approach that tests both electric field and current density monitors generically to avoid code duplication.

The implementation integrates seamlessly with the existing TCAD simulation framework, following established patterns for monitor types, data handling, and validation. Current density (J⃗) is a fundamental electromagnetic quantity representing charge flow per unit area, making this addition valuable for analyzing conduction phenomena in semiconductor devices. The changes also updated documentation strings to clarify that both electric field and current density monitors work for both pure Charge simulations and combined Charge/Conduction simulations.

Important Files Changed

File Changes Summary
Filename Score Overview
tidy3d/components/tcad/monitors/charge.py 5/5 Added new SteadyCurrentDensityMonitor class following established patterns
tidy3d/components/tcad/data/monitor_data/charge.py 5/5 Implemented SteadyCurrentDensityData class for storing current density field data
tidy3d/components/tcad/data/types.py 5/5 Added current density data type to union type definitions
tidy3d/components/tcad/types.py 5/5 Added current density monitor to heat-charge monitor type union
tidy3d/components/tcad/simulation/heat_charge.py 5/5 Integrated current density monitor into simulation validation logic
tests/test_components/test_heat_charge.py 3/5 Added tests for current density monitoring with minor naming inconsistency

Confidence score: 4/5

  • This PR is safe to merge with minimal risk as it follows established patterns and maintains backward compatibility
  • Score reflects consistent implementation across all files with only minor test naming issue identified
  • Pay close attention to the test file where the current density monitor has an incorrect name property

Sequence Diagram

sequenceDiagram
    participant User
    participant HeatChargeSimulation
    participant SteadyCurrentDensityMonitor
    participant SteadyCurrentDensityData

    User->>HeatChargeSimulation: "Create simulation with SteadyCurrentDensityMonitor"
    HeatChargeSimulation->>SteadyCurrentDensityMonitor: "Validate monitor configuration"
    SteadyCurrentDensityMonitor-->>HeatChargeSimulation: "Monitor validated"
    
    User->>HeatChargeSimulation: "Run simulation"
    HeatChargeSimulation->>SteadyCurrentDensityData: "Generate current density data from computed results"
    SteadyCurrentDensityData->>SteadyCurrentDensityData: "Validate data type (IndexedFieldVoltageDataArray or PointDataArray)"
    SteadyCurrentDensityData->>SteadyCurrentDensityData: "Check if data crosses conducting materials"
    SteadyCurrentDensityData-->>HeatChargeSimulation: "Return validated current density data"
    
    User->>SteadyCurrentDensityData: "Access field components (J)"
    SteadyCurrentDensityData-->>User: "Return current density field data"
    
    User->>SteadyCurrentDensityData: "Request field name for visualization"
    SteadyCurrentDensityData-->>User: "Return 'J' or 'J²' based on request"
    
    User->>SteadyCurrentDensityData: "Apply symmetry expansion"
    SteadyCurrentDensityData->>SteadyCurrentDensityData: "Create symmetry expanded copy"
    SteadyCurrentDensityData-->>User: "Return expanded data"
Loading

@marc-flex marc-flex self-assigned this Jul 10, 2025
@marc-flex marc-flex force-pushed the marc/current_density branch from 4e6e50c to 498628d Compare July 14, 2025 15:18
@marc-flex marc-flex marked this pull request as ready for review August 19, 2025 07:19
@marc-flex marc-flex requested a review from momchil-flex August 19, 2025 07:19
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 1 comment

Edit Code Review Bot Settings | Greptile

@marc-flex marc-flex force-pushed the marc/current_density branch from 498628d to d325a9b Compare August 19, 2025 07:38
Copy link
Contributor

github-actions bot commented Aug 19, 2025

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

  • tidy3d/components/tcad/data/monitor_data/abstract.py (100%)
  • tidy3d/components/tcad/data/monitor_data/charge.py (100%)
  • tidy3d/components/tcad/monitors/charge.py (100%)

Summary

  • Total: 39 lines
  • Missing: 0 lines
  • Coverage: 100%

@marc-flex marc-flex requested a review from damiano-flex August 19, 2025 08:12
@marc-flex marc-flex force-pushed the marc/current_density branch from b6d335e to 9390323 Compare August 20, 2025 07:57
Copy link
Collaborator

@momchil-flex momchil-flex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much cleaner! :) Feel free to choose whether to address comment about field_name.

@marc-flex marc-flex force-pushed the marc/current_density branch from 9390323 to 8e9dcdc Compare August 21, 2025 11:35
@marc-flex marc-flex enabled auto-merge August 21, 2025 11:36
@marc-flex marc-flex changed the title Adding support for current density monitor [FXC-1504]: Adding support for current density monitor Aug 21, 2025
@marc-flex marc-flex added this pull request to the merge queue Aug 21, 2025
Merged via the queue into develop with commit 8d4c6a4 Aug 21, 2025
24 checks passed
@marc-flex marc-flex deleted the marc/current_density branch August 21, 2025 12:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants