-
I would like to integrate a system of differential equations in which the evolution of a real component depends upon an indicator of the remaining complex components.
Is it possible to use ComponentArray so that u.m is Float64 at every step? The code above returns `ComponentVector{ComplexF64}(v = ComplexF64[0.9803381875004509 - 0.19732470228080312im, 0.0 + 0.0im], m = ComplexF64[1.2197284031519102 + 0.0im])' I understand that ArrayPartition
yields the desired output but I do not understand how to pass this output to an ODEProblem |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
You could technically do this by doing test_u0 = ComponentArray{Union{Float64, ComplexF64}(v=[1.0 + 0.0*im, 0.0+im*0.0], m= 1.0) But it’s probably going to be slightly slower than keeping everything complex and converting |
Beta Was this translation helpful? Give feedback.
-
Please bear with me but I thik I do not understand the syntax correctly. If I enter
I get
which does not look to me the desired result. Many thanks! |
Beta Was this translation helpful? Give feedback.
-
I can definitely work with complex, as you suggest. I was just curious. ComponentArrays allowed me to finally get a quantum trajectory code to work properly :). I wanted only to further test its functionalyity. Many thanks for your work! |
Beta Was this translation helpful? Give feedback.
Interesting.
The solver must be doing something to promote the types then. I don’t think there’s much we can do about that.It looks like ComponentArrays is converting that type. But either way, is there any reason you can’t use a complex number form
and just convert it to real whenever you want to use it? That will be the most performant option.