Skip to content

Commit

Permalink
Add docstrings for current sources
Browse files Browse the repository at this point in the history
  • Loading branch information
AayushSabharwal committed Apr 28, 2022
1 parent f4c3cd2 commit f74f1d4
Showing 1 changed file with 207 additions and 48 deletions.
255 changes: 207 additions & 48 deletions src/Electrical/Analog/sources.jl
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ end

"""
```julia
function CosineVoltage(;name, offset=0.0, amplitude=1.0, frequency=1.0, starttime=0.0, phase=0.0)
function CosineVoltage(; name, offset=0.0, amplitude=1.0, frequency=1.0, starttime=0.0, phase=0.0)
```
A source in which the voltage across its terminals is a cosine function of time.
# States
- `v(t)`
- `v(t)`: [`V`]
The voltage across this source, given by `p.v - n.v`
# Connectors
Expand Down Expand Up @@ -151,7 +151,7 @@ end

"""
```julia
function RampVoltage(;name, offset=0.0, start_time=0.0, duration=1.0, height=1.0)
function RampVoltage(; name, offset=0.0, start_time=0.0, duration=1.0, height=1.0)
```
A source in which the voltage across grows linearly from `offset` to `offset+height` over
Expand All @@ -166,7 +166,6 @@ the time interval `duration` starting at `start_time`
Positive port
- `n`
Negative port
RampVoltage(;name, offset=0.0, start_time=0.0, duration=1.0, height=1.0)
# Parameters
- `offset`: [`V`]
Expand Down Expand Up @@ -197,7 +196,7 @@ end

"""
```julia
function SineVoltage(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0)
function SineVoltage(; name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0)
```
A source in which the voltage across its terminals is a sine function of time.
Expand Down Expand Up @@ -293,11 +292,11 @@ end

"""
```julia
function StepVoltage(;name, offset=0.0, start_time=0.0, height=1.0)
function StepVoltage(; name, offset=0.0, start_time=0.0, height=1.0)
```
A source in which the voltage across its terminals increases from `offset` to `offset+height` at
`starttime`
`start_time`
# States
- `v(t)`: [`V`]
Expand Down Expand Up @@ -382,12 +381,25 @@ end

# Current Sources ######################################################################################################
"""
ConstantCurrent(;name, I = 1.0)
```julia
function ConstantCurrent(; name, I = 1.0)
```
The source for an ideal constant current.
Source for constant current.
# States
- `i(t)`: [`A`]
The current through this source, which is always constant
# Connectors
- `p`
Positive pin
- `n`
Negative pin
# Parameters:
- `I`: [A] Current
- `I`: [`A`]
The constant current through the terminals of this source
"""
function ConstantCurrent(;name, I = 1.0)
@named oneport = OnePort()
Expand All @@ -401,16 +413,35 @@ function ConstantCurrent(;name, I = 1.0)
end

"""
CosineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0)
```julia
function CosineCurrent(; name, offset=0.0, amplitude=1.0, frequency=1.0, starttime=0.0, phase=0.0)
```
Generate cosine current.
A source in which the current through its terminals is a cosine function of time.
# Parameters:
- `frequency`: [Hz] Frequency of sine wave
- `amplitude`: [A] Amplitude of sine wave
- `phase`: [rad] Phase of sine wave
- `offset`: [A] Offset of output current
- `start_time`: [s] Output `y = offset` for `t < start_time`
# States
- `i(t)`: [`A`]
The current through this source
# Connectors
- `p`
Positive port
- `n`
Negative port
# Observables
- `offset`: [`A`]
A constant offset added to the current output
- `amplitude`: [`A`]
The amplitude of the cosine function
- `frequency`: [`Hz`]
The frequency of the cosine function
- `starttime`: [`s`]
The time at which the source starts functioning. Before this time, the current through
its terminals is 0.
- `phase`: [`rad`]
The phase offset of the cosine function
"""
function CosineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0)
δ = 0.00001
Expand All @@ -432,17 +463,36 @@ function CosineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_ti
end

"""
ExpSineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0, damping=0.0)
```julia
function ExpSineCurrent(; name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0, damping=0.0)
```
Generate damped sine current.
A source in which the current through its terminals is a damped sine function of time.
# Parameters:
- `frequency`: [Hz] Frequency of sine wave
- `amplitude`: [A] Amplitude of sine wave
- `damping`: [1/s] Damping coefficient of sine wave
- `phase`: [rad] Phase of sine wave
- `offset`: [A] Offset of output current
- `start_time`: [s] Output `y = offset` for `t < start_time`
# States
- `i(t)`: [`A`]
The current through this source
# Connectors
- `p`
Positive port
- `n`
Negative port
# Parameters
- `offset`: [`A`]
A constant offset added to the current output
- `amplitude`: [`A`]
The amplitude of the damped sine function
- `frequency`: [`Hz`]
The frequency of the damped sine function
- `start_time`: [`s`]
The time at which the source starts functioning. Before this time, the current through
its terminals is `offset`.
- `phase`: [`rad`]
The phase offset of the damped sine function
- `damping_coef`: [`1/s`]
Damping coefficient of the damped sine function
"""
function ExpSineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0, damping=0.0)
δ = 0.00001
Expand All @@ -464,15 +514,32 @@ function ExpSineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_t
end

