-
-
Notifications
You must be signed in to change notification settings - Fork 39
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
[WIP] Add Latexify extension and AnalysisPoint support #339
Open
ChrisRackauckas
wants to merge
1
commit into
main
Choose a base branch
from
latexify
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Though it's really weird... it completely ignores the recipe. MWE:
@gustaphe do you know why this recipe is missed?