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

Suggestions: temporary arrays in dd #109

Open
bclyons12 opened this issue Dec 28, 2023 · 4 comments
Open

Suggestions: temporary arrays in dd #109

bclyons12 opened this issue Dec 28, 2023 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@bclyons12
Copy link
Member

Often times in FUSE and such we need to create intermediary arrays, e.g.
https://github.com/ProjectTorreyPines/FUSE.jl/blob/d7b49e00f733b363c33f1287a680666001727842/src/actors/build/oh_magnet.jl#L80
What if we imbedded some temporary arrays within the dd, e.g., inside core_profiles.profiles_1d[] and the like? Then we could do these calculations without allocations.

@bclyons12 bclyons12 added the enhancement New feature or request label Dec 28, 2023
@bclyons12
Copy link
Member Author

Maybe this could be automated if we already track any dd quantity that's a dimension? We would need to be careful of multithreading of course

@orso82
Copy link
Member

orso82 commented Dec 28, 2023

@bclyons12 can you please take a look at the temporary IDS and see if it could be used for this purpose?
It looks like it can support 0D...6D data both time dependent and not.

IMASDD.temporary  Storage of undeclared data model components
├─ constant_float0d[:] [mixed]  Constant 0D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
├─ constant_float1d[:] [mixed]  Constant 1D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
├─ constant_float2d[:]  Constant 2D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
├─ constant_float3d[:]  Constant 3D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
├─ constant_float4d[:]  Constant 4D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
├─ constant_float5d[:]  Constant 5D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
├─ constant_float6d[:]  Constant 6D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
├─ constant_integer0d[:]  Constant 0D integer
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
├─ constant_integer1d[:]  Constant 1D integer
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
├─ constant_integer2d[:]  Constant 2D integer
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
├─ constant_integer3d[:]  Constant 3D integer
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
├─ constant_string0d[:]  Constant 0D string
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
├─ constant_string1d[:]  Constant 1D string
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
├─ dynamic_float1d[:]  Dynamic 1D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
│     ├─ data [mixed]  Data
│     └─ time [s]  Time
├─ dynamic_float2d[:]  Dynamic 2D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
│     ├─ data [mixed]  Data
│     └─ time [s]  Time
├─ dynamic_float3d[:]  Dynamic 3D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
│     ├─ data [mixed]  Data
│     └─ time [s]  Time
├─ dynamic_float4d[:]  Dynamic 4D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
│     ├─ data [mixed]  Data
│     └─ time [s]  Time
├─ dynamic_float5d[:]  Dynamic 5D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
│     ├─ data [mixed]  Data
│     └─ time [s]  Time
├─ dynamic_float6d[:]  Dynamic 6D float
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value [mixed]  Value
│     ├─ data [mixed]  Data
│     └─ time [s]  Time
├─ dynamic_integer1d[:]  Dynamic 1D integer
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
│     ├─ data  Data
│     └─ time [s]  Time
├─ dynamic_integer2d[:]  Dynamic 2D integer
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
│     ├─ data  Data
│     └─ time [s]  Time
├─ dynamic_integer3d[:]  Dynamic 3D integer
│  ├─ identifier  Description of the quantity using the standard identifier structure
│  │  ├─ description  Verbose description
│  │  ├─ index  Integer identifier (enumeration index within a list). Private identifier values must be indicated by a negative
│  │  │  index.
│  │  └─ name  Short string identifier
│  └─ value  Value
│     ├─ data  Data
│     └─ time [s]  Time

@bclyons12
Copy link
Member Author

bclyons12 commented Dec 28, 2023

Not quite what I had in mind. My idea is the preallocate the temporary arrays once the size of the dimensions are known. You would need a separate one for each dimension.

Perhaps we could use the temporary IDS if we wanted to allocate on the fly and check dimensions each time, reallocating if they're wrong. At least then you only allocate once if it's in a loop or something. Some clever macros or functions to handle that would help.

@orso82
Copy link
Member

orso82 commented Dec 28, 2023

Ok, I think I get it. Essentially in your example you'd like to do .=:

    bd.oh.flattop_duration .= bd.flux_swing.flattop / abs(integrate(cp1d.grid.area, cp1d.j_ohmic ./ cp1d.conductivity_parallel))

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

No branches or pull requests

2 participants