Inspect A Failed Solve
Run this straight-line script with an installed jcmsuite package, a configured
JCMsuite runtime, and a solver license:
python demos/documentation_tutorials/failure_logs/single.py
The material template substitutes intentional_solver_error where a numeric
permittivity is required. This deliberately causes a solver input error after
template rendering. The script prints the diagnostics instead of returning a result.
"""Print diagnostics from a deliberately failed ordinary solve."""
import jcmsuite
from jcmsuite.exceptions import SolveExecutionError, SourceMappingError
try:
jcmsuite.solve(
"project.jcmp",
keys={"permittivity": "intentional_solver_error"},
temporary=True,
)
except SolveExecutionError as error:
print("Backend:", error.backend, "Exit code:", error.exit_code)
print(error.log)
except SourceMappingError as error:
print(error)
if isinstance(error.__cause__, SolveExecutionError):
print(error.__cause__.log)
else:
raise
SolveExecutionError exposes
diagnostic text in log, together with backend and exit_code.
A source-mapped input error can instead raise
SourceMappingError with the
execution error as its cause. The script handles both cases, but re-raises a
mapping error that has no execution-error cause.
A successful solve returns a result whose log is a
SolveExecutionLog or None.
That object has separate stdout and stderr attributes; it is not the string
stored on a raised execution error.
The mixed-batch tutorial shows how to retain both successful entries and failures.
Project Files
project.jcmp
Project {
InfoLevel = 3
Electromagnetics {
TimeHarmonic {
Scattering {
FieldComponents = Electric
Accuracy {
FiniteElementDegree = 3
Refinement {
MaxNumberSteps = 0
PreRefinements = 0
}
}
}
}
}
}
materials.jcmt
Material {
Name = "Vacuum"
DomainId = 1
RelPermittivity = 1.0
}
Material {
Name = "Rod"
DomainId = 2
RelPermittivity = %(permittivity)s
}
layout.jcm
Layout2D {
UnitOfLength = 1e-6
MeshOptions {
MaximumSideLength = 0.1
}
Objects {
Parallelogram {
Name = "ComputationalDomain"
DomainId = 1
Priority = ComputationalDomain
Width = 4
Height = 4
Boundary {
Class = Transparent
}
}
Circle {
Name = "Rod"
DomainId = 2
Priority = 1
Radius = 0.3
RefineAll = 4
}
}
}
sources.jcm
SourceBag {
Source {
ElectricFieldStrength {
PlaneWave {
K = [1.14239732857811e7 0.0 0.0]
Amplitude = [0 0 1]
}
}
}
}