Embedded Scripting¶
With embedded scripting, the power and diversity of Python is placed at your disposal within JCMsuite
’s input files.
The JCMsuite
input structure remains unchanged:
All .jcm
input files are still placed in a project directory.
As an extension it is allowed to declare placeholders (keys), and to embed Python code within the .jcm
files.
The so enriched input files have the extension .jcmt
or .jcmpt
(‘t’ stand for template)
to distinguish them from the plain .jcm
files.
When running the project with the solver wrapper solve.py, it is necessary to pass the parameter values for all used keys:
keys = {
'radius': 0.3e-6,
'lambda_0': 1.55e-6
}
results = jcmwave.solve('project.jcmp', keys=keys)
In this example it is assumed that placeholders radius
and lambda_0
are used in the .jcmt
input files. The values to these parameters are passed as a Python dictionary, here called keys
. The computed data are returned in the list results
. The following section Tutorial is a step-by-step introduction which demonstrates the usage of embedded scripting within the .jcmt
files.