gafusion / omas

Ordered Multidimensional Array Structure
http://gafusion.github.io/omas
MIT License
30 stars 15 forks source link

Possible bug in identify_cocos #160

Closed lstagner closed 3 years ago

lstagner commented 3 years ago

I'm implementing my own COCOS and I'm using your code as a basis. I think there might be a bug

https://github.com/gafusion/omas/blob/7e21883065119cad530138dc4d1c94b29d1572e8/omas/omas_physics.py#L1986-L1991

If phi is clockwise shouldn't sigma_rpz be negative not positive. See Table 1 (below) in the COCOS paper

Screen Shot 2021-04-30 at 9 05 09 PM

When I implemented this in my COCOS my tests were failing on the GEQDSK with known native cocos.

dir = @__DIR__
g1 = readg(dir*"/g150219.03200") # (+Bt, +Ip) COCOS = 1
g2 = readg(dir*"/g133221.01150") # (-Bt, +Ip) COCOS = 5
g3 = readg(dir*"/g159177.02700") # (+Bt, -Ip) COCOS = 3
g4 = readg(dir*"/g153298.04400") # (-Bt, -Ip) COCOS = 7
COCOS Tests: Test Failed at /Users/lstagner/.julia/dev/Equilibrium/test/runtests.jl:50
  Expression: identify_cocos(g1, clockwise_phi=false) == (1,)
   Evaluated: (2,) == (1,)
COCOS Tests: Test Failed at /Users/lstagner/.julia/dev/Equilibrium/test/runtests.jl:51
  Expression: identify_cocos(g2, clockwise_phi=false) == (5,)
   Evaluated: (6,) == (5,)
COCOS Tests: Test Failed at /Users/lstagner/.julia/dev/Equilibrium/test/runtests.jl:52
  Expression: identify_cocos(g3, clockwise_phi=false) == (3,)
   Evaluated: (4,) == (3,)
COCOS Tests: Test Failed at /Users/lstagner/.julia/dev/Equilibrium/test/runtests.jl:53
  Expression: identify_cocos(g4, clockwise_phi=false) == (7,)
   Evaluated: (8,) == (7,)
orso82 commented 3 years ago

I think you are correct @lstagner

@bclyons12 can you weight in?

bclyons12 commented 3 years ago

You are correct. sigma_rpz=-1 is clockwise phi. That function is just supposed to identify a given COCOS and I don't think it's actively used anywhere in omas or OMFIT. All the transform functions should be properly implemented, so this is an easy fix.

@lstagner I've spent way more time than I'm proud of doing COCOS stuff. Please keep me apprised of what you're working on. Is this in Julia? Is there a repository I can be invited to?

lstagner commented 3 years ago

I have invited you and Orso to the JuliaFusion Organization where I've have been keeping fusion related julia code. The COCOS work is currently in the Equilibrium.jl package but I am planning to move it into its own repository.