Using Modeling Toolkit to solve simple equation

I shall pretense this with that I am very new to ModelingToolkit
As part of a bigger system I have a laser source term which chnages based on the type of a struct defining the equation. This means that I want to build a function that defines the laser based on type and make this a modeling toolkit model to the implement elsewhere in my equations. However this equation isn’t a D(t) but rather a f(t) equation. Is there a way to make modeling toolkit solve these without differentiating? Currently when I use structural_simply(eq) the equation just disappears.

Here is a rough MWE that simulates this and matches my usecase without the multiple dispatch on types.

function test_eq(;name)
    @parameters a b 
    @variables y(t)

    eqs =  [y ~ a*t + b]


@named testeq=test_eq()


After you run structural_simplify, the whole equation vanishes as I guess it isn’t a differential equation but I’m not sure.

Thanks for any help

You don’t need ModelingToolkit for this, Symbolics is enough

julia> @parameters a b
2-element Vector{Num}:

julia> @variables y
1-element Vector{Num}:

julia> eq = y ~ a*t + b
y ~ b + a*t

julia> Symbolics.solve_for(eq, t)
(-b + y) / a
1 Like

Thank you very much.

Could I then use this to sub into an ODE, as I said prior this is mainly for a time dependent variable. I have shown below how the structure of the code needs to somewhat look like so I assumed that this component would require some form of ODEProblem or equivalent to sub it into further equations

function (::Gaussian)(;name)
    @parameters FWHM  Offset
    @variables tp(t)
    eqs = [tp ~ sqrt(4*log(2)/pi)/FWHM*exp(-4*log(2)*(t-(2*FWHM)-Offset)^2/FWHM^2)]

function tester(;name)
    @variables S(t) T(t)
    eqs = [D(T) ~ S]


@named gauss_laser=lp()
@named testconnector=tester()

connections = [testconnector.S ~]