Skip to content

Adding supporting code for blog post #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

mmarkows17
Copy link
Collaborator

Supporting code for the blog post Physics-Informed Machine Learning: Methods and Implementation

@@ -0,0 +1,97 @@
classdef spectralConvolution1dLayer < nnet.layer.Layer ...
Copy link
Collaborator

@bwdGitHub bwdGitHub Jun 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expect we could use the same version here and in the 1d FNO example - maybe we should consider a directory of shared tools for the examples.

That's something we'll have to look into in future I think, not something to try deal with in this PR.

Copy link
Member

@conordaly0 conordaly0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome Mae!

I still need to review the other MLX files, but I wanted to post my initial comments first.

Copy link
Member

@conordaly0 conordaly0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great Mae!

Copy link
Collaborator

@bwdGitHub bwdGitHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there might be some open conversations still, but this is looking good to me.

I forget if I said elsewhere, but just in case, we should "Squash and merge" when merging this. That seems to be the default when I look, probably because we've used that elsewhere. My understanding is that will prevent those large data files, hidden in the historic commits, won't end up in the main branch since a later commit deletes them, and squashing those together will remove the files from the git history.

2. **Fourier Neural Operator**: learns the solution operator that maps input functions (e.g. forcing function) to the solution of a differential equation, utilizing Fourier transforms to parameterize the integral kernel and efficiently capture global dependencies.

## Setup
Open the project file physics-informed-ml-blog-supporting-code.prj to correctly set the path.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really like using a project. I think the path management is simple enough, when I opened the project the only path I noticed added was the /data, which we can probably reference with relative paths in most examples load(fullfile("..","data","datafile.mat"))

The project adds a bunch of .xml files without human readable names, and it's not obvious what their purpose is. That makes it harder to understand the state of local copies of the repo and harder to review changes.

I think we shouldn't use a project and should remove all the resources and metadata that it adds.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't add binary files to the repo where possible, particularly data files that are "large" - MB is large for git, e.g. this page says 50MB will give you warnings.

These files add a noticeable impact on the speed of pulling the repo, and it's not possible to review changes to these files as a diff (arguably the same is true of .mlx. At least visdiff locally could let me see a human readable diff).

I can message on Teams about how I'm planning to add some data separately.

@@ -1,13 +1,13 @@
# Physics Informed Machine Learning Methods and Implementation supporting code
This repository provides examples demonstrating a variety of Physics-Informed Machine Learning (PhiML) techniques, applied to a simple pendulum system. The examples provided here are discussed in detail in the accompanying blog post "Physics-Informed Machine Learning: Methods and Implementation".
This collection provides examples demonstrating a variety of Physics-Informed Machine Learning (PhiML) techniques, applied to a simple pendulum system. The examples provided here are discussed in detail in the accompanying blog post "Physics-Informed Machine Learning: Methods and Implementation".

![hippo](https://www.mathworks.com/help/examples/symbolic/win64/SimulateThePhysicsOfAPendulumsPeriodicSwingExample_10.gif)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like I'm missnig something, why's the alt text "hippo" 😅?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to above, it'd be nice if we can change the code so that this blank plot isn't needed.

**Physics\-Informed Loss**


The physics loss enforces the differential equation by penalizing deviations from the governing pendulum ODE. Functions like [`dllaplacian`](https://www.mathworks.com/help/releases/R2025a/deeplearning/ref/dlarray.dllaplacian.html?searchPort=60735) and [`dljacobian`](https://www.mathworks.com/help/deeplearning/ref/dlarray.dljacobian.html) make it simple to define derivative terms appearing in ordinary and partial differential equations for use in a PINN.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need that "?searchPort" part in the dllaplacian link.

Comment on lines 22 to 23
Created and tested with MATLAB&reg; R2025a
- [Deep Learning Toolbox&trade;](https://www.mathworks.com/products/deep-learning.html)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The generatePendulumData function uses sgolayfilt which needs Signal Processing Toolbox. I guess we won't need that when we get the data on supportfiles.

@@ -76,6 +66,8 @@ for i = 1:numPlots
ylabel("$\theta(t)$",Interpreter='latex')
end
```

![figure_0.png](FNO_README_media/figure_0.png)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice if the alt text here is descriptive, like "Solution Plots" or something. Not sure if we have any control over that for MLX to MD export.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these plots be made such that the y axis labels don't overlap, and the legend isn't blocking the plot?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants