const firstWindingA = flux.getNodeById("P1"); // Primary winding input
const firstWindingB = flux.getNodeById("P2"); // Primary winding output
const secondWindingA1 = flux.getNodeById("S1"); // First secondary winding output
const secondWindingB1 = flux.getNodeById("S2"); // First secondary winding return
const secondWindingA2 = flux.getNodeById("S3"); // Second secondary winding output
const secondWindingB2 = flux.getNodeById("S4"); // Second secondary winding return
const primaryCurrent = flux.createOutputNode("primaryCurrent1");
const secondaryCurrent1 = flux.createOutputNode("secondaryCurrent2");
const secondaryCurrent2 = flux.createOutputNode("secondaryCurrent3");
// Setup Event
flux.on("setup", () => {
const inductance = Number(flux.properties.find((prop) => prop.name === "Primary Inductance")?.value || 4);
const ratio = Number(flux.properties.find((prop) => prop.name === "Ratio")?.value || 0.152); // 35V/230V
const couplingCoefficient = Number(flux.properties.find((prop) => prop.name === "Coupling Coefficient")?.value || 0.99);
const power = 500; // Transformer VA rating
flux.simulationModel = {
type: "transformer",
inductance: inductance,
ratio: ratio,