# Declare type of @variable (e.g. complex) in ModelingToolkit.jl

**URL:** https://discourse.julialang.org/t/declare-type-of-variable-e-g-complex-in-modelingtoolkit-jl/59563
**Category:** Modelling & Simulations
**Tags:** modelingtoolkit, symbolics
**Created:** [April 18, 2021, 9:15pm UTC](https://discourse.julialang.org/t/declare-type-of-variable-e-g-complex-in-modelingtoolkit-jl/59563 "2021-04-18T21:15:20Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Sciemon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sciemon/32/20897_2.png) [@Sciemon](https://discourse.julialang.org/u/Sciemon)
#### Post date: [April 18, 2021, 9:15pm UTC](https://discourse.julialang.org/t/declare-type-of-variable-e-g-complex-in-modelingtoolkit-jl/59563/1 "2021-04-18T21:15:20Z")

</div>

Is there a way to declare the type of a variable in ModelingToolkit.jl? For example something like

```julia
@variables a(t)::complex

```

I’m excited to start with ModelingToolkit.jl having followed its development for a while. In my field (power systems) complex variables are ubiquitous and the model is a mixture between complex and real variables. I haven’t found a way to unambiguously declare a variable as complex. I tried to use the initial conditions that are passed the  
ODEProblem but this doesn’t seem to work. I think it needs to be done before simplifying the model (structural\_simplify).  
The current behavior is also that some real variables are assumed complex.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [April 18, 2021, 10:30pm UTC](https://discourse.julialang.org/t/declare-type-of-variable-e-g-complex-in-modelingtoolkit-jl/59563/2 "2021-04-18T22:30:09Z")

</div>

It’s coming fairly soon but you can’t at this moment.

---

<div class="post-metadata">

### Author: ![Sciemon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sciemon/32/20897_2.png) [@Sciemon](https://discourse.julialang.org/u/Sciemon)
#### Post date: [April 18, 2021, 10:39pm UTC](https://discourse.julialang.org/t/declare-type-of-variable-e-g-complex-in-modelingtoolkit-jl/59563/3 "2021-04-18T22:39:08Z")

</div>

Thanks for the prompt reply.

---

<div class="post-metadata">

### Author: ![Rohan\_Rajagopal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rohan_rajagopal/32/34183_2.png) [@Rohan\_Rajagopal](https://discourse.julialang.org/u/Rohan_Rajagopal)
#### Post date: [May 23, 2022, 10:17am UTC](https://discourse.julialang.org/t/declare-type-of-variable-e-g-complex-in-modelingtoolkit-jl/59563/4 "2022-05-23T10:17:22Z")

</div>

Greetings!

Apologies for bumping this old thread, is there any update on the use of complex variables in modelingtoolkit?

Looking forward.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [May 23, 2022, 12:57pm UTC](https://discourse.julialang.org/t/declare-type-of-variable-e-g-complex-in-modelingtoolkit-jl/59563/5 "2022-05-23T12:57:27Z")

</div>

The stuff here was implemented, but it’s still early.
