Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 37 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ resistorProps.parse({ resistance: "10k" } as ResistorPropsInput);
| `<analog.acsweepsimulation />` | [`AnalogAcSweepSimulationProps`](#analogacsweepsimulationprops-analogacsweepsimulation) |
| `<analog.dcoperatingpointsimulation />` | [`AnalogDcOperatingPointSimulationProps`](#analogdcoperatingpointsimulationprops-analogdcoperatingpointsimulation) |
| `<analog.dcsweepsimulation />` | [`AnalogDcSweepSimulationProps`](#analogdcsweepsimulationprops-analogdcsweepsimulation) |
| `<analog.measurement />` | [`AnalogMeasurementProps`](#analogmeasurementprops-analogmeasurement) |
| `<analogsimulation />` | [`AnalogSimulationProps`](#analogsimulationprops-analogsimulation) |
| `<analog.sweepparameter />` | [`AnalogResistanceSweepParameterProps`](#analogresistancesweepparameterprops-analogsweepparameter) |
| `<analog.sweepparameter />` | [`AnalogSweepCoordinatesProps`](#analogsweepcoordinatesprops-analogsweepparameter) |
| `<analog.transientsimulation />` | [`AnalogTransientSimulationProps`](#analogtransientsimulationprops-analogtransientsimulation) |
| `<autoroutingphase />` | [`AutoroutingPhaseProps`](#autoroutingphaseprops-autoroutingphase) |
| `<battery />` | [`BatteryProps`](#batteryprops-battery) |
Expand Down Expand Up @@ -280,6 +281,21 @@ export interface AnalogDcSweepSimulationProps extends AnalogAnalysisSimulationBa

[Source](https://github.com/tscircuit/props/blob/main/lib/components/analogdcsweepsimulation.ts)

### AnalogMeasurementProps `<analog.measurement />`

```ts
export interface AnalogMeasurementProps {
/** Stable name written to the simulation measurement result. */
name: string;
/** Unit of the scalar returned by measureFn. */
unit: string;
/** Computes one scalar for each transient simulation run. */
measureFn: (context: AnalogTransientMeasurementContext) => number;
}
```

[Source](https://github.com/tscircuit/props/blob/main/lib/components/analogmeasurement.ts)

### AnalogSimulationProps `<analogsimulation />`

```ts
Expand All @@ -297,13 +313,24 @@ export interface AnalogSimulationProps {

[Source](https://github.com/tscircuit/props/blob/main/lib/components/analogsimulation.ts)

### AnalogResistanceSweepParameterProps `<analog.sweepparameter />`
### AnalogSweepCoordinatesProps `<analog.sweepparameter />`

```ts
export interface AnalogResistanceSweepParameterProps extends AnalogSweepCoordinatesProps {
parameterType: "resistance";
/** Selector for the resistor whose simulation-only resistance is swept. */
resistorRef: string;
export interface AnalogSweepCoordinatesProps {
/** Stable identity for this sweep parameter. */
name?: string;
/** Explicit parameter coordinates. Cannot be combined with start/stop/step. */
values?: Array<number | string>;
/** First generated parameter coordinate. Requires stop and step. */
start?: number | string;
/** Last generated parameter coordinate. Requires start and step. */
stop?: number | string;
/** Nonzero parameter increment directed from start toward stop. */
step?: number | string;
/** Optional graph coordinates corresponding one-to-one with the physical sweep values. */
displayValues?: number[];
/** Unit for displayValues. Required when displayValues is provided. */
displayUnit?: string;
}
```

Expand Down Expand Up @@ -716,6 +743,8 @@ export interface CurrentSourceProps<
acMagnitude?: number | string;
/** Small-signal AC phase. Raw numbers are degrees. */
acPhase?: number | string;
/** Piecewise-linear transient source waveform. Cannot be combined with waveShape. */
currentWaveform?: CurrentWaveformPoint[];
connections?: Connections<CurrentSourcePinLabels>;
}
```
Expand Down Expand Up @@ -2208,6 +2237,8 @@ export interface VoltageSourceProps<
acMagnitude?: number | string;
/** Small-signal AC phase. Raw numbers are degrees. */
acPhase?: number | string;
/** Piecewise-linear transient source waveform. Cannot be combined with waveShape. */
voltageWaveform?: VoltageWaveformPoint[];
connections?: Connections<VoltageSourcePinLabels>;
}
```
Expand Down
77 changes: 73 additions & 4 deletions generated/COMPONENT_TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,25 @@ export const schematicPinStyle = z.record(
}),
```

### simulation-waveform

```typescript
export const validateStrictlyIncreasingWaveformTimes = (
points: ReadonlyArray<Record<"time", number>>,
context: z.RefinementCtx,
) => {
for (let index = 1; index < points.length; index++) {
if (points[index]!.time <= points[index - 1]!.time) {
context.addIssue({
code: "custom",
path: [index, "time"],
message: "Waveform times must be strictly increasing",
})
}
}
}
```

### url

```typescript
Expand Down Expand Up @@ -991,6 +1010,33 @@ export const analogDcSweepSimulationProps = z
})
```

### analogmeasurement

```typescript
export interface TransientMeasurementSeries {
timestampsMs: readonly number[]
values: readonly number[]
}
export interface AnalogTransientMeasurementContext {
getVoltage: (selector: string) => TransientMeasurementSeries
getCurrent: (selector: string) => TransientMeasurementSeries
}
export interface AnalogMeasurementProps {
name: string
unit: string
measureFn: (context: AnalogTransientMeasurementContext) => number
}
/** Computes one scalar for each transient simulation run. */
export const analogMeasurementProps = z
.object({
name: z.string().min(1),
unit: z.string().min(1),
measureFn: z.custom<AnalogMeasurementProps["measureFn"]>(
(value) => typeof value === "function",
),
})
```

### analogsimulation

```typescript
Expand All @@ -1017,7 +1063,7 @@ export interface AnalogAnalysisSimulationBaseProps {
graphIndependentAxes?: boolean
children?: ReactNode
}
/** Optional nested sweep parameter for repeated analysis runs. */
/** Optional nested sweep parameters and transient measurements. */
export const analogAnalysisSimulationBaseProps = {
name: z.string().optional(),
spiceEngine: spiceEngine.optional(),
Expand All @@ -1042,7 +1088,16 @@ export const analogSimulationProps = z.object({
### analogsweepparameter

```typescript
/** Nonzero parameter increment directed from start toward stop. */
export interface AnalogSweepCoordinatesProps {
name?: string
values?: Array<number | string>
start?: number | string
stop?: number | string
step?: number | string
displayValues?: number[]
displayUnit?: string
}
/** Unit for displayValues. Required when displayValues is provided. */
export interface AnalogResistanceSweepParameterProps
extends AnalogSweepCoordinatesProps {
parameterType: "resistance"
Expand Down Expand Up @@ -1725,6 +1780,11 @@ export const crystalProps = commonComponentProps.extend({
### currentsource

```typescript
export interface CurrentWaveformPoint {
time: number | string
current: number | string
}
/** Source current at this point. Raw numbers are amperes. */
export interface CurrentSourceProps<PinLabel extends string = string>
extends CommonComponentProps<PinLabel> {
current?: number | string
Expand All @@ -1735,9 +1795,10 @@ export interface CurrentSourceProps<PinLabel extends string = string>
dutyCycle?: number | string
acMagnitude?: number | string
acPhase?: number | string
currentWaveform?: CurrentWaveformPoint[]
connections?: Connections<CurrentSourcePinLabels>
}
/** Small-signal AC phase. Raw numbers are degrees. */
/** Piecewise-linear transient source waveform. Cannot be combined with waveShape. */
export const currentSourceProps = commonComponentProps.extend({
current: current.optional(),
frequency: frequency.optional(),
Expand All @@ -1747,6 +1808,7 @@ export const currentSourceProps = commonComponentProps.extend({
dutyCycle: percentage.optional(),
acMagnitude: current.optional(),
acPhase: rotation.optional(),
currentWaveform: currentWaveform.optional(),
connections: createConnectionsProp(currentSourcePinLabels).optional(),
})
```
Expand Down Expand Up @@ -4607,6 +4669,11 @@ export const voltageProbeProps = commonComponentProps
### voltagesource

```typescript
export interface VoltageWaveformPoint {
time: number | string
voltage: number | string
}
/** Source voltage at this point. Raw numbers are volts. */
export interface VoltageSourceProps<PinLabel extends string = string>
extends CommonComponentProps<PinLabel> {
voltage?: number | string
Expand All @@ -4622,9 +4689,10 @@ export interface VoltageSourceProps<PinLabel extends string = string>
period?: number | string
acMagnitude?: number | string
acPhase?: number | string
voltageWaveform?: VoltageWaveformPoint[]
connections?: Connections<VoltageSourcePinLabels>
}
/** Small-signal AC phase. Raw numbers are degrees. */
/** Piecewise-linear transient source waveform. Cannot be combined with waveShape. */
export const voltageSourceProps = commonComponentProps.extend({
voltage: voltage.optional(),
frequency: frequency.optional(),
Expand All @@ -4639,6 +4707,7 @@ export const voltageSourceProps = commonComponentProps.extend({
period: ms.optional(),
acMagnitude: voltage.optional(),
acPhase: rotation.optional(),
voltageWaveform: voltageWaveform.optional(),
connections: createConnectionsProp(voltageSourcePinLabels).optional(),
})
```
Expand Down
67 changes: 66 additions & 1 deletion generated/PROPS_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export interface AnalogAnalysisSimulationBaseProps {
spiceOptions?: SpiceOptions
/** Render each probe with an independent vertical graph scale. */
graphIndependentAxes?: boolean
/** Optional nested sweep parameter for repeated analysis runs. */
/** Optional nested sweep parameters and transient measurements. */
children?: ReactNode
}

Expand Down Expand Up @@ -95,6 +95,16 @@ export interface AnalogInductanceSweepParameterProps
}


export interface AnalogMeasurementProps {
/** Stable name written to the simulation measurement result. */
name: string
/** Unit of the scalar returned by measureFn. */
unit: string
/** Computes one scalar for each transient simulation run. */
measureFn: (context: AnalogTransientMeasurementContext) => number
}


export interface AnalogResistanceSweepParameterProps
extends AnalogSweepCoordinatesProps {
parameterType: "resistance"
Expand All @@ -115,6 +125,30 @@ export interface AnalogSimulationProps {
}


export interface AnalogSweepCoordinatesProps {
/** Stable identity for this sweep parameter. */
name?: string
/** Explicit parameter coordinates. Cannot be combined with start/stop/step. */
values?: Array<number | string>
/** First generated parameter coordinate. Requires stop and step. */
start?: number | string
/** Last generated parameter coordinate. Requires start and step. */
stop?: number | string
/** Nonzero parameter increment directed from start toward stop. */
step?: number | string
/** Optional graph coordinates corresponding one-to-one with the physical sweep values. */
displayValues?: number[]
/** Unit for displayValues. Required when displayValues is provided. */
displayUnit?: string
}


export interface AnalogTransientMeasurementContext {
getVoltage: (selector: string) => TransientMeasurementSeries
getCurrent: (selector: string) => TransientMeasurementSeries
}


export interface AnalogTransientSimulationProps
extends AnalogAnalysisSimulationBaseProps {
/** Simulation duration. Raw numbers are milliseconds. Defaults to 10ms. */
Expand Down Expand Up @@ -815,10 +849,20 @@ export interface CurrentSourceProps<PinLabel extends string = string>
acMagnitude?: number | string
/** Small-signal AC phase. Raw numbers are degrees. */
acPhase?: number | string
/** Piecewise-linear transient source waveform. Cannot be combined with waveShape. */
currentWaveform?: CurrentWaveformPoint[]
connections?: Connections<CurrentSourcePinLabels>
}


export interface CurrentWaveformPoint {
/** Time from the start of the transient simulation. Raw numbers are milliseconds. */
time: number | string
/** Source current at this point. Raw numbers are amperes. */
current: number | string
}


export interface CustomDrcCheckContext {
select: CustomDrcSelect
selectAll: CustomDrcSelectAll
Expand Down Expand Up @@ -2331,6 +2375,11 @@ export interface SolderJumperProps extends JumperProps {


export interface SpiceEngine {
/**
* Maximum number of independent simulations this engine can safely execute
* at once. Engines are treated as serial when this is omitted.
*/
maxConcurrentSimulations?: number
simulate: (spiceString: string) => Promise<SpiceEngineSimulationResult>
}

Expand Down Expand Up @@ -2507,6 +2556,12 @@ export interface ToolingrailProps {
}


export interface TransientMeasurementSeries {
timestampsMs: readonly number[]
values: readonly number[]
}


export interface TransistorProps<PinLabel extends string = string>
extends CommonComponentProps<PinLabel> {
type: "npn" | "pnp" | "bjt" | "jfet" | "mosfet" | "igbt"
Expand Down Expand Up @@ -2555,7 +2610,17 @@ export interface VoltageSourceProps<PinLabel extends string = string>
acMagnitude?: number | string
/** Small-signal AC phase. Raw numbers are degrees. */
acPhase?: number | string
/** Piecewise-linear transient source waveform. Cannot be combined with waveShape. */
voltageWaveform?: VoltageWaveformPoint[]
connections?: Connections<VoltageSourcePinLabels>
}


export interface VoltageWaveformPoint {
/** Time from the start of the transient simulation. Raw numbers are milliseconds. */
time: number | string
/** Source voltage at this point. Raw numbers are volts. */
voltage: number | string
}

```
16 changes: 16 additions & 0 deletions lib/common/simulation-waveform.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import type { z } from "zod"

export const validateStrictlyIncreasingWaveformTimes = (
points: ReadonlyArray<Record<"time", number>>,
context: z.RefinementCtx,
) => {
for (let index = 1; index < points.length; index++) {
if (points[index]!.time <= points[index - 1]!.time) {
context.addIssue({
code: "custom",
path: [index, "time"],
message: "Waveform times must be strictly increasing",
})
}
}
}
Loading
Loading