Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Polynomials with very small coefficients gets rounded to 0 #123

Closed
baggepinnen opened this issue Feb 4, 2018 · 1 comment
Closed

Polynomials with very small coefficients gets rounded to 0 #123

baggepinnen opened this issue Feb 4, 2018 · 1 comment

Comments

@baggepinnen
Copy link
Member

Background: https://discourse.julialang.org/t/trouble-with-controlsystems-jl/8783/7
Constructor of Poly checks absolute magnitude of coeffs and rounds down if < 2eps(). This threshold should be a variable such that tf constructor can set it in relation to magnitude of coeffs in denominator/numerator

Test case:

using ControlSystems
rl           = 0.2
L            = 150.0e-9
dcr          = 2.0e-3 
nbulk        = 12
cbulk        = 470.0e-6
esr_bulk     = 4.5e-3
ncer         = 96
ccer         = 14.0e-6
esr_cer      = 2.0e-3
nph          = 1
s            = tf("s")
l_imp        = dcr + L*s
bulk_imp     = (esr_bulk/nbulk) + 1.0/(cbulk*nbulk*s)
cer_imp      = (esr_cer/ncer) + 1.0/(ccer*ncer*s)
cer_load_imp = cer_imp*rl/(cer_imp + rl)
den          = (bulk_imp + cer_load_imp)
num          = (bulk_imp * cer_load_imp)
tot_load_imp = num/den # Throws ERROR: Zero denominator
tot_load_imp = tf(num.matrix[1].num.a, den.matrix[1].num.a) # Workaround
@freemin7
Copy link
Contributor

I just ran your code but did not get an error.

tot_load_imp = num/den
TransferFunction{ControlSystems.SisoRational{Float64}}
3.243773646808546e-26*s^6 + 1.1739482429175884e-18*s^5 + 5.521161503047678e-13*s^4 + 2.0375470079999997e-9*s^3
--------------------------------------------------------------------------------------------------------------
   1.6436741697320034e-21*s^6 + 3.837467174734453e-15*s^5 + 1.6990809055395836e-11*s^4 + 1.018773504e-8*s^3

Continuous-time transfer function model

Is the solution correct and if so can this issue be closed?
I also used a higher precision type, Double64 from DoubleFloats and the solution looked similar:

tot_load_imp = num/den
TransferFunction{ControlSystems.SisoRational{DoubleFloat{Float64}}}
3.243773646808546e-26*s^6 + 1.1739482429175888e-18*s^5 + 5.52116150304768e-13*s^4 + 2.037547008e-9*s^3
------------------------------------------------------------------------------------------------------
1.643674169732004e-21*s^6 + 3.837467174734454e-15*s^5 + 1.699080905539584e-11*s^4 + 1.018773504e-8*s^3

Continuous-time transfer function model

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants