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

Electrical formatting changes #64

Merged
merged 2 commits into from
Jun 7, 2022

Conversation

ValentinKaisermayer
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Jun 7, 2022

Codecov Report

Merging #64 (909f4a7) into main (1af4a62) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main      #64   +/-   ##
=======================================
  Coverage   68.51%   68.51%           
=======================================
  Files          23       23           
  Lines         918      918           
=======================================
  Hits          629      629           
  Misses        289      289           
Impacted Files Coverage Δ
src/Electrical/Analog/ideal_components.jl 83.33% <ø> (ø)
src/Electrical/Analog/sensors.jl 56.41% <ø> (ø)
src/Electrical/Analog/sources.jl 100.00% <ø> (ø)
src/Electrical/utils.jl 61.53% <ø> (ø)

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@ChrisRackauckas ChrisRackauckas merged commit b999295 into SciML:main Jun 7, 2022
ChrisRackauckas added a commit that referenced this pull request Oct 28, 2024
Though it's really weird... it completely ignores the recipe. MWE:

```julia
using ModelingToolkit
using ModelingToolkit: t_nounits as t
using ModelingToolkitStandardLibrary.Electrical
using ModelingToolkitStandardLibrary.Mechanical.Rotational
using ModelingToolkitStandardLibrary.Blocks
using OrdinaryDiffEq
using Plots

@mtkmodel DCMotor begin
    @parameters begin
        R = 0.5, [description = "Armature resistance"] # Ohm
        L = 4.5e-3, [description = "Armature inductance"] # H
        k = 0.5, [description = "Motor constant"] # N.m/A
        J = 0.02, [description = "Inertia"] # kg.m²
        f = 0.01, [description = "Friction factor"] # N.m.s/rad
        tau_L_step = -0.3, [description = "Amplitude of the load torque step"] # N.m
    end
    @components begin
        ground = Ground()
        source = Voltage()
        ref = Blocks.Step(height = 1, start_time = 0)
        pi_controller = Blocks.LimPI(k = 1.1, T = 0.035, u_max = 10, Ta = 0.035)
        feedback = Blocks.Feedback()
        R1 = Resistor(R = R)
        L1 = Inductor(L = L)
        emf = EMF(k = k)
        fixed = Fixed()
        load = Torque()
        load_step = Blocks.Step(height = tau_L_step, start_time = 3)
        inertia = Inertia(J = J)
        friction = Damper(d = f)
        speed_sensor = SpeedSensor()
    end
    @equations begin
        connect(fixed.flange, emf.support, friction.flange_b)
        connect(emf.flange, friction.flange_a, inertia.flange_a)
        connect(inertia.flange_b, load.flange)
        connect(inertia.flange_b, speed_sensor.flange)
        connect(load_step.output, load.tau)
        connect(ref.output, feedback.input1)
        connect(speed_sensor.w, :y, feedback.input2)
        connect(feedback.output, pi_controller.err_input)
        connect(pi_controller.ctr_output, :u, source.V)
        connect(source.p, R1.p)
        connect(R1.n, L1.p)
        connect(L1.n, emf.p)
        connect(emf.n, source.n, ground.g)
    end
end

@nAmed model = DCMotor()

sys = structural_simplify(model)
connect(sys.speed_sensor.w, :y, sys.feedback.input2)

using Latexify

@latexrecipe function f(n::AnalysisPoint)
    env --> :equation
    cdot --> false
    index --> :subscript
    return nameof(n)
end

latexify(connect(sys.speed_sensor.w, :y, sys.feedback.input2))
```

```
julia> latexify(connect(sys.speed_sensor.w, :y, sys.feedback.input2))
ERROR: AssertionError: latexify does not support objects of type AnalysisPoint.
Stacktrace:
  [1] _latexraw(args::AnalysisPoint; kwargs::@kwargs{…})
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexraw.jl:109
  [2] process_latexify(args::Num; kwargs::@kwargs{convert_unicode::Bool, index::Symbol, env::Symbol})
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexify_function.jl:49
  [3] process_latexify
    @ ~/.julia/packages/Latexify/ieukI/src/latexify_function.jl:40 [inlined]
  [4] latexraw
    @ ~/.julia/packages/Latexify/ieukI/src/latexraw.jl:58 [inlined]
  [5] (::Latexify.var"#64#66"{@kwargs{convert_unicode::Bool, index::Symbol, env::Symbol}})(i::Num)
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexoperation.jl:21
  [6] iterate
    @ ./generator.jl:47 [inlined]
  [7] _collect(c::Vector{…}, itr::Base.Generator{…}, ::Base.EltypeUnknown, isz::Base.HasShape{…})
    @ Base ./array.jl:854
  [8] collect_similar
    @ ./array.jl:763 [inlined]
  [9] map
    @ ./abstractarray.jl:3285 [inlined]
 [10] latexoperation(ex::Expr, prevOp::Vector{Symbol}; kwargs::@kwargs{convert_unicode::Bool, index::Symbol, env::Symbol})
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexoperation.jl:21
 [11] latexoperation
    @ ~/.julia/packages/Latexify/ieukI/src/latexoperation.jl:9 [inlined]
 [12] (::Latexify.var"#recurseexp!#44"{Bool, @kwargs{index::Symbol, env::Symbol}})(ex::Expr)
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexraw.jl:98
 [13] _latexraw(inputex::Expr; convert_unicode::Bool, kwargs::@kwargs{index::Symbol, env::Symbol})
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexraw.jl:102
 [14] process_latexify(args::Expr; kwargs::@kwargs{index::Symbol, env::Symbol})
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexify_function.jl:49
 [15] process_latexify
    @ ~/.julia/packages/Latexify/ieukI/src/latexify_function.jl:40 [inlined]
 [16] latexraw
    @ ~/.julia/packages/Latexify/ieukI/src/latexraw.jl:58 [inlined]
 [17] _latexequation(eq::Expr; starred::Bool, kwargs::@kwargs{index::Symbol, env::Symbol})
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexequation.jl:5
 [18] process_latexify(args::Equation; kwargs::@kwargs{})
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexify_function.jl:49
 [19] process_latexify
    @ ~/.julia/packages/Latexify/ieukI/src/latexify_function.jl:40 [inlined]
 [20] latexify(args::Equation; kwargs::@kwargs{})
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexify_function.jl:27
 [21] latexify(args::Equation)
    @ Latexify ~/.julia/packages/Latexify/ieukI/src/latexify_function.jl:25
 [22] top-level scope
    @ REPL[14]:1
Some type information was truncated. Use `show(err)` to see complete types.
```

@gustaphe do you know why this recipe is missed?
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

Successfully merging this pull request may close these issues.

2 participants