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

Doesn't work on Julia Box. #204

Open
SimonEnsemble opened this issue Feb 6, 2018 · 2 comments
Open

Doesn't work on Julia Box. #204

SimonEnsemble opened this issue Feb 6, 2018 · 2 comments

Comments

@SimonEnsemble
Copy link

The following code works on my local machine but not Julia box. [only last part is relevant] But I think it should work on Julia Box by default? By doesn't work, I mean that the plot is static.

using Interact
import PyPlot; const plt = PyPlot

type SecondOrderSystem
    τ::Float64
    ξ::Float64
end

function y_ovr_KM(t::Float64, system::SecondOrderSystem)
    # underdamped
    if system.ξ < 1.0
        # from lecture notes
        a = system.ξ / system.τ
        b = sqrt(1.0 - system.ξ) / system.τ
        return (1 - exp(-a * t) *(
                cos(b * t) + system.ξ / sqrt(1.0 - system.ξ) * sin(b * t)))
    # critically damped
    elseif system.ξ == 1.0
        return 1.0 - (1.0 + t / system.τ) * exp(-t / system.τ)
    # overdamped
    elseif system.ξ > 1.0
        τ₁ = system.τ / (system.ξ - sqrt(system.ξ ^ 2 - 1.0))
        τ₂ = system.τ / (system.ξ + sqrt(system.ξ ^ 2 - 1.0))
        return 1.0 - (τ₁ * exp(-t / τ₁) - τ₂ * exp(-t / τ₂)) / (τ₁ - τ₂)
    end

fig = plt.figure()

t_ovr_tau = collect(linspace(0, 16, 100))

@manipulate for ξ=0.0:0.1:5.0; PyPlot.withfig(fig) do
    
    τ = 1.0 # this plot does not depend on tau* system.τ
    system = SecondOrderSystem(τ, ξ)
        
    y = y_ovr_KM.(t_ovr_tau * system.τ, system)
        
    plt.plot(t_ovr_tau, y, c="green", label="output")
    plt.xlabel("\$t/ \\tau\$")
    plt.ylabel("\$y/(KM)\$")
    plt.ylim([0, 1.6])
    plt.axhline(y=1, color="k", linestyle="--")
    end
end
@rubensaid
Copy link

I have the same problem.

@twavv
Copy link
Member

twavv commented Jul 9, 2019

JuliaBox seems to be using a very old version of WebIO. Can you ask the JuliaBox people about this?

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

3 participants