Examples

Release · v2.2.0MarkdownLLM docs
이 페이지의 내용

Choose by what you want to see

Open versus reflecting boundaries for an electric pulse

Follow a field

Begin with a pulse, a boundary and a dielectric interface. Actual time-domain snapshots make a useful first experiment.

Watch and run

New to the API? Start with the first runnable model and the visual manual.

Run from a source checkout

The scripts below ship in a source checkout under examples/. Run them in order: each one teaches one decision a real design needs. The last column says which ports and boundaries the script builds, so you can find the one closest to your structure. Paths in the tables are relative to examples/.

Run a script from the repository root, for example:

Terminal window
python examples/quickstart/hello_world.py

Most finish in seconds to a few minutes on a CPU. Steps 4 and 10 take tens of minutes.

The machine-readable index lists builders and output files.

The learning path

#ScriptWhat it teachesPorts and boundaries
1quickstart/hello_world.pyinstall check: the smallest Simulation → run → probe loopPEC box; point source and one probe
2tutorials/boundary_spec_demo.pychoosing boundaries: CPML for open problems, PEC for closed ones, PMC symmetry, periodic cells; and declaring metal inside the domain as a sheet, a volume or a wireBoundarySpec per axis and face; point source and probe
3tutorials/slab_rt_flux_monitor.pyreflection and transmission spectra done right: flux monitors plus a reference run, and why a probe FFT misleadsCPML; plane wave; two flux monitors
4tutorials/nonuniform_patch_demo.pya graded z mesh for a thin substrate, and checking where the layers actually landed after grading shifts themCPML; dz_profile; point source and probe
5tutorials/materials_and_dispersion.pylibrary and custom materials, why a lossless resonator’s Q is meaningless, Debye and Lorentz polesCPML; point source and probe
6tutorials/run_control_and_fields.pyn_steps vs num_periods vs until_decay, the truncation warning, reading field slicesCPML; point source and probe
7tutorials/ports_and_sparams_101.pywhich port fits which structure, S11 basics, and the bins the extractor marks unreliablelumped, microstrip, waveguide and coaxial ports, and add_lumped_rlc; CPML and PEC
8tutorials/resonance_harminv.pyring-down resonance extraction, picking a mode by its physics rather than its amplitude, simulation time vs frequency resolutionclosed PEC cavity; point source and probe; no port, which would load the cavity
9tutorials/antenna_farfield_pattern.pyplacing a far-field box at least half a wavelength from the radiator, and checking directivity against the textbook short dipole; writes output/short_dipole_e_plane.csvCPML; add_ntff_box; point source
10tutorials/patch_antenna_demo.pya real antenna end to end: a stack registered to the built mesh, copper as sheets, the radiating mode picked by its far field, a settling check and an error budget against openEMSCPML; graded dz_profile; add_ntff_box; point source and probe
11tutorials/rcs_scattering.pyradar cross section with subtract_incident_reference=TrueCPML; plane wave and an empty reference run
12inverse_design/differentiable_s11_design.pyjax.grad through compute_waveguide_s_matrix, checked against central finite differencesCPML; two WR-90 waveguide ports
13tutorials/artifact_report_demo.pyexporting a shareable scene, mesh and preflight metadata, a report and a manifestPEC box; lumped port and probe; no FDTD run

Six of these scripts are run end to end by a test that checks their output: materials_and_dispersion, antenna_farfield_pattern, ports_and_sparams_101, run_control_and_fields, rcs_scattering and resonance_harminv. Some of these tests bound physics, such as the dipole’s directivity, a cavity mode’s error and the backscatter ratio; others check the advisories and that values are finite. hello_world runs end to end with a check that its output is finite. Every other script is checked only for what it builds, not for what it prints, so a “checked against” in the table is what the script reports, not a test result.

Read the preflight output of every script. Its warnings name the conditions that would make a result wrong: a lossless resonator, a layer that landed on the wrong cells, a run cut off before the field rang down.

Other scripts

ScriptWhat it showsPorts and boundaries
tutorials/cad_mesh_import_demo.pyimporting an STL part with MeshShape and a mm → m scale. Needs the rfx-fdtd[cad] extra and exits cleanly without it; exposes build_simulation()CPML; point source
inverse_design/multilayer_ar_coating.pya three-layer anti-reflection coating optimized through forward(eps_override=...), checked against the transfer-matrix optimumCPML on x, periodic y and z; point source and two probes
inverse_design/field_observable_shielding.pypooling two DFT plane probes into one worst-case leakage objective with field_softmaxCPML; plane wave; two DFT planes
inverse_design/progressive_demo.pyprogressive_optimize running a design over increasing mesh resolutions. A minimal API demo with a trivial optimumCPML; point source and probe
config/microstrip_thru.yamlthe YAML front end, run with rfx run, rfx plot and rfx export-geometryCPML; two 50 Ω wire ports; ground and trace as sheets

Validation scripts are not tutorials

The comparisons in tests/crossval/ check rfx against another solver. They assume you already understand the setup and they judge numbers, so they teach little about building a model. See Benchmarks for what they show.

Back to top