Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Uwe Fechner committed Jul 24, 2024
1 parent 5de8e99 commit 971f464
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/async_generator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ The inertia of drum and motor are combined into one value (stiff coupling). =#
Model of a winch with an async generator and a gearbox.
"""
@with_kw mutable struct AsyncMachine <: AbstractWinchModel @deftype Float64
set::Settings = se()
set::Union{Settings, Nothing} = nothing
"nominal motor voltage"
u_nom = 400.0/sqrt(3)
"rated synchronous motor speed [rad/s]"
Expand All @@ -50,6 +50,12 @@ Model of a winch with an async generator and a gearbox.
brake::Bool = true;
end

function AsyncMachine(set::Settings)
wm = AsyncMachine()
wm.set = set
wm
end

# calculated the motor reactance X [Ohm]
function calc_reactance(wm::AsyncMachine)
wm.u_nom^2 / (2 * wm.omega_sn * wm.tau_b)
Expand Down
5 changes: 3 additions & 2 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ using Test

cd("..")
KiteUtils.set_data_path("")
set = se()

@testset "calc_force" begin
wm = deepcopy(AsyncMachine())
wm = deepcopy(AsyncMachine(set))
wm.set.inertia_total=4*0.082
@test wm.set.inertia_total 0.328
@test (-calc_force(wm, 1.0, 0.0)) -12620.5127746
@test (-calc_force(wm, 0.15, 9.0)) 3698.78395182
end

@testset "WinchModels.jl" begin
wm = deepcopy(AsyncMachine())
wm = deepcopy(AsyncMachine(set))
@test calc_reactance(wm) 0.4676729273591048
@test calc_inductance(wm) 0.002977298325578337
@test calc_resistance(wm) 0.07268793534211404
Expand Down

0 comments on commit 971f464

Please sign in to comment.