diff --git a/lib/circuitJsonToSpice.ts b/lib/circuitJsonToSpice.ts index 0f4b42c..900afdb 100644 --- a/lib/circuitJsonToSpice.ts +++ b/lib/circuitJsonToSpice.ts @@ -372,7 +372,18 @@ export function circuitJsonToSpice( const modelName = `${modelType}_${mosfet_mode.toUpperCase()}` if (!netlist.models.has(modelName)) { - netlist.models.set(modelName, `.MODEL ${modelName} ${modelType}`) + if (mosfet_mode === "enhancement") { + const vto = channel_type === "p" ? -1 : 1 + netlist.models.set( + modelName, + `.MODEL ${modelName} ${modelType} (VTO=${vto} KP=0.1)`, + ) + } else { + netlist.models.set( + modelName, + `.MODEL ${modelName} ${modelType} (KP=0.1)`, + ) + } } const mosfetCmd = new MOSFETCommand({ diff --git a/tests/examples/boost-converter.test.tsx b/tests/examples/boost-converter.test.tsx index 93d79f1..a882698 100644 --- a/tests/examples/boost-converter.test.tsx +++ b/tests/examples/boost-converter.test.tsx @@ -17,7 +17,7 @@ test( expect(spiceString).toMatchInlineSnapshot(` "* Circuit JSON to SPICE Netlist .MODEL D D - .MODEL NMOS_ENHANCEMENT NMOS + .MODEL NMOS_ENHANCEMENT NMOS (VTO=1 KP=0.1) LL1 N1 N2 1 DD1 N2 N3 D CC1 N3 0 10U diff --git a/tests/examples/buck-converter.test.tsx b/tests/examples/buck-converter.test.tsx index 59cfc74..171934e 100644 --- a/tests/examples/buck-converter.test.tsx +++ b/tests/examples/buck-converter.test.tsx @@ -12,7 +12,7 @@ test( expect(spiceString).toMatchInlineSnapshot(` "* Circuit JSON to SPICE Netlist - .MODEL PMOS_ENHANCEMENT PMOS + .MODEL PMOS_ENHANCEMENT PMOS (VTO=-1 KP=0.1) .MODEL D D MM1 N2 N1 VP_IN VP_IN PMOS_ENHANCEMENT DD1 0 N2 D