Skip to main content
  • UC Berkeley
  • College of Letters & Science
Berkeley University of California

URAP

Project Descriptions
Fall 2026

URAP Home Project Listings Application Contact

Building a New CAD Import Tool for MEGAlib with AI-Assisted Software Development

Andreas Zoglauer, Staff Researcher  
Space Sciences Laboratory  

Applications for Fall 2026 are closed for this project.

MEGAlib is a toolkit designed to calibrate, simulate, reconstruct, and analyze data from gamma-ray detectors. It is widely used in astrophysics, solar physics, planetary science, nuclear security applications, and medical imaging, and it is the main data-analysis toolkit of NASA's upcoming COSI space mission.

Every MEGAlib simulation and analysis starts from a mass model: a description of all volumes, their positions and rotations, their materials, and which of them are detectors. Most groups build this model by hand in MEGAlib's geometry language. This takes weeks to months and is always a simplification of the CAD model from which the instrument was actually built. An existing alternative converts CAD models via a voxel geometry, but it is time consuming to set up, limited in accuracy by the voxel size, and slow to simulate.

This project will write a new CAD import tool for MEGAlib. It reads engineering CAD models (STEP, STL, PLY, OBJ, GDML) and produces a mass model which can be used directly for simulations and analysis. The tool will be written with AI coding assistants (Claude Code, Codex, and similar agentic tools) as the primary implementation engine. The students write the specifications, drive the agents, and verify the result.

The deliverables are the tool as part of an official MEGAlib release, a validated CAD imported mass model of an existing measurement setup (COSI STTC), an open benchmark suite, and a short software paper (JOSS or SoftwareX) with the students as co-authors. The paper rests on the measurements, not on the use of AI: the simplification policy and the errors it induces, the fraction of an instrument which can be recovered as analytic solids, the comparison of the imported mass model against COSI calibration data, and the comparison of the three routes to a mass model.

Day-to-day supervisor for this project is Dr. Andreas Zoglauer, the lead developer of MEGAlib and the COSI Science Data & Operations Lead.

Role: We expect to build a team of three students, who will do the implementation, testing, and validation. The team meets weekly for one hour with the advisor via Zoom, and we expect the team to also meet among themselves. This is a roughly two-semester effort, so we prefer students who want to stay for more than one semester. The most successful students will be offered to continue over the summer.

The tasks will be distributed across the team:

(1) Import and geometry translation: Read the CAD assembly tree (via OpenCASCADE/FreeCAD for STEP) and translate it into MEGAlib's geometry description - volume hierarchy, placements, rotations, units, and naming.

(2) Mesh repair and simplification: Detect and repair open surfaces, non-manifold edges, flipped normals, and self-intersections. Decimate the meshes according to their relevance for the physics - the acceptable error on a volume depends on its material, its thickness in radiation lengths, and its distance to the detectors. Quantify the induced error both geometrically (volume, mass, Hausdorff distance) and in the simulated observables.

(3) Recovery of analytic solids: Detect parts which are boxes, cylinders, cones, or spheres and write them as MEGAlib's native volumes instead of triangle meshes. These are exact instead of faceted, and much faster in Geant4. Measure how much of a real instrument can be recovered this way, and what it gains in accuracy and runtime.

(4) Materials and detector description: Map CAD material names to MEGAlib's material database, and add what a CAD model does not contain - energy resolutions, thresholds, trigger criteria, and which volumes are detectors.

(5) Verification, validation, and benchmarking:
- Compare masses and volumes against the CAD model, and check automatically for overlaps and gaps.
- Simulate COSI calibrations with the imported mass model and compare against the measured calibration data: line positions and widths, peak-to-Compton ratios, count rates, and the event distribution over the detectors.
- Compare the three routes to a mass model - built by hand, converted via the voxel approach, and converted with the new tool - on the same set of geometries: accuracy against CAD and against measurement, simulation runtime and memory, and setup effort. The test geometries will be released as a benchmark suite.

(6) Documentation and release: Write the tutorials, examples, and unit tests which go with an official MEGAlib release.

Working with AI means the following here: Write the specification first, use the agents to implement, refactor, generate tests, and review code - but you are responsible for the result, and every merged line has to be code you can explain in the weekly meeting. We keep a log of what the agents did well and where they failed, and summarize it at the end of the project.

Learning outcomes:
(1) AI-assisted software engineering: specifications, agentic coding workflows, test generation, code review, and verification of AI output.
(2) How gamma-ray detectors and telescopes are described, simulated, and modeled.
(3) Computational geometry: meshes, tessellation, repair, decimation, shape recognition, and coordinate transformations.
(4) Monte Carlo simulations with Geant4/MEGAlib, and the statistical comparison of simulated and measured data.
(5) Benchmark design: choosing the metrics and controlling the variables.
(6) Open-source development: issues, branches, pull requests, unit tests, documentation, and release.
(7) Scientific writing, as co-author of the software paper.

Qualifications: The following qualifications apply to seniors; consider them relaxed for first- and second-year students. Desired qualifications are: Interest in physics, astrophysics, or scientific computing; proficiency in Python 3 and/or C++; familiarity with git and GitHub; familiarity with the Linux/Unix environment, bash, and remote code execution via ssh; willingness to work with AI coding agents in a disciplined, verify-everything way; basic statistical understanding for comparing distributions; great organization and communication skills; punctuality and reliability; talent for multitasking and balancing this project with your normal classes. Helpful but not required: experience with CAD software, 3D meshes, computational geometry, Geant4, or Monte Carlo simulations.

In your application, please clearly indicate the following:
(1) Why you have applied for this position, and what interests you about writing scientific software with AI assistance
(2) Your previous experience with Python and/or C++
(3) Your previous experience with git and GitHub, especially branches, pull requests, and code review
(4) Your previous experience with Linux/Unix, bash, and remote code execution via ssh
(5) Your previous experience with AI coding assistants (e.g. Claude Code, Codex, Cursor, Copilot), and where you found their limits - no experience is fine
(6) Any experience with CAD software (FreeCAD, SolidWorks, Fusion 360, OnShape, ...), 3D meshes, or computational geometry
(7) How many hours per week you can spend on the project
(8) Whether you would be interested in working more than one semester on the project

We look forward to hearing from you!

Hours: 9-11 hrs

Off-Campus Research Site: We will predominantly meet and communicate via Zoom, Slack, and email. Weekly meetings can alternatively happen at UC Berkeley's Space Sciences Laboratory - please take the free hill shuttle from the Hearst mining circle to the top of the hill, SSL is the last stop (~10 min bus ride). We expect the team to meet once per week in person among themselves on campus to work on the project.

Related website: https://github.com/zoglauer/megalib
Related website: http://cosi.ssl.berkeley.edu

 Engineering, Design & Technologies   Mathematical and Physical Sciences   Digital Humanities and Data Science

Return to Project List

Office of Undergraduate Interdisciplinary Studies, Undergraduate Division
College of Letters & Science, University of California, Berkeley
Accessibility   Nondiscrimination   Privacy Policy