Documentation
¶
Overview ¶
Package sitesim is a simulated house behind one main fuse, for testing Core in a closed loop. It holds the physics and the devices' own behaviour; Core reads what the devices report and sends them commands. A test advances it one second at a time on a pinned clock. Nothing here sleeps or starts a goroutine.
Signs follow docs/site-convention.md: positive W flows into the site. Phase currents are signed the same way unless a meter drops the sign.
Index ¶
Constants ¶
const Step = time.Second
Step is the plant's time step.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Battery ¶
type Battery struct {
Phases int // 1 (on L1) or 3
MaxChargeW, MaxDischargeW float64
CapacityWh, SoC float64
Latency time.Duration
W float64 // power now, positive charging
// contains filtered or unexported fields
}
Battery is a battery inverter that follows a power command after Latency.
type BatteryReading ¶
type BatteryReading struct{ W, SoC float64 }
BatteryReading is what the battery reports.
type Car ¶
type Car struct {
Phases int // phases its onboard charger uses
MaxW float64 // the most it takes, whatever it is offered
Plugged bool
}
Car is the vehicle on the EVSE.
type EVSE ¶
type EVSE struct {
Phases int // wired phases, 1 or 3
MinA, MaxA float64
Delay time.Duration // from command to current at the car
ReadbackLag time.Duration // the charger reports the draw this late
LoadBalancerA float64 // > 0: its own balancer keeps each phase under this
OfferA float64 // current limit in force
OfferPhases int
DrawW float64 // the car's draw now
DrawPhases int
SessionWh float64 // since the car plugged in
// The Easee driver's own choice for "auto" (easee_cloud.lua pick_phases):
// without a phase_split_w it splits at the fuse's current on one phase,
// and it keeps a phase count PhaseHold before it changes it.
SplitAtA float64 // > 0: auto with no split splits at voltage × SplitAtA
PhaseHold time.Duration // > 0: an auto phase count stays this long
// contains filtered or unexported fields
}
EVSE is a charger with its driver: it turns a power command into a current limit, as the Easee driver does, and applies it after Delay.
type Event ¶
type Event struct {
At time.Duration
Kind EventKind
For time.Duration
Device string // "battery" or "evse"
Do func(*Plant)
}
Event is one change on the timeline, At after the plant started.
type Fuse ¶
Fuse is a gG main fuse (IEC 60269) on each phase, as srcfl/device-simulator's fuse package models it: the thermal model the site rig judges Core by, so both simulators share one fuse. A phase starts cold in a 25 °C cabinet; Preheat starts it warm. Damage and Blown mirror each phase after a step.
type Meter ¶
type Meter struct {
Every time.Duration
Unsigned bool // phase currents as magnitudes
// contains filtered or unexported fields
}
Meter is the site meter. It reads the boundary every Every, or every second when Every is zero.
type MeterReading ¶
MeterReading is one site meter reading. Phase power keeps its sign when the currents lose theirs, as on P1.
type Plant ¶
type Plant struct {
Now time.Time
Voltage float64
HouseW [3]float64 // house load per phase
PVW float64 // three-phase PV, zero or negative
Battery *Battery // nil: none
EVSE *EVSE // nil: none
Car *Car // the car on the EVSE; nil or unplugged: none
Meter Meter
Fuse Fuse
Events []Event // in time order; each fires once
A [3]float64 // physical phase currents after the last step
// contains filtered or unexported fields
}
Plant is one site. Set its fields before the first Step and change them from events.
type Tick ¶
type Tick struct {
Meter *MeterReading
Battery *BatteryReading
EV *EVReading
Restart time.Duration // > 0: Core goes down now for this long
}
Tick is what one second produced. A nil reading means the device sent nothing this second.