|
500 | 500 | @test SciMLBase.successful_retcode(sol) |
501 | 501 | end |
502 | 502 |
|
| 503 | +@testset "Interpolation in model macro" begin |
| 504 | + |
| 505 | + function MassSpringDamper(; name) |
| 506 | + @named input = RealInput() |
| 507 | + @variables f(t) x(t)=0 dx(t)=0 ddx(t) |
| 508 | + @parameters m=10 k=1000 d=1 |
| 509 | + |
| 510 | + eqs = [f ~ input.u |
| 511 | + ddx * 10 ~ k * x + d * dx + f |
| 512 | + D(x) ~ dx |
| 513 | + D(dx) ~ ddx] |
| 514 | + |
| 515 | + ODESystem(eqs, t; name, systems = [input]) |
| 516 | + end |
| 517 | + |
| 518 | + table_data = [1.0, 2.0, 3.0] |
| 519 | + table_bkp = [0.0, 0.5, 1.0] |
| 520 | + itp = LinearInterpolation(table_data, table_bkp) |
| 521 | + |
| 522 | + @mtkmodel model_with_lut begin |
| 523 | + @components begin |
| 524 | + src = Interpolation(itp) |
| 525 | + clk = ContinuousClock() |
| 526 | + model = MassSpringDamper() |
| 527 | + end |
| 528 | + @equations begin |
| 529 | + connect(src.input, clk.output) |
| 530 | + connect(src.output, model.input) |
| 531 | + end |
| 532 | + end; |
| 533 | + @mtkbuild sys = model_with_lut() |
| 534 | + |
| 535 | + prob = ODEProblem(sys, [], (0.0, 1)) |
| 536 | + sol = solve(prob, Tsit5()) |
| 537 | + |
| 538 | + @test SciMLBase.successful_retcode(sol) |
| 539 | +end |
| 540 | + |
503 | 541 | @testset "ParametrizedInterpolation" begin |
504 | 542 | @variables y(t) = 0 |
505 | 543 | u = rand(15) |
|
0 commit comments