Skip to content

Issue281 new default configs - AUG#333

Merged
lasofivec merged 17 commits intodevelfrom
Issue281_NewDefaultConfigs
Jan 24, 2020
Merged

Issue281 new default configs - AUG#333
lasofivec merged 17 commits intodevelfrom
Issue281_NewDefaultConfigs

Conversation

@Didou09
Copy link
Copy Markdown
Member

@Didou09 Didou09 commented Jan 23, 2020

Main changes:

And AUG now appears in the available configs message created by PR #327

In [1]: import tofu as tf 

In [2]: tf.geom.utils.get_available_config()
A config is the geometry of a tokamak
You can define your own, see online tutorial at:
	https://tofuproject.github.io/tofu/auto_examples/tutorials/tuto_plot_create_geometry.html
tofu also also provides some pre-defined config ready to load
They are available via their name or via shortcuts

	unique names	shortcuts
	------------ 	-------------------------
	- AUG-V1      	['AUG-V1', 'AUG']
	- ITER-V1     	['ITER-V1', 'A2']
	- ITER-V2     	['ITER-V2', 'B4', 'ITER']
	- JET-V0      	['JET-V0', 'JET']
	- NSTX-V0     	['NSTX-V0', 'NSTX']
	- WEST-Sep    	['WEST-Sep', 'A3']
	- WEST-V1     	['WEST-V1', 'A1']
	- WEST-V2     	['WEST-V2', 'B1']
	- WEST-V3     	['WEST-V3', 'B2']
	- WEST-V4     	['WEST-V4', 'B3', 'WEST']

  => to get a pre-defined config, call for example:
	config = tf.geom.utils.create_config('ITER')

In [3]: conf = tf.geom.utils.create_config('AUG')

In [4]: conf.plot()

PR_AUG

Perspectives:

  • A more detailed version (with non-axisymmetric details for PFC) should be made available in a future version

Issues:

Acknowledgements:

A contribution obtained with the help of @jdhare

VEZINET Didier and others added 16 commits January 17, 2020 09:22
… in Struct._checkformat_dgeom() and cleaner error handling in tf.geom._comp._Struct_set_Poly()
…ct not valid due to bug in _GG.Poly_isClockwise() inducing error on Vol in _GG.Poly_Order(), probably solved by lasofivec on another branch
…t 3 txt files still not loaded due to bug in _GG. tf.geom.utils.create_Config() more robust vs Struct that can't be loaded (warnings not fatal)
[bf #331] raising exceptions when poly ill defined
@Didou09 Didou09 requested a review from lasofivec January 23, 2020 15:47
@Didou09 Didou09 self-assigned this Jan 23, 2020
@pep8speaks
Copy link
Copy Markdown

pep8speaks commented Jan 23, 2020

Hello @Didou09! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-01-23 15:51:03 UTC

@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #333 into devel will increase coverage by 0.05%.
The diff coverage is 48%.

Impacted file tree graph

@@            Coverage Diff             @@
##            devel     #333      +/-   ##
==========================================
+ Coverage   40.02%   40.08%   +0.05%     
==========================================
  Files          79       79              
  Lines       24128    24172      +44     
==========================================
+ Hits         9658     9689      +31     
- Misses      14470    14483      +13
Impacted Files Coverage Δ
tofu/version.py 100% <100%> (ø) ⬆️
tofu/geom/_comp.py 59.91% <40%> (-0.26%) ⬇️
tofu/geom/_core.py 63.08% <47.36%> (-0.08%) ⬇️
tofu/geom/utils.py 44.61% <0%> (+2.84%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cbcc34c...c10784e. Read the comment docs.

Comment thread tofu/geom/_core.py

# Elimininate any double identical point
ind = np.sum(np.diff(Poly, axis=1) ** 2, axis=0) < 1.0e-12
ind = np.sum(np.diff(np.concatenate((Poly, Poly[:, 0:1]), axis=1),
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you close the poly ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want a bool array ind the same shape as Poly, to tell us which successive points are redundant.
So:

  • We use np.diff() => ind will be of shape (npts-), if poly has shape (2, npts). Concatenating the first poitn at the end (i.e. closing the polygon) will yield the good shape for ind
  • If we don't close the poly here, and if the first point and the last point are identical (poly already closed), np.diff() will not detect it. So closing the poly in np.diff() is actually a good way of making sure we remove (at line 443) the last point if the poly was already closed

Comment thread tofu/geom/utils.py
lS.append(obj)
elif len(ff) > 1:
# More demanding criterion
ssbis, Expbis = '_'+ss+'.txt', '_Exp'+Exp+'_'
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are ss files ?

Copy link
Copy Markdown
Member Author

@Didou09 Didou09 Jan 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this loop, cc is the class str ('PFC', 'Ves'...) and ss is the name of the Struct considered.
The name of a .txt file containing the polygon of a Struct is formatted as

TFG_class_ExpTokamak_Name.txt

For example:

TFG_PFC_ExpAUG_TPLT1.txt

This file contains the polygon for a PFC of experiment ASDEX Upgrade (AUG) which is called TPLT1.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this method we try to identify a unique txt fle corresponding to a given Struct (by class, Exp, name).
A first try is done with simple criteria which are sufficient 90% of the time.
But in some case multiple matches are found, because for example the names of several Struct share a common part, for example:

TFG_PFC_ExpAUG_D3BG1.txt
TFG_PFC_ExpAUG_D3BG10.txt

These are two different Struct. But the name of the first one is fully enclosed in the name of the second.
So if we look for all files containing the str 'D3BG1', we'll find these two solutions.
In that case, we search again with more strict criteria to identify the unique file.

@lasofivec lasofivec merged commit 3e5caf6 into devel Jan 24, 2020
@lasofivec lasofivec deleted the Issue281_NewDefaultConfigs branch January 24, 2020 14:36
@Didou09 Didou09 restored the Issue281_NewDefaultConfigs branch January 24, 2020 14:53
@Didou09
Copy link
Copy Markdown
Member Author

Didou09 commented Jan 24, 2020

Thanks for approving the merge :-)
I'm restoring the branch because this is branch that will live a long time since we will use it every time we'll add a new tokamak (I'm expecting GOLEM, TCV and JET in the coming weeks / months)

@lasofivec
Copy link
Copy Markdown
Collaborator

You can restore it when it is needed but you can also keep it on :)

@Didou09 Didou09 mentioned this pull request Jan 30, 2020
@Didou09 Didou09 mentioned this pull request Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants