Skip to content
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

resolves 150: support jupyter notebook in examples #163

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions examples/modules/csm/examples/pendulum2D/pendulum2D.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{
"version": "1",
"author": ["vincentchabannes","prudhomm","lberti","jobinhio"],
"date": "23/09/2022",
"date": "30/11/2022",
"references":[""]
},
"Models":
Expand Down Expand Up @@ -76,7 +76,19 @@
},
"Measures":
{
"VolumeVariation":""
"VolumeVariation":"",
"Statistics":
{
"disp":
{
"type":["min","max","mean"],
"field":"displacement"
},
"von-mises": {
"type": ["min","max","mean"],
"expr": "sqrt(0.5*((solid_stress_P_00-solid_stress_P_11)^2+(solid_stress_P_11-solid_stress_P_22)^2+(solid_stress_P_22-solid_stress_P_11)^2+6*(solid_stress_P_12^2+solid_stress_P_23^2+solid_stress_P_31^2))):solid_stress_P_00:solid_stress_P_11:solid_stress_P_22:solid_stress_P_12:solid_stress_P_23:solid_stress_P_31"
}
}
}
}
}
Expand Down
16 changes: 14 additions & 2 deletions examples/modules/csm/examples/pendulum3D/pendulum3D.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"version": "1",
"author": ["vincentchabannes","prudhomm","lberti","jobinhio"],
"date": "23/09/2022",
"date": "30/11/2022",
"references":[""]
},
"Models":
Expand Down Expand Up @@ -72,7 +72,19 @@
},
"Measures":
{
"VolumeVariation":""
"VolumeVariation":"",
"Statistics":
{
"disp":
{
"type":["min","max","mean"],
"field":"displacement"
},
"von-mises": {
"type": ["min","max","mean"],
"expr": "sqrt(0.5*((solid_stress_P_00-solid_stress_P_11)^2+(solid_stress_P_11-solid_stress_P_22)^2+(solid_stress_P_22-solid_stress_P_11)^2+6*(solid_stress_P_12^2+solid_stress_P_23^2+solid_stress_P_31^2))):solid_stress_P_00:solid_stress_P_11:solid_stress_P_22:solid_stress_P_12:solid_stress_P_23:solid_stress_P_31"
}
}
}
}
}
Expand Down
18 changes: 17 additions & 1 deletion examples/modules/csm/examples/spring/spring.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"version": "1",
"author": ["vincentchabannes","prudhomm","lberti","jobinhio"],
"date": "23/09/2022",
"date": "30/11/2022",
"references":[""]
},
"Models":
Expand Down Expand Up @@ -77,6 +77,22 @@
"Exports":
{
"fields":["displacement","pressure","pid","von-mises-criterion"]
},
"Measures":
{
"Statistics":
{
"disp":
{
"type":["min","max","mean"],
"field":"displacement"
},
"von-mises":
{
"type": ["min","max","mean"],
"expr": "sqrt(0.5*((solid_stress_P_00-solid_stress_P_11)^2+(solid_stress_P_11-solid_stress_P_22)^2+(solid_stress_P_22-solid_stress_P_11)^2+6*(solid_stress_P_12^2+solid_stress_P_23^2+solid_stress_P_31^2))):solid_stress_P_00:solid_stress_P_11:solid_stress_P_22:solid_stress_P_12:solid_stress_P_23:solid_stress_P_31"
}
}
}
}
}
Expand Down
19 changes: 17 additions & 2 deletions examples/modules/csm/examples/suspension/suspension.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{
"version": "1",
"author": ["vincentchabannes","prudhomm","lberti","jobinhio"],
"date": "23/09/2022",
"date": "30/11/2022",
"references":[""]
},
"Models":
Expand Down Expand Up @@ -78,7 +78,22 @@
{
"Exports":
{
"fields":["displacement"]
"fields":["displacement","pid","von-mises-criterion"]
},
"Measures":
{
"Statistics":
{
"disp":
{
"type":["min","max","mean"],
"field":"displacement"
},
"von-mises": {
"type": ["min","max","mean"],
"expr": "sqrt(0.5*((solid_stress_P_00-solid_stress_P_11)^2+(solid_stress_P_11-solid_stress_P_22)^2+(solid_stress_P_22-solid_stress_P_11)^2+6*(solid_stress_P_12^2+solid_stress_P_23^2+solid_stress_P_31^2))):solid_stress_P_00:solid_stress_P_11:solid_stress_P_22:solid_stress_P_12:solid_stress_P_23:solid_stress_P_31"
}
}
}
}
}
Expand Down
18 changes: 17 additions & 1 deletion examples/modules/csm/examples/vierendeel-truss/Plate.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"version": "1",
"author": ["vincentchabannes","prudhomm","lberti","jobinhio"],
"date": "23/09/2022",
"date": "30/11/2022",
"references":[""]
},
"Models":
Expand Down Expand Up @@ -65,6 +65,22 @@
"Exports":
{
"fields":["displacement","von-mises-criterion","tresca-criterion","principal-stresses"]
},
"Measures":
{
"Statistics":
{
"disp":
{
"type":["min","max","mean"],
"field":"displacement"
},
"von-mises":
{
"type": ["min","max","mean"],
"expr": "sqrt(0.5*((solid_stress_P_00-solid_stress_P_11)^2+(solid_stress_P_11-solid_stress_P_22)^2+(solid_stress_P_22-solid_stress_P_11)^2+6*(solid_stress_P_12^2+solid_stress_P_23^2+solid_stress_P_31^2))):solid_stress_P_00:solid_stress_P_11:solid_stress_P_22:solid_stress_P_12:solid_stress_P_23:solid_stress_P_31"
}
}
}
}
// TODO : Currently doesn't work
Expand Down
102 changes: 102 additions & 0 deletions examples/modules/csm/pages/pendulum2D/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,32 @@ mpirun -np 4 feelpp_toolbox_solid --case "github:{repo:toolbox,path:examples/mod

