I implemented the diode.
There isn’t a place to put common constants yet so I just put them inside the component. If you want I can also make a separate PR for that?
I also implemented the thermal diode which has an additional thermalport and models the temperature dependent behaviour, I’ll make a separate PR for that once I have added tests.
"""
Diode(; name, Is = 1e-12, n = 1)
Ideal diode based on the Shockley diode equation.
# States
- See [OnePort](@ref)
# Connectors
- `p` Positive pin
- `n` Negative pin
# Parameters
- `Is`: [`A`] Saturation current
- `n`: Ideality factor
"""
@mtkmodel Diode begin
begin
k = 1.380649e-23 # Boltzmann constant (J/K)
q = 1.602176634e-19 # Elementary charge (C)
end
@extend v, i = oneport = OnePort(; v = 0.0)
@parameters begin
Is = 1e-6, [description = "Saturation current (A)"]
n = 1, [description = "Ideality factor"]
T = 300.15, [description = "Ambient temperature"]
end
@equations begin
i ~ Is * (exp(v * q / (n * k * T)) - 1)
end
end
Made a small demo with an AC source:
