Code Monkey home page Code Monkey logo

pyelmer's People

Contributors

aerosmite avatar anilkunwar avatar arvedes avatar db434 avatar jonathanrayner avatar mfschroeder avatar muddi900 avatar tpgillam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyelmer's Issues

pyelmer dependence of solver-specific keywords

Currently the classes Boundary, Material, BodyForce etc. contain many keywords for a specific solver in Elmer. These are now stored in pyelmer-internal YAML files or, even worse, programmed directly into the pyelmer code. There are hundreds of solvers and thousands of keywords in Elmer. pyelmer cannot possibly deal with them all. It would be better if such keywords would be stored in YAML files in the simulation folder, where the user of pyelmer can see them and is encouraged to edit them.

As a first try I made a few commits to allow for a more flexible use of YAML files. However, more changes in pyelmer would be necessary: to change boundary settings loaded from the file, to avoid many repeating lines in the YAML files, etc.

H-B curve in material definitions.

I'm trying to work out how one should define a nonlinear BH curve for a MagnetoDynamics2D
simulation.
I think the SIF file I should end up with should look like:

Material 2
 Name = "Iron"
 Electric Conductivity = 0
! keyword is H-B curve, but values are in B-H format
 H-B Curve = Variable coupled iter
 Real Monotone Cubic
 Include BH
 End
End 

I've tried as yml file

m230-35:
  #Density: 7900.0  # 20°C
  Electric Conductivity: 1.37e+6  # 20°C
  #Emissivity: 0.111  # 200°C
  #Heat Capacity:  470.0 # 20°C
  #Heat Conductivity: 15.0 # 20°C
  #Relative Permeability: 1
  #Relative Permittivity: 1
  H-B Curve : 
    Variable: "dummy" 
    Cubic: 'Monotone'
    include: 'HB' 

which results in:

! m230-35
Material 4
  Electric Conductivity = 1370000.0
  H-B Curve = {'Variable': 'dummy', 'Cubic': 'Monotone', 'include': 'HB'}
End

Missing support for several solvers

I would like to set up a multi-physics simulation in pyelmer. This involves HeatSolve, FlowSolve, StressSolve, MagnetoDynamics, MagnetoDynamics2D, MeshSolve, SaveData and probably a few more post-processing solvers. Boundary conditions, body forces, etc., are currently not specified, i.e., need to be flexible in my case. Which solvers currently are supported by pyelmer and what are plans for the near future? I would like to install pyelmer in a package folder shared between several users and set-up/run my simulations without changing pyelmer itself.

Precice adapator

Hi,

This is not an issue, only a suggestion to include precice adaptor into pyelmer. Do you have any roadmap for that?

Simplification of pyelmer

We (Kaspars & Arved) want to simplify pyelmer a bit to make it easier to maintain, as discussed here #4 . For this, solver-specific key words shall be adjusted in three steps:

  1. change the examples to lead new users to use the data-dictionary
  2. re-implement the keywords elsewhere in a derived class, e.g. class BoundaryWithKeywords(Boundary)
  3. remove the keywords from main module elmer.py

