Skip to content

Commit eb2fa18

Browse files
refactor: move @compile_workload to after exports
1 parent bbc1cbc commit eb2fa18

File tree

1 file changed

+35
-35
lines changed

1 file changed

+35
-35
lines changed

src/ModelingToolkit.jl

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -242,41 +242,6 @@ const D_nounits = Differential(t_nounits)
242242
const D_unitful = Differential(t_unitful)
243243
const D = Differential(t)
244244

245-
PrecompileTools.@compile_workload begin
246-
using ModelingToolkit
247-
@variables x(ModelingToolkit.t_nounits)
248-
@named sys = System([ModelingToolkit.D_nounits(x) ~ -x], ModelingToolkit.t_nounits)
249-
prob = ODEProblem(mtkcompile(sys), [x => 30.0], (0, 100), jac = true)
250-
@mtkmodel __testmod__ begin
251-
@constants begin
252-
c = 1.0
253-
end
254-
@structural_parameters begin
255-
structp = false
256-
end
257-
if structp
258-
@variables begin
259-
x(t) = 0.0, [description = "foo", guess = 1.0]
260-
end
261-
else
262-
@variables begin
263-
x(t) = 0.0, [description = "foo w/o structp", guess = 1.0]
264-
end
265-
end
266-
@parameters begin
267-
a = 1.0, [description = "bar"]
268-
if structp
269-
b = 2 * a, [description = "if"]
270-
else
271-
c
272-
end
273-
end
274-
@equations begin
275-
x ~ a + b
276-
end
277-
end
278-
end
279-
280245
export ODEFunction, convert_system_indepvar,
281246
System, OptimizationSystem, JumpSystem, SDESystem, NonlinearSystem, ODESystem
282247
export SDEFunction
@@ -378,4 +343,39 @@ for prop in [SYS_PROPS; [:continuous_events, :discrete_events]]
378343
@eval @public $getter, $hasfn
379344
end
380345

346+
PrecompileTools.@compile_workload begin
347+
using ModelingToolkit
348+
@variables x(ModelingToolkit.t_nounits)
349+
@named sys = System([ModelingToolkit.D_nounits(x) ~ -x], ModelingToolkit.t_nounits)
350+
prob = ODEProblem(mtkcompile(sys), [x => 30.0], (0, 100), jac = true)
351+
@mtkmodel __testmod__ begin
352+
@constants begin
353+
c = 1.0
354+
end
355+
@structural_parameters begin
356+
structp = false
357+
end
358+
if structp
359+
@variables begin
360+
x(t) = 0.0, [description = "foo", guess = 1.0]
361+
end
362+
else
363+
@variables begin
364+
x(t) = 0.0, [description = "foo w/o structp", guess = 1.0]
365+
end
366+
end
367+
@parameters begin
368+
a = 1.0, [description = "bar"]
369+
if structp
370+
b = 2 * a, [description = "if"]
371+
else
372+
c
373+
end
374+
end
375+
@equations begin
376+
x ~ a + b
377+
end
378+
end
379+
end
380+
381381
end # module

0 commit comments

Comments
 (0)