CLIENTFortranC++C#Vue
Charged Particle Optics
Electron optics simulation software (CPO2D and CPO3D)
to present, simulation engines, website, admin app and newsletter
Introduction
This case study is a little different as I got to know one of the founders (Prof. Frank Read) personally when walking our dogs.
Frank has an amazing physics background, and although my education in this topic was sorely limited I was very eager to learn more.
Frank and his colleague Nick Bowring started CPO whilst at the University of Manchester to solve 2- and 3-dimensional electrostatic problems with the Boundary Element Method.
My initial help was on modernising the website, which has been through several iterations since.
The software itself is written in C++ and Fortran. Before I started working on the core of the software I had to understand it fully. This involved a legacy health check where the codebase and supporting infrastructure is documented to identify any stale toolchains or dependencies. It’s from this study that the requirement to update to a stable compiler was identified.
I’ve swapped out the physical hardware licensing (dongles) for virtual licensing, activated over the internet.
The software has been updated to support the latest Windows operating systems.
I’ve also reimplemented the application help as the old Windows help system was no longer supported. The help system is now also synchronised and published on the website.
The majority of the work has been on converting both CPO2D (two-dimensional simulations) and CPO3D (three-dimensional simulations) from 32-bit to 64-bit.
CPO2D and CPO3D now have a big list of improvements which are being actively developed.
I’ve pretty much managed everything from the logo design, through software development to invoicing.
I am now a shareholder in the company and continue to work on the software and website.
Safety first
The software has a healthy user base and the output has to be correct in every case. For this reason I built a regression test rig to ensure that the software produces the same results before and after a change.
These tests were fairly limited at first. Since converting to 64-bit the tests have been extended to cover more scenarios and edge cases.
The number of tests now stands at 898 plus 99 end-to-end tests across all applications (website, admin app, CPO2D and CPO3D).
The tests are currently manually run before every release to prevent software being shipped that has regressed in any way.
For example, a slower run time or a different output file would be flagged.
The data for the tests came from the hundreds of excellent test data files included with both 2D and 3D variants.
Legacy Fortran and C++ codebase
The main issue has been that in software terms, the codebase is old and has not kept up to date with modern compilers and toolsets.
This meant compatibility problems with Windows, starting from Vista.
There are about 154,000 lines of Fortran and 126,000 of C and C++ with the largest single file being 21,598 lines.
The 32-bit versions had memory caps of 5,000 elements and could crash with stack overflows on large simulations.
Although I don’t like to blame compilers (it’s very rare that a compiler has a bug), there were some issues with the Fortran compiler that needed to be worked around.
Migrating to 64-bit and .NET 10
The simulation engines have been migrated to 64-bit and the regression tests above ensure they stay correct.
The website has been updated to the latest version of .NET and a new application for managing clients and campaigns has been built. This means the site can now run in a fraction of the resources of a typical Windows host and could be hosted on Linux which improves reliability and lowers costs.
Replacing Mailchimp
The site newsletter was originally managed by Mailchimp but I decided to bring it in-house due to costs and the regular up-selling emails. Both systems ran in parallel for 26 days to ensure no subscribers were lost and that the new system was working correctly.
The replacement uses a paid transactional email provider and we record every consent and suppression in our own database. We also have one-click unsubscribe and can manage audiences and campaigns from the admin app.
Next up
There are a lot of improvements that are currently being worked on.
Speed (multi-processor, GPU, cloud), output formats, visualisations, modernising the codebase, open-sourcing the help, cross-platform support, API and MCP connectors.
You can find the website and software at electronoptics.com.
Have a similar system or challenge?
Contact me to talk through your options.