Skip to content

Instantly share code, notes, and snippets.

@anderson2981
Created May 2, 2024 22:47
Show Gist options
  • Save anderson2981/0cc6f47e0b034caef7c76853e07a6b00 to your computer and use it in GitHub Desktop.
Save anderson2981/0cc6f47e0b034caef7c76853e07a6b00 to your computer and use it in GitHub Desktop.
from mirgecom.mpi import mpi_entry_point
from mirgecom.array_context import initialize_actx, actx_class_is_profiling
from mirgecom.array_context import get_reasonable_array_context_class
@mpi_entry_point
def main(actx_class):
from mpi4py import MPI
comm = MPI.COMM_WORLD
actx = initialize_actx(actx_class, comm=comm,
use_axis_tag_inference_fallback=True,
use_einsum_inference_fallback=True)
def test_function(temperature):
return actx.np.where(actx.np.greater(temperature, 1000.),
2000., actx.np.where(actx.np.greater(temperature, 500.),
750., actx.np.where(actx.np.greater(temperature, 50.), 250.,
25)))
def test_function2(temperature):
return actx.np.where(actx.np.greater(temperature, 6000.0), 15.857914857900802 + -8484.010667579607 / temperature, actx.np.where(actx.np.greater(temperature, 1000.0), 6.21785087461938 + 0.00334301651978085*temperature + -5.984523426438233e-07*temperature**2 + 5.47163492659835e-11*temperature**3 + -2.02441466271074e-15*temperature**4 + 3102.94429958825 / temperature, actx.np.where(actx.np.greater(temperature, 50.0), 3.73312012902641 + -0.001125805440573445*temperature + 7.8480817078594e-06*temperature**2 + -3.427121040364425e-09*temperature**3 + 5089.77593 / temperature, 3.6776866372578287 + 5090.692681693975 / temperature)))
print(f"{test_function(25.)}")
print(f"{test_function(75.)}")
print(f"{test_function(525.)}")
print(f"{test_function(1005.)}")
print(f"{test_function(1820.)}")
import numpy as np
temp = np.float64(25.)
print(f"{test_function(temp)}")
actx_class = get_reasonable_array_context_class(
lazy=False, distributed=True, profiling=False, numpy=False)
main(actx_class)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment