ogs6py

Python-API for the OpenGeoSys (http://www.opengeosys.org) software.

https://github.com/joergbuchwald/ogs6py

Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 3 DOI reference(s) in README
  • Academic publication links
    Links to: joss.theoj.org, zenodo.org
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (14.9%) to scientific vocabulary
Last synced: 6 months ago · JSON representation ·

Repository

Python-API for the OpenGeoSys (http://www.opengeosys.org) software.

Basic Info
  • Host: GitHub
  • Owner: joergbuchwald
  • License: bsd-3-clause
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 2.32 MB
Statistics
  • Stars: 18
  • Watchers: 3
  • Forks: 23
  • Open Issues: 7
  • Releases: 10
Created almost 7 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog Contributing License Citation Authors

README.md

DOI ogs6py_test codecov DOI

ogs6py

ogs6py is a python-API for the OpenGeoSys finite element sofware. Its main functionalities include creating and altering OGS6 input files as well as executing OGS. The package allows to streamline OGS-workflows with python or Julia entirely in jupyter or pluto notebooks as demonstrated in the following video:

video presentation of ogs6py and vtu interface

To alter and execute OGS input, e.g., for looping over parameter ranges, two approaches exist:

1. creating a new input file using python method calls
2. altering existing input files

0. Installation

ogs6py can be easily installed from PyPI

```shell

pip install [--user] ogs6py

```

or the latest version from github:

```shell

pip install [--user] https://github.com/joergbuchwald/ogs6py/archive/refs/heads/master.zip

```

Note that the logfile parser of ogs6py requires at least Python 3.8.

Unittests can be run via

```shell

python tests/test_ogs6py.py

```

CAUTION: naming style of methods has changed (2021-05-20)

1. Documentation for ogs6py

You can find the documentation under https://joergbuchwald.github.io/ogs6py-doc

2. Creating a new input file

The following example consists of a simple mechanics problem. The source file can be found in the examples directory The names of the method calls are based on the corresponing XML tags.

```python from ogs6py import ogs

model = ogs.OGS(PROJECTFILE="simplemechanics.prj") model.geo.addgeom(filename="square1x1.gml") model.mesh.addmesh(filename="square1x1quad1e2.vtu") model.processes.setprocess(name="SD", type="SMALLDEFORMATION", integrationorder="2", soliddensity="rhosr", specificbodyforce="0 0") model.processes.setconstitutiverelation(type="LinearElasticIsotropic", youngsmodulus="E", poissonsratio="nu") model.processes.addprocessvariable(processvariable="processvariable", processvariablename="displacement") model.processes.addprocessvariable(secondaryvariable="sigma", outputname="sigma") model.timeloop.addprocess(process="SD", nonlinearsolvername="basicnewton", convergencetype="DeltaX", normtype="NORM2", abstol="1e-15", timediscretization="BackwardEuler") model.timeloop.setstepping(process="SD", type="FixedTimeStepping", tinitial="0", tend="1", repeat="4", deltat="0.25") model.timeloop.addoutput(type="VTK", prefix="blubb", repeat="1", eachsteps="10", variables=["displacement", "sigma"]) model.parameters.addparameter(name="E", type="Constant", value="1") model.parameters.addparameter(name="nu", type="Constant", value="0.3") model.parameters.addparameter(name="rhosr", type="Constant", value="1") model.parameters.addparameter(name="displacement0", type="Constant", values="0 0") model.parameters.addparameter(name="dirichlet0", type="Constant", value="0") model.parameters.addparameter(name="dirichlet1", type="Constant", value="0.05") model.processvars.setic(processvariablename="displacement", components="2", order="1", initialcondition="displacement0") model.processvars.addbc(processvariablename="displacement", geometricalset="square1x1geometry", geometry="left", type="Dirichlet", component="0", parameter="dirichlet0") model.processvars.addbc(processvariablename="displacement", geometricalset="square1x1geometry", geometry="bottom", type="Dirichlet", component="1", parameter="dirichlet0") model.processvars.addbc(processvariablename="displacement", geometricalset="square1x1geometry", geometry="top", type="Dirichlet", component="1", parameter="dirichlet1") model.nonlinsolvers.addnonlinsolver(name="basicnewton", type="Newton", maxiter="4", linearsolver="generallinearsolver") model.linsolvers.addlinsolver(name="generallinearsolver", kind="lis", solvertype="cg", precontype="jacobi", maxiterationstep="10000", errortolerance="1e-16") model.linsolvers.addlinsolver(name="generallinearsolver", kind="eigen", solvertype="CG", precontype="DIAGONAL", maxiterationstep="10000", errortolerance="1e-16") model.linsolvers.addlinsolver(name="generallinearsolver", kind="petsc", prefix="sd", solvertype="cg", precontype="bjacobi", maxiterationstep="10000", errortolerance="1e-16") model.writeinput() model.runmodel(logfile="out.log") ```

python model.runModel(path="~/github/ogs/build_mkl/bin")

An example using the MPL can be find in example_THM.py.

3. Alternatively it is possible to alter existing files using the available replace methods:

E.g., to iterate over three Young's moduli one can use the replace parameter method:

python Es = [1,2,3] filename = "simple_mechanics.prj" for E in Es: model = OGS(INPUT_FILE=filename, PROJECT_FILE=filename) model.replace_parameter(name="E", value=E) model.replace_text("out_E="+str(E), xpath="./time_loop/output/prefix") model.write_input() model.run_model(path="~/github/ogs/build_mkl/bin")

Instead of the replace_parameter method, the more general replace_text method can also be used to replace the young modulus in this example:

python model.replace_text(E, xpath="./parameters/parameter[name='E']/value")

The Young's modulus in this file can also be accessed through 0'th occurrence of the place addressed by the xpath ./parameters/parameter/value

python model.replace_text(E, xpath="./parameters/parameter/value", occurrence=0)

For MPL based processes, there exist specific functions to set phase and medium properties: e.g.,

python model.replace_phase_property(mediumid=0, phase="Solid", name="thermal_expansivity", value="42")

for a phse property and

python model.replace_medium_property(mediumid=0, name="porosity", value="0.24")

for a property that lives on the medium level.

4. Log-Parser

To parse the OGS output that is piped into a file do

python df = model.parse_out("examples/out_thm.log")

which returns a pandas dataframe.

5. Examples

There are examples that have been used in OGS workflows and may be generalized to other use cases - generating an input file (prj) from a file template by reading parameters from a data file (csv), - finding the optimal coupling scheme parameter for the staggered scheme.

6. FAQ/Troubleshooting

  • OGS exectution fails and nothing is written to the logfile. Please check whether OGS is executed correctly from the terminal. A common issue is related to the fact that the interactive python environment differs from the environment in the terminal. Usually, this can be fixed by setting the required environment variables via a wrapper command. E.g., model.run_model(wrapper="source /opt/intel/oneapi/setvars.sh intel64 &&").

Owner

  • Name: Jörg Buchwald
  • Login: joergbuchwald
  • Kind: user
  • Location: Leipzig
  • Company: UFZ

bio: https://www.researchgate.net/profile/Joerg-Buchwald other gits: - https://gitlab.com/joergbuchwald - https://gitlab.opengeosys.org/joergbuchwald

Citation (CITATION.cff)

cff-version: 1.1.0
message: "If you use this software, please cite it as below."
authors:
  - family-names: Buchwald
    given-names: Jörg
    orcid: https://orcid.org/0000-0001-5174-3603
title: "ogs6py" 
version: v0.33
date-released: 2017-12-18
doi: 10.21105/joss.03673
license: BSD 3-Clause
repository-code: "https://github.com/joergbuchwald/ogs6py"

GitHub Events

Total
  • Watch event: 2
  • Push event: 3
Last Year
  • Watch event: 2
  • Push event: 3

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 360
  • Total Committers: 15
  • Avg Commits per committer: 24.0
  • Development Distribution Score (DDS): 0.214
Past Year
  • Commits: 24
  • Committers: 2
  • Avg Commits per committer: 12.0
  • Development Distribution Score (DDS): 0.042
Top Committers
Name Email Commits
joergbuchwald j****d@u****e 283
Jörg Buchwald b****j@m****1 13
joerg j****g@d****n 12
Thomas Nagel n****t@t****e 8
Dominik Kern d****t@g****m 8
Simon Richter s****r@h****e 7
Norbert Grunwald n****d@u****e 6
OliverPe o****k@g****m 5
Thomas Fischer t****r@u****e 4
Tobias Meisel t****l@u****e 4
petschic o****k@u****e 4
Lars Bilke l****e@u****e 3
Dmitri Naumov g****b@n****e 1
Olaf Kolditz o****z@u****e 1
Wenqing Wang w****g@u****e 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 38
  • Total pull requests: 55
  • Average time to close issues: 20 days
  • Average time to close pull requests: 7 days
  • Total issue authors: 14
  • Total pull request authors: 12
  • Average comments per issue: 0.92
  • Average comments per pull request: 0.76
  • Merged pull requests: 48
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 9
  • Average time to close issues: N/A
  • Average time to close pull requests: 3 minutes
  • Issue authors: 0
  • Pull request authors: 2
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 9
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • joergbuchwald (9)
  • HeiJuli (6)
  • dominik-kern (5)
  • kuateric (5)
  • bilke (3)
  • ErikNixdorf (2)
  • muellerchr (1)
  • GuanglinDu (1)
  • akaszynski (1)
  • psatke (1)
  • cpgr (1)
  • jbathmann (1)
  • Scinopode (1)
  • garibay-j (1)
Pull Request Authors
  • joergbuchwald (47)
  • dominik-kern (5)
  • Scinopode (4)
  • bilke (4)
  • M-Jaeschke (2)
  • oliverpetschick (2)
  • wenqing (2)
  • nagelt (1)
  • TomFischer (1)
  • Eqrisi (1)
  • endJunction (1)
  • TobiasMeisel (1)
Top Labels
Issue Labels
enhancement (1)
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • pypi 215 last-month
  • Total dependent packages: 1
  • Total dependent repositories: 1
  • Total versions: 14
  • Total maintainers: 3
pypi.org: ogs6py
  • Versions: 14
  • Dependent Packages: 1
  • Dependent Repositories: 1
  • Downloads: 215 Last month
Rankings
Dependent packages count: 4.8%
Forks count: 8.5%
Downloads: 10.6%
Average: 12.2%
Stargazers count: 15.6%
Dependent repos count: 21.6%
Last synced: 6 months ago

Dependencies

setup.py pypi
  • lxml *
.github/workflows/draft-pdf.yml actions
  • actions/checkout v2 composite
  • actions/upload-artifact v1 composite
  • openjournals/openjournals-draft-action master composite
.github/workflows/pylint.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v1 composite
.github/workflows/python-package.yml actions
  • actions/checkout v2 composite
  • actions/setup-python v2 composite
  • codecov/codecov-action v1 composite