"""
RampCurrent(;name, offset=0.0, start_time=0.0, duration=1.0, height=1.0)
```julia
function RampCurrent(; name, offset=0.0, start_time=0.0, duration=1.0, height=1.0)
```
Generate ramp current.
A source in which the current grows linearly from `offset` to `offset+height` over
the time interval `duration` starting at `start_time`
# Parameters:
- `height`: [A] Height of ramp
- `duration`: [s] Duration of ramp (= 0.0 gives a Step)
- `offset`: [A] Offset of output current
- `start_time`: [s] Output `y = offset` for `t < start_time`
# States
- `i(t)`: [`A`]
The current through this source
# Connectors
- `p`
Positive port
- `n`
Negative port
# Parameters
- `offset`: [`A`]
A constant offset added to the current output
- `start_time`: [`s`]
The time at which the current starts growing
- `duration`: [`s`]
The duration of the ramp (`0.0` gives a step)
- `height`: [`A`]
The amount that the current grows in the time interval
"""
function RampCurrent(;name, offset=0.0, start_time=0.0, duration=1.0, height=1.0)
δ = 0.00001
Expand All @@ -492,16 +559,36 @@ function RampCurrent(;name, offset=0.0, start_time=0.0, duration=1.0, height=1.0
end

"""
SineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0)
```julia
function SineCurrent(; name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0)
```
Generate sine current.
A source in which the current through its terminals is a sine function of time.
# Parameters:
- `frequency`: [Hz] Frequency of sine wave
- `amplitude`: [A] Amplitude of sine wave
- `phase`: [rad] Phase of sine wave
- `offset`: [A] Offset of output current
- `start_time`: [s] Output `y = offset` for `t < start_time`
# States
- `i(t)`: [`A`]
The current through this source
# Connectors
- `p`
Positive port
- `n`
Negative port
# Parameters
- `offset`: [`A`]
A constant offset added to the current output
- `amplitude`: [`V`]
The amplitude of the sine function
- `frequency`: [`Hz`]
The frequency of the sine function
- `start_time`: [`s`]
The time at which the source starts functioning. Before this time, the current through
its terminals is `offset`.
- `phase`: [`rad`]
The phase offset of the sine function
"""
function SineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0, phase=0.0)
δ = 0.00001
Expand All @@ -522,6 +609,34 @@ function SineCurrent(;name, offset=0.0, amplitude=1.0, frequency=1.0, start_time
extend(ODESystem(eqs, t, [], pars; name=name), oneport)
end

"""
```julia
function SquareCurrent(; name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0)
```
A source in which the current through its terminals is a square function of time.
# States
- `i(t)`: [`A`]
The current through this source
# Connectors
- `p`
Positive port
- `n`
Negative port
# Parameters
- `offset`: [`A`]
A constant offset added to the current output
- `amplitude`: [`A`]
The amplitude of the square wave function
- `frequency`: [`Hz`]
The frequency of the square wave function
- `start_time`: [`s`]
The time at which the source starts functioning. Before this time, the current through
its terminals is `offset`.
"""
function SquareCurrent(; name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0)
δ = 0.0001

Expand All @@ -540,14 +655,30 @@ function SquareCurrent(; name, offset=0.0, amplitude=1.0, frequency=1.0, start_t
end

"""
StepCurrent(;name, offset=0.0, start_time=0.0, height=1.0)
```julia
function StepCurrent(; name, offset=0.0, start_time=0.0, height=1.0)
```
Generate step current.
A source in which the current through its terminals increases from `offset` to `offset+height` at
`start_time`
# Parameters:
- `height`: [A] Height of step
- `offset`: [A] Offset of output current
- `start_time`: [s] Output `y = offset` for `t < start_time`
# States
- `i(t)`: [`A`]
The current through this source
# Connectors
- `p`
Positive port
- `n`
Negative port
# Observables
- `offset`: [`A`]
A constant offset added to the current output
- `start_time`: [`s`]
The time at which the source starts functioning, and the current jumps
- `height`: [`A`]
Magnitude of increase in current
"""
function StepCurrent(;name, offset=0.0, start_time=0.0, height=1.0)
δ = 0.0001
Expand All @@ -566,6 +697,34 @@ function StepCurrent(;name, offset=0.0, start_time=0.0, height=1.0)
extend(ODESystem(eqs, t, [], pars; name=name), oneport)
end

"""
```julia
function TriangularCurrent(; name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0)
```
A source in which the current through its terminals is a triangular function of time.
# States
- `i(t)`: [`A`]
The current through this source
# Connectors
- `p`
Positive port
- `n`
Negative port
# Observables
- `offset`: [`A`]
A constant offset added to the current output
- `amplitude`: [`A`]
Amplitude of the triangular wave function
- `frequency`: [`Hz`]
Frequency of the triangular wave function
- `start_time`: [`s`]
The time at which the source starts functioning. Before this, the output of the source is
`offset`
"""
function TriangularCurrent(; name, offset=0.0, amplitude=1.0, frequency=1.0, start_time=0.0)
δ = 0.00001

Expand Down

0 comments on commit f74f1d4

Please sign in to comment.