NOTE: The report of the execution of the command above is available xref:pendulum2D/solid-information.adoc[here].

=== Python interface
We start with the {feelpp} environment.

[source,python]
----
from feelpp import *
from feelpp.toolboxes.core import *
from feelpp.toolboxes.solid import *

# create the application
# create a feelppdb subdirectory where the results are stored
app = Environment(['feelpp_toolbox_solid'], opts= toolboxes_options("solid"),config=localRepository(""))
----

Next we download the study configuration and simulate it

[source,python]
----
pendulum2Dcfg=feelpp.download("github:{repo:toolbox,path:examples/modules/csm/examples/pendulum2D/}", worldComm=app.worldCommPtr())[0]
pendulum2Dcfg+='/pendulum2D.cfg'

if os.path.exists(pendulum2Dcfg):
app.setConfigFile(pendulum2Dcfg)
s = solid(dim=2)
----

== Data files

The case data files are available in Github link:{uri-data}/pendulum/[here]
Expand Down Expand Up @@ -106,6 +132,82 @@ The pid helps to see how the mesh was partitioned for parallel processing.
include::example$pendulum2D/pendulum2D.json[tags=exports]
----

[source,python]
----
import pandas as pd
df=pd.DataFrame(meas)
print(df.head())

# prepare for plotting
import plotly.graph_objects as go
----

[%collapsible.result]
.Results
====
----
Paraview files are in /scratch/jupyter/feelppdb/np_1/np_1/solid.exports
Statistics_disp_max Statistics_disp_mean_0 Statistics_disp_mean_1 \
0 0.000000e+00 0.000000 0.000000
1 -3.329553e-07 -0.000003 -0.000242
2 -4.652734e-06 -0.000022 -0.001200
3 1.084905e-05 -0.000097 -0.003076
4 6.733757e-05 -0.000294 -0.005797

Statistics_disp_min Statistics_von-mises_max Statistics_von-mises_mean \
0 0.000000 0.000000e+00 0.000000
1 -0.000245 8.511694e+04 735.543752
2 -0.001221 3.746634e+05 4510.381468
3 -0.003151 8.814162e+05 13740.732376
4 -0.005967 1.580571e+06 28332.568714

Statistics_von-mises_min time
0 0.000000 0.00
1 0.552184 0.01
2 3.061166 0.02
3 17.603125 0.03
4 92.414719 0.04
----
====

=== Displacement

.Plot the max of the displacement over time
[source,python]
----
fig = go.Figure()
fig.add_trace(go.Scatter(x=df["time"], y=df["Statistics_disp_max"], name="max disp"))
fig.add_trace(go.Scatter(x=df["time"], y=df["Statistics_disp_min"], name="min disp"))
fig.update_layout(legend_title_text='Max displacement over time')
fig.show()
----

[%collapsible.result]
.Results
====
image:{imagesprefix}pendulum/minmaxdisp.png[]
====

=== Von-Mises Criterions


.Plot the max of the von-mises criterion over time
[source,python]
----
fig = go.Figure()
fig.add_trace(go.Scatter(x=df["time"], y=df["Statistics_von-mises_max"],name="max"))
fig.add_trace(go.Scatter(x=df["time"], y=df["Statistics_von-mises_min"],name="min"))
fig.add_trace(go.Scatter(x=df["time"], y=df["Statistics_von-mises_mean"],name="mean"))
fig.update_layout(legend_title_text='Von-Mises min,mean and max over time')
fig.show()
----

[%collapsible.result]
.Results
====
image:{imagesprefix}pendulum/minmaxvonmises.png[]
====

=== Video

The video below shows the oscillating motion of the pendulum.
Expand Down
Loading