# Use of complex numbers in ModelingToolkit using @mtkmodel macro

**URL:** https://discourse.julialang.org/t/use-of-complex-numbers-in-modelingtoolkit-using-mtkmodel-macro/130332
**Category:** New to Julia
**Tags:** modelingtoolkit
**Created:** [June 30, 2025, 10:16am UTC](https://discourse.julialang.org/t/use-of-complex-numbers-in-modelingtoolkit-using-mtkmodel-macro/130332 "2025-06-30T10:16:31Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![JaviJR](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/javijr/32/218294_2.png) [@JaviJR](https://discourse.julialang.org/u/JaviJR)
#### Post date: [June 30, 2025, 10:16am UTC](https://discourse.julialang.org/t/use-of-complex-numbers-in-modelingtoolkit-using-mtkmodel-macro/130332/1 "2025-06-30T10:16:32Z")

</div>

**Hello,**  
I’ve been running some tests with ModelingToolkit, and when trying to implement equations that use complex numbers using `@mtkmodel` macro, I haven’t been able to assign initial values to the system without it failing. For example, when creating the following system, I get the error “_ **type ComplexTerm has no field metadata** _”. Does anyone know if this happens because I implemented it incorrectly, or is it simply that ModelingToolkit isn’t yet designed to handle systems involving complex numbers?

```julia
@mtkmodel Complex begin

	@parameters begin

		R = 1.0
		C = 1.0
		ω = 1

	end

	@variables begin

        i(t)::ComplexF64 = 1.0 + 0.3 * im
        u(t)::ComplexF64 

	end

	@equations begin

		u ~ (R + 1 / (im * ω * C))*i

	end
end

@mtkbuild model = Complex()

```

Thanks in advance.

---

<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: [June 30, 2025, 10:32am UTC](https://discourse.julialang.org/t/use-of-complex-numbers-in-modelingtoolkit-using-mtkmodel-macro/130332/2 "2025-06-30T10:32:18Z")

</div>

The macro does not support complex well IIRC