To encourage new users to use their own settings (referring to #5), the data directory shall be moved to the examples directory and not be distributed with the package anymore. This change is also motivated by the fact that it is impossible to provide universal default settings for a solver, simulation, etc. The interface for working with these files may be adapted a bit in consideration of #3.

Eventually, we want to move the gmsh module to another project. It fits well into the pyelmer workflow, but does not contribute to its key functionality. I'm not sure what the result will look like, but I am confident that these changes are possible without affecting the user interface (by introducing the new project as dependency).

I hope that we can make a v1.0.0 release once all this is completed!

I'll continue with all this after my summer holiday, but I'd be happy to get some feedback until then!

Add "names" to sif

It would be nice to include the name of the Body, Boundary, etc., in the sif file not only as a comment but in the form:

Body 1
    Name = <Body.name>
    (...)
End

It enables, e.g., a better output using Vtu Part collection = True in ResultOutputSolver.

It has already been implemented for the new Component class:

pyelmer/pyelmer/elmer.py

Lines 411 to 415 in 56cfe2d

def get_data(self):
"""Generate dictionary with data for sif-file."""
d = {
"Name": self.name,
}

The other classes and the corresponding tests need to be adjusted similarly.

use os.path.join consistently

In #21 construction of filepaths has been partially changed to os.path.join. This should be done consistently throughout the code.

provide solver keywords in a structured manner

Background: The keywords for solvers related to crystal growth simulations (HeatSovler, PhaseChangeSolver, StatMag, MgDyn2DHarmonic) were originally implemented in pyelmer, then moved to the submodule elmerkw. Currently, using these parameters is not the recommended workflow and importing elmerkw raises a DeprecationWarning. Instead, the user is encouraged to provide the keywords in a dictionary.

I think providing keywords is great advantage of pyelmer and gives a huge benefit to the users because they can rely on autocomplete functionality of their IDE instead of looking everything up in the manuals. It'd be great to bring back this functionality to the main elmer module but in a more structured manner helping the users to find the right keywords for their solvers. I am thinking of something like:

bc_bottom = elmer.Boundary(...)
bc_bottom .heatsovler.fixed_heatflux = 10
bc_bottom .magnetodynamics.electric_current_density = 100
(...)

Basic problem getting pyelmer running

On windows 10, python 3.10, installed pyelmer with pip command, we are getting the following error after trying to run one of the example scripts:

Traceback (most recent call last):
  File "path to\crystal_growth_2d.py", line 14, in <module>
    from pyelmer import elmer
  File "path to\Python310\site-packages\pyelmer\__init__.py", line 2, in <module>
    from . import elmer, execute, gmsh, post
  File "path to\Python310\site-packages\pyelmer\gmsh.py", line 4, in <module>    
    import gmsh
  File "path to\Python310\site-packages\gmsh.py", line 53, in <module>
    lib = CDLL(libpath)
  File "path to\lib\ctypes\__init__.py", line 364, in __init__
    if '/' in name or '\\' in name:
TypeError: argument of type 'NoneType' is not iterable

Any hints?

Trouble with pyelmer.gmsh (objectgmsh Fixed)

Hello,
This issue seems basic, but I am having trouble finding the pyelmer.gmsh module- I followed all the steps to download/install pyelmer to my IDE, but I cannot fix this issue. I searched inside the internal function but could not locate the module as stated.

  • I ran the example code of a simple heat transfer simulation

Thanks,
Jaden C.

Use names instead of IDs

The solver can be configured using names instead of ids of gmsh physical groups. Using this as default option in pyelmer would simplify the simulation setup.

Referencing to other bodies / boundaries etc. not working

In some setups it is required to reference another body, e.g. for definition of an intersection BC. In the sif it looks like this:

Boundary Condition 1
  Target Boundaries(1) = 1
End
Boundary Condition 2
  Target Boundaries(1) = 2
End
Boundary Condition 3
  Intersection BC(2) = Integer 1 2  ! reference to BCs defined above
  (...)
End

Problem with Python 3.11

Tried to setup and run examples. Exception with python 3.11.

File "/Users/pw/dml/elmertest.py", line 3, in
from pyelmer import elmer
File "/Users/pw/dml/lib/python3.11/site-packages/pyelmer/init.py", line 2, in
from . import elmer, execute, post
File "/Users/pw/dml/lib/python3.11/site-packages/pyelmer/post.py", line 17, in
@DataClass
^^^^^^^^^
File "/Users/pw/.pyenv/versions/3.11.1/lib/python3.11/dataclasses.py", line 1220, in dataclass
return wrap(cls)
^^^^^^^^^
File "/Users/pw/.pyenv/versions/3.11.1/lib/python3.11/dataclasses.py", line 1210, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pw/.pyenv/versions/3.11.1/lib/python3.11/dataclasses.py", line 958, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/pw/.pyenv/versions/3.11.1/lib/python3.11/dataclasses.py", line 815, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'pyelmer.post.LinearIteration'> for field linear_iteration is not allowed: use default_factory
(dml) pw@Pauls-iMac dml %

Output of SaveData/SaveScalars solver

This solver is very useful to get data on boundaries, but the current format in Elmer with "data file" and "names file" for all boundaries together is very hard to read. Could pyelmer include a functionality to improve this? For example, each boundary gets a separate output file in table format: 1st column = variable names, n-th column = value in time step n. For time series plotting this needs to be transposed, so a switch for both formats would be helpful.

Improve run_elmer_grid function

There are some limitations of the run_elmer_grid function:

  • It only works with Gmsh msh-files
  • It moves all the output back into the directory where the msh-file is (this should be default but optional)
  • It doesn’t support any additional arguments for ElmerGrid (e.g. for partitioning)

It shouldn't be a big deal to implement that.

ElmerGrid (or elmerSolver) not found from Windows %PATH% variable

While trying to execute a pyelmer example, I got an error FileNotFoundError: [WinError 2] from execute.run_elmer_grid.
Unfortunately python's subprocess doesn't look into %PATH% variable while trying to run, so I found a little workaround :
I decided to look for the executable (ElmerGrid or ElmerSolver depending on the called function) in the %PATH% variable, and replaced

if elmergrid is None:
        # On Windows ElmerGrid.exe is not found once gmsh.initialize() was executed.
        # Try to use abs-path instead.
        if os.path.exists('C:/Program Files/Elmer 8.4-Release/bin/ElmerGrid.exe'):
            elmergrid = 'C:/Program Files/Elmer 8.4-Release/bin/ElmerGrid.exe'
        else:
            elmergrid = 'ElmerGrid'

with

found = False
if elmergrid is None:
	# On Windows ElmerGrid.exe is not found once gmsh.initialize() was executed.
	# Try to use abs-path instead.
	if os.path.exists('C:/Program Files/Elmer 8.4-Release/bin/ElmerGrid.exe'):
		elmergrid = 'C:/Program Files/Elmer 8.4-Release/bin/ElmerGrid.exe'
	else:
		for dir in os.environ.copy()["PATH"].split(';'):
			if os.path.exists(dir+'\\ElmerGrid.exe'):
				elmergrid = dir+'\\ElmerGrid.exe'
				found = True
		if not found:
			elmergrid = 'ElmerSolver'

and of course the same for run_elmer_solver. It seems to do the trick.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.