Passing vectors of data into MTK/MoL problem as parameter

I have been able to use vectors of data that I’ve passed through DataInterpolations as inputs/boundary conditions to a ModelingToolkit/MethodOfLines problem, but I would like to use the data vectors as MTK parameters to automate changing my system conditions. I’ve been struggling for a while now and I can’t find any documentation on how to do this. Is there something I’m missing or should I look for a different way to adjust my system inputs?

I’ve adapted one of the tutorials from MethodOfLines to show what I’m trying to do, and verified that it creates the same errors.

using DifferentialEquations, ModelingToolkit, MethodOfLines, DomainSets, DataInterpolations

input_temperature = [1 2 2 3 2 1]
input_time = [0 1 2 3 4 5]
# Parameters, variables, and derivatives
@parameters input_temperature, input_time
@variables t, x, u(..)
params = [input_temperature => input_temperature, input_time => input_time]
Dt = Differential(t)
Dxx = Differential(x)^2

# 1D PDE and boundary conditions
eq  = Dt(u(t, x)) ~ Dxx(u(t, x))
bcs = [u(0, x) ~ cos(x),
        u(t, 0) ~ LinearInterpolation(input_temperature, input_time),
        u(t, 1) ~ exp(-t) * cos(1)]

# Space and time domains
domains = [t ∈ Interval(0.0, input_time[end]),
           x ∈ Interval(0.0, 1.0)]

# PDE system

@named pdesys = PDESystem(eq, bcs, domains, [t, x], [u(t, x)], params)

# Method of lines discretization
dx = 0.1
order = 2
discretization = MOLFiniteDifference([x => dx], t)

# Convert the PDE problem into an ODE problem
prob = discretize(pdesys,discretization)

# Solve ODE problem
using OrdinaryDiffEq
sol = solve(prob, Tsit5(), saveat=0.2)

#Ideally, I would be able to do something like this to modify timeseries data 
newprob = remake(prob, p = [[3 3 2 1 4], [0 2 4 5 8]])
sol2 = solve(newprob, Tsit5(), saveat=0.2)

This doesn’t work right now but we plan to have a solution by JuliaCon.

1 Like

Okay, thanks! I’ll work on an alternative until then.