Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

imas2tofu with two 2D grids #1031

Open
tbarbui opened this issue Feb 10, 2025 · 1 comment
Open

imas2tofu with two 2D grids #1031

tbarbui opened this issue Feb 10, 2025 · 1 comment

Comments

@tbarbui
Copy link
Collaborator

tbarbui commented Feb 10, 2025

Hello,

There is an issue with imas2tofu when I load an equilibrium which contains multiple 2D grids.

At WEST in order to retrieve correctly the 2D grids from the equilibrium, imas should be used with the flag user='imas_simulation'.
This correctly imports two 2D grids: one triangular ('2dmeshNodes' and '2dmeshFaces') and one rectangular ('2dmeshR' and '2dmeshZ')

However an error is raised, due to the presence of two different grids?

In [8]: multi = tf.imas2tofu.MultiIDSLoader(
   ...:     	shot=60763,
   ...:         run=0,
   ...:         occ=0,
   ...:         user='imas_simulation',
   ...:         database='west',
   ...:         ids=['equilibrium'],
   ...:         ids_base=False,
   ...: )
   ...: 
Getting ids  [occ]  database  user             version  shot   run  refshot  refrun
-----------  -----  --------  ---------------  -------  -----  ---  -------  ------
equilibrium  [0]    west      imas_simulation  3        60763  0    -1       -1    
/Home/TB275660/Documents/Tofu/tofu/tofu/imas2tofu/_def.py:900: RuntimeWarning: invalid value encountered in sqrt
  return np.sqrt(
/Home/TB275660/Documents/Tofu/tofu/tofu/imas2tofu/_comp.py:869: UserWarning: The following data could not be retrieved:
	- equilibrium:
		x1 data :  'x1R'
		x1R data:  dcond[2]['ind'] = [1] so ind = [1] but len(sig[0]) = 1
		x1Z data:  dcond[2]['ind'] = [1] so ind = [1] but len(sig[0]) = 1
  warnings.warn(msg)
Traceback (most recent call last):

  File "/tmp/ipykernel_46603/4258191158.py", line 10, in <cell line: 10>
    plasma = multi.to_Plasma2D(strict=False)

  File "/Home/TB275660/Documents/Tofu/tofu/tofu/imas2tofu/_core.py", line 2062, in to_Plasma2D
    return _comp_toobjects.get_plasma(

  File "/Home/TB275660/Documents/Tofu/tofu/tofu/imas2tofu/_comp_toobjects.py", line 612, in get_plasma
    raise Exception(msg)

Exception: 2d mesh shall be provided either via:
	- '2dmeshR' and '2dmeshZ'
	- '2dmeshNodes' and '2dmeshFaces'

The two grids are correctly imported:

dout = multi.get_data('equilibrium', strict=False)
In [11]: dout['equilibrium']['2dmeshNodes']['data'].shape
Out[11]: (7950, 2)

In [12]: dout['equilibrium']['2dmeshR']['data'].shape
Out[12]: (60, 60)
@tbarbui
Copy link
Collaborator Author

tbarbui commented Feb 12, 2025

lprof2d = None
        if len(out_) > 0 and cmesh is True:

            npts, datashape = None, None
            keym = None

            # ----
            # mesh

            keym = f'{idsshort}.mesh'
            lc = [
                all([ss in lsig for ss in ['2dmeshNodes', '2dmeshFaces']]),
                all([ss in lsig for ss in ['2dmeshR', '2dmeshZ']]),
            ]
            if not np.sum(lc) == 1:
                msg = (
                    "2d mesh shall be provided either via:\n"
                    "\t- '2dmeshR' and '2dmeshZ'\n"
                    "\t- '2dmeshNodes' and '2dmeshFaces'"
                )
                raise Exception(msg)

            # Nodes / Faces case
            if lc[0]:
                coll.add_mesh_2d_tri(
                    key=keym,
                    knots=out_['2dmeshNodes']['data'],
                    indices=out_['2dmeshFaces']['data'],
                    source=ids,
                )
                n1 = coll.dobj[wm][keym]['shape-k'][0]
                n2 = coll.dobj[wm][keym]['shape-c'][0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant