Submit To A Remote SLURM Queue
This tutorial submits a batch to a remote SLURM queue and then collects the
batch result. The tutorial uses a Queue resource with explicit remote-login,
JCMsuite-installation, and scheduler settings.
Before you run the tutorial, replace every <...> placeholder in run.py.
You must have access to the remote login host, a valid SLURM account and
partition, and a writable remote working directory. The remote host must have
the required JCMsuite installation.
Run the tutorial from the tutorial root:
python execution_runtime/daemon/04_remote_slurm/run.py
Python File
"""Submit a batch through a remote SLURM queue resource."""
import jcmsuite
from jcmsuite.daemon import Queue
# Replace each placeholder with the values for your remote environment.
REMOTE_HOSTS = ["<LOGIN_HOST>", "<COMPUTE_HOST>"]
REMOTE_LOGIN = "<USERNAME>"
REMOTE_JCMROOT = "<REMOTE_JCMROOT>"
REMOTE_WORKING_DIR = "<REMOTE_WORKDIR>"
SLURM_ACCOUNT = "<ACCOUNT>"
SLURM_PARTITION = "<PARTITION>"
daemon = jcmsuite.daemon.handler()
daemon.resources.add(
Queue(
hostname=REMOTE_HOSTS,
login=REMOTE_LOGIN,
jcm_root=REMOTE_JCMROOT,
working_dir=REMOTE_WORKING_DIR,
account=SLURM_ACCOUNT,
partition_name=SLURM_PARTITION,
n_nodes=1,
n_tasks_per_node=1,
n_threads=2,
time_minutes=30,
)
)
with daemon:
batched_results = jcmsuite.solve(
"mie2D.jcmp",
keys=[{"radius": 0.3}, {"radius": 0.4}, {"radius": 0.5}],
temporary=True,
)
print(batched_results.success_indices)
print(batched_results.failure_indices)
Project Files
layout.jcmt
Layout2D {
UnitOfLength = 1e-6
MeshOptions {
MaximumSideLength = 0.1
}
Objects {
# Computational domain
Parallelogram {
Name = "ComputationalDomain"
DomainId = 1
Priority = ComputationalDomain
Width = 4
Height = 4
Boundary {
Class = Transparent
}
}
# Scatterer (rod)
Circle {
Name = "Rod"
DomainId = 2
Priority = 1
Radius = %(radius)e
RefineAll = 4
}
}
}
materials.jcm
# material properties for the surroundings (air)
Material {
DomainId = 1
RelPermittivity = 1.0
RelPermeability = 1.0
}
# material properties the glass rod
Material {
DomainId = 2
RelPermittivity = 2.3104 # 1.52^2
RelPermeability = 1.0
}
mie2D.jcmp
Project {
InfoLevel = 3
Electromagnetics {
TimeHarmonic {
Scattering {
FieldComponents = Electric
Accuracy {
FiniteElementDegree = 3
Refinement {
MaxNumberSteps = 0
PreRefinements = 0
}
}
}
}
}
}
# computes the energy flux of the scattered field into the exterior domain
PostProcess {
FluxIntegration {
FieldBagPath = "./mie2D_results/fieldbag.jcm"
OutputFileName = "./mie2D_results/energyflux_scattered.jcm"
OutputQuantity = ElectromagneticFieldEnergyFlux
InterfaceType = ExteriorDomain
}
}
PostProcess {
FourierTransform {
FieldBagPath = "./mie2D_results/fieldbag.jcm"
OutputFileName = "./mie2D_results/fc.jcm"
NormalDirection = Y
Rotation = X:Z:-Y
Format = JCM
}
}
# exports computed field on cartesian grid
PostProcess {
ExportFields {
FieldBagPath = "./mie2D_results/fieldbag.jcm"
OutputFileName = "./mie2D_results/fieldbag_cartesian.jcm"
Cartesian {
NGridPointsX = 200
NGridPointsY = 200
}
}
}
sources.jcm
SourceBag {
Source {
ElectricFieldStrength {
PlaneWave {
K = [1.14239732857811e7 0.0 0.0]
Amplitude = [0 0 1]
}
}
}
}