Skip to content

Commit ee28ef9

Browse files
authored
Merge pull request #140 from acfr/issue_136_139
Issue 136 139
2 parents 67f9f81 + d094413 commit ee28ef9

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

src/ParameterTypes/passive_ren.jl

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Construct direct parameterisation of a passive REN.
2525
- `ν::Number=0`: Passivity index. Use `ν > 0` for an incrementally strictly input passive model. Set both `ν = 0` and `ρ = 0` for incrementally passive model.
2626
- `ρ::Number=0`: Passivity index. Use `ρ > 0` for an incrementally strictly output passive model.
2727
28-
Note that setting both `ν,ρ > 0` or both `ν,ρ < 0` is not currently supported and will throw an error.
28+
Note that the product of passivity indices ρν has to be less than 1/4 for passive REN.
2929
3030
# Keyword arguments
3131
@@ -55,8 +55,8 @@ function PassiveRENParams{T}(
5555
end
5656

5757
# Check ρ and ν
58-
if ρ*ν > 0
59-
error("If ρ and ν are both positive, passiveREN could produce incorrect results. Please set at least one of them as zero. ")
58+
if ρ*ν >= 1/4
59+
error("ρ and ν can not be arbitrarily large for passiveREN models. Please make sure ρν < 1/4. ")
6060
end
6161

6262
if ρ < 0 || ν < 0
@@ -114,7 +114,8 @@ function direct_to_explicit(ps::PassiveRENParams{T}, return_h=false) where T
114114
H = x_to_h(X, ϵ, polar_param, ρ_polar) + Γ2
115115
else
116116
# For ρ!=0 case, ISOP model
117-
D22 = _D22_pass(M, ρ)
117+
D22 = _D22_pass(M, ρ)
118+
118119
C2_imp = _C2_pass(D22, C2, ρ)
119120
D21_imp = _D21_pass(D22, D21, D12_imp, ρ)
120121

@@ -132,8 +133,6 @@ function direct_to_explicit(ps::PassiveRENParams{T}, return_h=false) where T
132133

133134
end
134135

135-
_D22_pass(M, ρ) = ((I+M) \ I) / ρ
136-
137136
_C2_pass(D22, C2, ρ) = (D22'*(-2ρ*I) + I)*C2
138137

139138
_D21_pass(D22, D21, D12_imp, ρ) = (D22'*(-2ρ*I) + I)*D21 - D12_imp'
@@ -142,6 +141,11 @@ _M_pass(X3, Y3, ϵ) = X3'*X3 + Y3 - Y3' + ϵ*I
142141

143142
_R_pass(D22, ν, ρ) = -2ν*I + D22 + D22' + D22'*(-2ρ*I)*D22
144143

144+
function _D22_pass(M, ρ)
145+
Im = _I(M) # Prevents scalar indexing on backwards pass of () / (I + M) on GPU
146+
return ((Im + M) \ Im) / ρ
147+
end
148+
145149
function _Γ1_pass(nx, ny, C2, D21, ρ, T)
146150
[C2'; D21'; zeros(T, nx, ny)] * (-2ρ*I) * [C2 D21 zeros(T, ny, nx)]
147151
end

0 commit comments

Comments
 (0)