Skip to content

Adding 3D Electrostatics SciML example#21

Open
mmarkows17 wants to merge 1 commit intomatlab-deep-learning:mainfrom
mmarkows17:publish/3D-electrostatics-example
Open

Adding 3D Electrostatics SciML example#21
mmarkows17 wants to merge 1 commit intomatlab-deep-learning:mainfrom
mmarkows17:publish/3D-electrostatics-example

Conversation

@mmarkows17
Copy link
Copy Markdown
Collaborator

Demo which shows how to create neural surrogate models for 3D field prediction directly from geometry/design.

Copy link
Copy Markdown
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!

We need to remember to update the outer repo README as well to reference this example

@@ -0,0 +1,9 @@
function x = edge_to_node_accumulation(x,xe,B)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Here and elsewhere, I'd prefer us to use lower camel case -- e.g. edgeToNodeAccumulation rather than snake case.

Where I spot it in other files I'll just leave a comment saying prefer lower camel case.

@@ -0,0 +1,11 @@
function data = loadAllData(dataRootDir)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like all the M-code files throughout each namespace are missing copyright headers. You should add one to each file.

@@ -0,0 +1,10 @@
function p = initialize_mlp(inputSize,hiddenSize,numLayers)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Prefer lower camel case initializeMLP

@@ -0,0 +1,11 @@
function p = initialize_processor(cfg)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Prefer lower camel case initializeProcessor

@@ -0,0 +1,35 @@
function [X,Xe,B,Y] = minibatch(X,Xe,B,Y,useGpu)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe createMiniBatch?

@@ -0,0 +1,562 @@
%[text] # Rapid Design Exploration for a 3D Electrostatics Problem Using Transolver
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think this script could have a more descriptive name like electrostaticsUsingTransolver.

Comment on lines +266 to +269
XBatch = dlarray(single(paddedInputsTrain(:,:,bIdx)),"CSB");
mBatch = dlarray(single(maskTrain(:,:,bIdx)),"CSB");
VBatch = dlarray(single(paddedTargetsTrain(:,:,bIdx)),"CSB");
EBatch = dlarray(single(paddedEfieldTrain(:,:,bIdx)),"CSB");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The case to single should really be happening outside of the trainnig loop -- so that it is not repeated at every iteration.


[net,avgGrad,avgSqGrad] = adamupdate(net,gradients,avgGrad,avgSqGrad,iteration,lr);

lossHistory(iteration) = double(extractdata(loss));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't think it is necessary to cast to double here?

Comment on lines +372 to +379
if useGpu
V = predict(net,dlarray(gpuArray(normU)),gpuArray(ones(1,size(normU,2))),InputDataFormats=["CS","CS"]);
V = extractdata(V);
V = gather(V);
else
V = predict(net,dlarray(normU),ones(1,size(normU,2)),InputDataFormats=["CS","CS"]);
V = extractdata(V);
end
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd advise using the if branch just to send the data to the GPU. Then the subsequent calls to predict, extract and gather can be combined for both branches.

@@ -0,0 +1,74 @@
# Rapid Design Exploration with Neural PDE Surrogates
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could we generate markdown from one or both of the transolver/meshgraphnet examples and find a way to include it in the repo, either in this readme or separate markdowns? I think it's important for examples to be readable on GitHub without requring someone to clone the repo and open the files in MATLAB just to read what the examples are doing.

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.

2 participants