Skip to content

Commit

Permalink
Merge pull request #78 from UM-Bridge/CI-fix
Browse files Browse the repository at this point in the history
CI fixes for gs2 and achlys
  • Loading branch information
chun9l authored May 23, 2024
2 parents b42aa40 + 614d534 commit 4fb0515
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark-achlys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
-
name: Validate
run: |
docker run --network=host -e model_host=http://localhost:4243 linusseelinger/testing-protocol-conformity-current:latest
docker run --network=host -e input_value="[0.8,1.0,1.3,9e-4,9e-4]" -e model_host=http://localhost:4243 linusseelinger/testing-protocol-conformity-current:latest
2 changes: 1 addition & 1 deletion .github/workflows/model-achlys.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ jobs:
-
name: Validate protocol
run: |
docker run --network=host -e model_host=http://localhost:4242 linusseelinger/testing-protocol-conformity-current:latest
docker run --network=host -e input_value="[0.8,1.0,1.3,9e-4,9e-4]" -e model_host=http://localhost:4242 linusseelinger/testing-protocol-conformity-current:latest
2 changes: 1 addition & 1 deletion .github/workflows/model-gs2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ jobs:
-
name: Validate
run: |
docker run --network=host -e model_host=http://localhost:4242 linusseelinger/testing-protocol-conformity-current:latest
docker run --network=host -m 4g -e input_value="[4.98536245337014,0.011195269013375201]" -e model_host=http://localhost:4242 linusseelinger/testing-protocol-conformity-current:latest
8 changes: 2 additions & 6 deletions benchmarks/achlys/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,5 @@ FROM linusseelinger/model-achlys

COPY . /benchmark-server

RUN apt update && \
DEBIAN_FRONTEND="noninteractive" apt install -y python3-pip python3-scipy

RUN pip3 install umbridge

CMD /server/server & python3 /benchmark-server/benchmark-server.py
CMD . venv/bin/activate && python3 /server.py & \
. venv/bin/activate && python3 /benchmark-server/benchmark-server.py
2 changes: 1 addition & 1 deletion benchmarks/achlys/benchmark-server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import umbridge

import numpy
import numpy as np
import scipy.stats as stats

from scipy.interpolate import interp1d
Expand Down
2 changes: 1 addition & 1 deletion models/gs2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ None |

## Source code

[Model sources here.](https://github.com/UM-Bridge/benchmarks/tree/gs2/models/gs2)
[Model sources here.](https://github.com/UM-Bridge/benchmarks/tree/main/models/gs2)

## Description
GS2 is developed to study low frequency turbulence in magnetised plasma. In this benchmark, it solves the gyrokinetic Vlasov-Maxwell system of equations that are widely adopted to describe the turbulent component of the electromagnetic fields and particle distribution functions of the species present in a plasma. The problem is five-dimensional and takes the form
Expand Down
31 changes: 14 additions & 17 deletions models/gs2/server.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import umbridge
import json
import os
import csv
from pyrokinetics import Pyro
from datetime import datetime
from fileinput import FileInput



Expand All @@ -20,25 +16,26 @@ def get_output_sizes(self, config):

def __call__(self, parameters, config):
input_file = "fast.in" # Select input file
pyro = Pyro(gk_file=input_file, gk_code="GS2")
os.system("mkdir -p restart") # GS2 needs this folder otherwise will fail
with FileInput(files=input_file, inplace=True) as file:
checkpoint = 0
for line in file:
if "&species_parameters_3" in line:
checkpoint += 1
if "tprim" in line and checkpoint == 1:
line = f" tprim = {parameters[0][0]}"
if "vnewk" in line and checkpoint == 1:
line = f" vnewk = {parameters[0][1]}"
print(line.rstrip()) # FileInput redirects stdout to file
if True: # Added to make it fast! Remove for production runs!
pyro.gs2_input["knobs"]["nstep"] = 50
pyro.gs2_input["theta_grid_parameters"]["ntheta"] = 10
pyro.gs2_input["theta_grid_parameters"]["nperiod"] = 2
pyro.gs2_input["le_grids_knobs"]["ngauss"] = 5
pyro.gs2_input["le_grids_knobs"]["negrid"] = 2

pyro.gs2_input["species_parameters_3"]["tprim"] = float(parameters[0][0])
pyro.gs2_input["species_parameters_3"]["vnewk"] = float(parameters[0][1])
pyro.gk_input.data = pyro.gs2_input
pyro.gk_input.write(input_file)

# Run the model
mpirank = config.get("ranks", 4)
os.system(f"mpirun --allow-run-as-root -n {mpirank} /usr/gs2/bin/gs2 {input_file}") # --allow-run-as-root to suppress OMPI error, not reccomended when running outside of docker!

# Read results using Pyrokinetics package and print output
gs2_input = input_file
pyro = Pyro(gk_file=gs2_input, gk_code="GS2")
# Read results and print output
pyro = Pyro(gk_file=input_file, gk_code="GS2")
pyro.load_gk_output()
data = pyro.gk_output
print(data)
Expand Down

0 comments on commit 4fb0515

Please sign in to comment.