Automatically extract B (magnetic flux density) and H (magnetic field intensity) from QuickField magnetostatic simulations, at multiple points, across multiple parameter sweeps, without clicking through the GUI one point at a time.
When running magnetostatic simulations in QuickField you often need to:
- Read B and H at many measurement points
- Repeat this across multiple solver runs (different mesh densities, permeabilities, current densities, etc.)
- Copy the values into a table for your report
Doing this manually through the QuickField GUI is slow and error prone. This script automates it:
- Connects to a running QuickField instance via COM
- Reads exact B and H at every point you define (same values as the GUI)
- Auto detects when you re-solve and prints updated tables instantly
- Optionally exports to CSV for easy spreadsheet import
One terminal, leave it running, re-solve as many times as you want → all tables printed automatically.
- Windows (QuickField is Windows-only)
- QuickField with COM/ActiveField support (Student, Professional, or Full edition)
- Python 3.8+
# Clone the repo
git clone https://github.com/andrrei509/quickfield-magnetostatics-extractor.git
cd quickfield-magnetostatics-extractor
# Install dependencies
pip install -r requirements.txtOr just install the single dependency directly:
pip install pywin32- Open your problem in QuickField and solve it
- Run the extractor:
python extract_results.py- You'll see a table like this:
========================================================================
Run #1 | 14:32:07 | Mesh: 247 nodes
========================================================================
Pt (X, Y) |B| [T] |H| [A/m]
---- -------------- -------------- --------------
P1 (+4.50,+0.00) 1.234567e-03 982.456123
P2 (+2.75,+0.00) 5.678901e-03 4518.234567
...
Pt Bx [T] By [T] Hx [A/m] Hy [A/m]
---- -------------- -------------- -------------- --------------
P1 1.234000e-03 5.670000e-05 982.345000 45.123000
...
========================================================================
- Change parameters in QuickField (mesh, μᵣ, J, geometry, …), re-solve → new table appears automatically
- Ctrl+C to stop
There are three ways to define where B and H are measured:
python extract_results.py --points "A,1.0,0; B,0,1.0; C,-1.0,0; D,0,-1.0"Format: Label,X,Y separated by semicolons.
Create a file like my_points.json:
{
"points": [
{ "label": "Center", "x": 0.0, "y": 0.0 },
{ "label": "Top", "x": 0.0, "y": 5.0 },
{ "label": "Right", "x": 5.0, "y": 0.0 },
{ "label": "Bottom", "x": 0.0, "y": -5.0 },
{ "label": "Left", "x": -5.0, "y": 0.0 }
]
}Then run:
python extract_results.py --config my_points.jsonSee points_example.json for a complete example.
Modify the DEFAULT_POINTS list near the top of extract_results.py.
Append results from every run to a CSV file:
python extract_results.py --csv results.csvEach re-solve appends new rows with a run number and timestamp, perfect for importing into Excel.
Change how often the script checks for new results (default: 3 seconds):
python extract_results.py --interval 1usage: extract_results [-h] [--points POINTS] [--config CONFIG]
[--csv CSV] [--interval INTERVAL] [--version]
options:
-h, --help show this help message and exit
--points, -p POINTS Semicolon-separated points: "Label,X,Y; Label,X,Y"
--config, -c CONFIG Path to a JSON file with point definitions
--csv CSV Path to CSV file (results appended after each run)
--interval, -i SECS Polling interval in seconds (default: 3)
--version, -V show version and exit
The script uses COM automation (via pywin32) to talk to QuickField's ActiveField API:
QuickField.Application
└─ ActiveProblem
└─ Result
└─ GetLocalValues(point)
├─ .Grad → B vector (Bx, By) in Tesla
└─ .KGrad → H vector (Hx, Hy) in A/m
Grad= gradient of the magnetic vector potential = B (flux density)KGrad= reluctivity × gradient = H (field intensity)
These are the exact same values displayed in QuickField's postprocessor, no manual calculations, no approximations.
The script uses early binding (win32com.client.gencache.EnsureDispatch) which generates a Python type library from QuickField's COM interface. This gives proper IntelliSense and reliable property access.
├── extract_results.py # Main script
├── points_example.json # Example point configuration
├── requirements.txt # Python dependencies
├── LICENSE # MIT License
├── .gitignore # Git ignore rules
├── README.md # This file
├── your_file.pbm # Empty QuickField problem (replace with the files QuickField generates)
├── your_file.mod # Empty QuickField model (replace with the files QuickField generates)
├── your_file.res # Empty QuickField results (replace with the files QuickField generates)
└── your_file.dms # Empty QuickField data (replace with the files QuickField generates)
| Problem | Solution |
|---|---|
Cannot connect to QuickField |
Make sure QuickField is running with a problem loaded |
No active problem |
Open a .pbm problem file in QuickField |
Problem not solved yet |
Click Problem → Solve in QuickField |
N/A for a point |
That point is outside the mesh, check your coordinates |
ModuleNotFoundError: win32com |
Run pip install pywin32 |
| COM cache errors | Delete %LOCALAPPDATA%\Temp\gen_py and retry |
Contributions welcome. Some ideas:
- Support for other QuickField problem types (electrostatics, heat transfer, …)
- GUI wrapper (tkinter/PyQt)
- Plotting with matplotlib
- Support for contour/line integrals, not just point values
MIT (use it however you want)
Built for the FEE3 (Fundamentals of Electrical Engineering) labs, but designed to be useful for anyone working with QuickField magnetostatics.