Divergence And Curl — Control Systems/Symbolic
Control_Systems/Symbolic/Divergence_And_Curl · 1 input / 1 output port(s) at insert · exports to Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text
Description#
The block's own DESCRIPTION_HTML, rendered verbatim — the same text the config dialog's info panel and the library navigator show. Fix a wrong sentence in the block's .cpp (R-D9), never here.
Divergence and Curl
Control Systems / Symbolic
The divergence or the curl of a vector field, evaluated at the input.
The field is written as one expression per component, [F1; F2; F3], over the
declared variables, and Operation chooses which is computed:
- Divergence – ∇·F = Σk ∂Fk/∂xk, a scalar. The field must have one component per variable.
- Curl – ∇×F, the column [∂F₃/∂y − ∂F₂/∂z; ∂F₁/∂z − ∂F₃/∂x; ∂F₂/∂x − ∂F₁/∂y]. Defined in three dimensions only, so the field must have exactly three components over exactly three variables.
These are MATLAB's divergence(F, v) and curl(F, v). Both
derivatives are taken symbolically, once, when the configuration loads.
Ports
- x – the variables, a vector of n entries (a column [n,1] or a row [1,n]) where n is the number of names in Variables: entry k is the k-th name. A Mux in front builds it from scalar signals.
- y – [1,1] in Divergence, the scalar ∇·F; [3,1] in Curl, the column ∇×F.
Parameters
- Expression – the expression, in MATLAB syntax over the names in
Variables: numbers,
pi,+ - * / ^, parentheses and the functionssin cos tan sec csc cot asin acos atan acot sinh cosh tanh asinh acosh atanh exp log log2 log10 sqrt. A matrix is written[f1; f2], with semicolons between rows and commas between the entries of a row.abs,signandheavisideare refused here, unlike on Symbolic Expression: see Notes. - Variables – the names of the input's entries, in order, separated by
spaces or commas:
x y z. Each is a MATLAB identifier, none may repeat, and none may be a function name orpi,e,i,j,Inf,NaNoreps. At most 12. - Operation – which is computed. Two options, and they change the
arithmetic and the output size, not merely a constant:
- Divergence – the scalar Σ ∂Fk/∂xk, for a field of n components over n variables.
- Curl – the three-component column, for a field of exactly three components over exactly three variables.
- Sampling Time (s) – zero or less inherits the solver's rate; a positive value runs the block at that period.
Code export
All ten targets: Python, MATLAB, Java, Rust, C,
C++, VHDL, Verilog, SystemVerilog and PLC Structured
Text. The calculus is done once, at configuration load; what each target carries is
the RESULT, printed as one inline expression per entry with its constants folded to 17
significant digits, so a generated core differentiates nothing and has no parameter to
tune. Where a target lacks a function it gets the identity – Java has no inverse
hyperbolic functions and PLC Structured Text no hyperbolic functions at all, so those are
written through log, exp and sqrt. The three
HDL targets are simulation-only real arithmetic, quantized to
Q16.16 only at the ports: a derivative of a transcendental expression is not a fixed-point
datapath.
Simulink bridge
None (Support::None). divergence / curl is a Symbolic Math Toolbox
function, and that toolbox ships no Simulink library at all, so there is no library path a
diagram could name; the bridge reports this block rather than dropping it, and it
therefore has no parity testbench. Code export verification covers it across all
ten languages. No configuration crosses, including "Sampling Time (s)".
Notes
- Curl is three-dimensional and divergence is not. A field of two or four components has a divergence and no curl; the block refuses Curl there by name rather than padding the field.
abs,signandheavisideare refused in the expression. The symbolic engine answersdiff(abs(x))only under an assumption that x is real – console state a block may not depend on – and the derivative ofsignorheavisideis an impulse no sample can carry. Symbolic Expression accepts all three, because it differentiates nothing.- Algebraic, with no state: the output depends only on the current input.
- The calculus is the console's own symbolic engine's (the engine behind
diffandjacobianon the command line), over exact rational arithmetic; constants are folded to doubles only after it. - Size limits are on the generated code: 144 entries, 4000 operations per entry. An expression whose derivatives grow past that is refused with that reason rather than truncated.
- No state space: the map is nonlinear in general, so model reduction correctly declines the block.
Code facts#
| Fact | Value |
|---|---|
| registered type | Control_Systems/Symbolic/Divergence_And_Curl |
| family | Control_Systems/Symbolic |
| solver environment class | ICoreBlock_0_Control_Systems_1_Symbolic_2_Divergence_And_Curl |
| source | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Divergence_And_Curl/ICoreBlock_0_Control_Systems_1_Symbolic_2_Divergence_And_Curl.cpp |
| header | src/ICoreBlocks/ICoreBlockLibrary/Blocks/Control_Systems/Symbolic/Divergence_And_Curl/ICoreBlock_0_Control_Systems_1_Symbolic_2_Divergence_And_Curl.h |
| default size on canvas | 140 × 70 px |
| ports at insert | 1 in, 1 out |
| code generators implemented | Python, MATLAB, Java, Rust, C, C++, VHDL, Verilog, SystemVerilog, PLC Structured Text |
Ports#
| # | Direction | Signal type | Description label |
|---|---|---|---|
| 1 | in | ICoreDouble | x |
| 2 | out | ICoreDouble | y |
Ports the constructor creates. A block whose port list changes with its configuration adds or removes ports at load time; the count above is the one a freshly inserted block has.
Configuration variables#
| Config variable | Default | Simulink parameter |
|---|---|---|
Expression | [x^2*y; sin(y*z); exp(x)*z] | — |
Variables | x y z | — |
Operation | Divergence%~%Curl~~Divergence | — |
Every block also carries Sampling Time (s) from ICoreBlockSolverEnvironment: zero or less inherits the solver's rate, a positive value runs the block at that period.
Simulink bridge#
| support | Support::None |
| Simulink path | — |
| port-count rule | PortsParam::None |
SampleTime parameter | yes |
Caveat (shown to the user): divergence / curl is a Symbolic Math Toolbox function, and that toolbox ships no Simulink library at all, so there is no library path a diagram could name; the block is reported rather than dropped when a model crosses
Catalog contract: src/ICoreBlocks/ICoreCoder/ICoreCommandSystem/SimulinkBridge/ICoreSimulinkBlockCatalog.h
Description vs code#
The lists agree. check_block_descriptions.py finds no disagreement between the description's Ports, Parameters, Code export and Simulink bridge lists and the code's.
The verdict above is
tools/docs/check_block_descriptions.py(P7.1), which compares LISTS. It cannot read a sentence: "stateless" on a block with a state, an initial-value semantic the recursion does not implement, a "not synthesizable" caveat the HDL banner contradicts. That is the agent audit (P7.3) on BLOCK_DESCRIPTION_AUDIT.md, and this tool's green is not a substitute for one.
File banner (developer view)#
The top comment of the block's .cpp — the maths, the realization and the export strategy, addressed to whoever changes it. It must not contradict the description above (P7.5).
Divergence and Curl -- divergence / curl on an expression compiled at config load Divergence: div F = sum_k dF_k / dx_k (a scalar, any n) Curl: curl F = [dF3/dy - dF2/dz; dF1/dz - dF3/dx; dF2/dx - dF1/dy] (3-D only)
One block with a MODE, because the two are the same reading of the same object: a vector field written as an expression per component, differentiated once at configuration load.
The reading, the sizing contract, compute_h and all ten generators are ICoreSymbolicBlockBase's; the calculus is the console's symbolic engine's, reached through ICoreSymbolicProgram. This file is what is genuinely this block's: its operation, its ports, its configs, its description, its icon and its Simulink entry.
VERIFIED OUTSIDE ICORE, because code-export verification compares the block with itself: the block's own C++ evaluation of its rig configuration was compared with MATLAB R2026a's divergence / curl on the same expression at the same points: max |difference| 1.67e-16 for divergence and 2.22e-16 for curl, which is rounding on the last bit rather than a tolerance.
Sample results#
Plotted: vector — Sine Wave, [3,1]: amplitudes 1/2/3 at 2 rad/s (tried only because every scalar stimulus was refused)
Category dynamic · sample time 0.1 · 60 steps · commit 83b4036dc8d5efdf28a47c36be1e27203065c75b · produced by docsSample --out <folder> --blocks Symbolic_Expression Symbolic_Derivative Gradient Jacobian Hessian Divergence_And_Curl Laplacian Taylor_Approximation Linear_Program LTI_System Wind_Turbulence_Model --steps 60 · data docs/generated/samples/Control_Systems__Symbolic__Divergence_And_Curl.json · the SVG is generated from those numbers by tools/docs/plot_svg.py, so it is a run and not a drawing (R-D10).