Skip to content

Conversation

seveibar
Copy link
Contributor

@seveibar seveibar commented Oct 4, 2025

Summary

  • generate voltage-controlled switch components and control sources for simulation_switch entries when converting to SPICE
  • add unit and integration coverage for square-wave behavior driven by simulation switches
  • bump the circuit-json dependency to the latest release

Testing

  • bun test tests/unit/circuit-json-conversion.test.tsx
  • bun test tests/integration/simulation.test.ts
  • bunx tsc --noEmit

https://chatgpt.com/codex/tasks/task_b_68e1aaee0188832ea9169969a9d6e68f

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +508 to +511
if (closesAt > 0) {
const period = closesAt * 2
const pulseWidth = Math.max(period / 2, 1e-9)
return `PULSE(${formatNumberForSpice(initialVoltage)} ${formatNumberForSpice(pulsedVoltage)} ${formatNumberForSpice(closesAt)} ${riseTime} ${fallTime} ${formatNumberForSpice(pulseWidth)} ${formatNumberForSpice(period)})`

Choose a reason for hiding this comment

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

P1 Badge Avoid turning one-shot switches into periodic oscillators

In buildSimulationSwitchControlValue, the fallback branch constructs a PULSE source with period = closesAt * 2 whenever only closes_at is provided. That makes the control voltage toggle forever, because SPICE repeats the pulse each period seconds, and with TD = closesAt (often 0) the switch flips immediately instead of staying closed until the requested time. Simulation switches that are meant to close once and remain closed will instead chatter on and off, producing an incorrect circuit. Consider emitting a non-repeating waveform (e.g., a DC level with a single transition via PWL or a pulse with an extremely long period) and delaying the first transition so that starts_closed, closes_at, and opens_at are honored.

Useful? React with 👍 / 👎.

@seveibar seveibar merged commit d2f13c4 into main Oct 5, 2025
5 checks passed
@ShiboSoftwareDev ShiboSoftwareDev deleted the codex/add-square-wave-form-from-simulation_switch branch October 5, 2025 11:17
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