Skip to content

Commit

Permalink
apply formatting and update visualization in jupyter
Browse files Browse the repository at this point in the history
  • Loading branch information
Krande committed Dec 20, 2023
1 parent 8063033 commit fdded8f
Show file tree
Hide file tree
Showing 59 changed files with 529 additions and 1,000 deletions.
5 changes: 3 additions & 2 deletions examples/experiments/rendering_pygfx/render_pygfx_fem_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# or
# mamba env update -f environment.yml --prune
#
import meshio
import pathlib

import meshio

import ada
from ada.config import logger

Expand All @@ -21,7 +22,7 @@ def main():
rmed = ada.from_fem_res(rmed_file)
# rmed.to_xdmf("temp/eigen_shell_cantilever_code_aster.xdmf")
rmed.to_gltf("temp/eigen_shell_cantilever_code_aster.glb")
rmed.to_viewer(1, 'modes___DEPL[0] - 13.5363')
rmed.to_viewer(1, "modes___DEPL[0] - 13.5363")


if __name__ == "__main__":
Expand Down
4 changes: 3 additions & 1 deletion examples/experiments/rendering_pygfx/render_pygfx_part.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def main():
bm5 = ada.Beam("my_beam_xyz_shell", (3, 2, 1), (3.5, 2.5, 1.5), "IPE300", color="red")
bm6 = ada.Beam("my_beam_xyz", (1, 2, 1), (1.5, 2.5, 1.5), "IPE300", color="yellow")
bm7_taper = ada.BeamTapered("my_Ibeam_taper", (2, 2, 1), (2.5, 2.5, 1.5), "IPE600", "IPE300", color="blue")
bm8_taper = ada.BeamTapered("my_BOX_beam_taper", (4, 2, 1), (4.5, 2.5, 1.5), "BG300x200x8x10", "BG200x200x8x10", color="red")
bm8_taper = ada.BeamTapered(
"my_BOX_beam_taper", (4, 2, 1), (4.5, 2.5, 1.5), "BG300x200x8x10", "BG200x200x8x10", color="red"
)
render_override.update({bm4.guid: GeomRepr.SHELL, bm5.guid: GeomRepr.SHELL})

# All beam profiles as solids
Expand Down
7 changes: 2 additions & 5 deletions examples/experiments/wgpu_gui/triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import wgpu


# %% Shaders


Expand Down Expand Up @@ -71,9 +70,7 @@ def main(canvas, power_preference="high-performance", limits=None):

async def main_async(canvas):
"""Async function to setup a viz on the given canvas."""
adapter = await wgpu.request_adapter_async(
canvas=canvas, power_preference="high-performance"
)
adapter = await wgpu.request_adapter_async(canvas=canvas, power_preference="high-performance")
device = await adapter.request_device_async(required_limits={})
return _main(canvas, device)

Expand Down Expand Up @@ -157,4 +154,4 @@ def draw_frame():

canvas = WgpuCanvas(size=(640, 480), title="wgpu triangle")
main(canvas)
run()
run()
7 changes: 3 additions & 4 deletions examples/experiments/wgpu_gui/wxpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"""
# run_example = false

import wx
from wgpu.gui.wx import WgpuWidget
import wgpu.backends.rs # noqa: F401, Select Rust backend

import wx
from triangle import main
from wgpu.gui.wx import WgpuWidget


class Example(wx.Frame):
Expand Down Expand Up @@ -38,4 +37,4 @@ def __init__(self):
main(example.canvas1)
main(example.canvas2)

app.MainLoop()
app.MainLoop()
38 changes: 18 additions & 20 deletions examples/notebooks/basic_parametric_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"execution_count": null,
"metadata": {
"ExecuteTime": {
"end_time": "2023-12-20T18:39:26.243111300Z",
"start_time": "2023-12-20T18:39:23.141930600Z"
}
},
"outputs": [],
"source": [
"from ada.param_models.basic_module import SimpleStru\n",
Expand All @@ -12,15 +17,17 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"a = Assembly(\"ParamModel\")\n",
"\n",
"for x in range(0, 2):\n",
" for y in range(0, 2):\n",
" for z in range(0, 2):\n",
"dim = 4\n",
"\n",
"for x in range(0, dim):\n",
" for y in range(0, dim):\n",
" for z in range(0, dim):\n",
" props = dict(name=f\"P{x}{y}{z}\", placement=Placement((x * 5, y * 5, z * 3)))\n",
" if z != 0:\n",
" props[\"add_bottom_floor\"] = False\n",
Expand All @@ -33,27 +40,18 @@
"metadata": {},
"outputs": [],
"source": [
"a"
"a.show()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"metadata": {
"pycharm": {
"is_executing": true
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Beginning writing to IFC file \"C:\\work\\code\\adapy\\examples\\temp\\massive_stru.ifc\" using IfcOpenShell\n",
"IFC file creation complete\n"
]
}
],
"outputs": [],
"source": [
"a.to_ifc(\"temp/massive_stru.ifc\")"
]
Expand All @@ -75,9 +73,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 1
"nbformat_minor": 4
}
609 changes: 47 additions & 562 deletions examples/notebooks/cantilever_fem_eigenfrequency.ipynb

Large diffs are not rendered by default.

34 changes: 17 additions & 17 deletions examples/notebooks/cantilever_fem_extended.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
" ada.Material(\"S420\", CarbonSteel(\"S420\", plasticity_model=DnvGl16Mat(0.1, \"S420\"))),\n",
")\n",
"a = ada.Assembly(\"MyAssembly\") / [ada.Part(\"MyPart\") / bm]\n",
"a"
"a.show()"
]
},
{
Expand Down Expand Up @@ -106,8 +106,8 @@
"origin = np.array([0.2, -0.1, -0.1])\n",
"points = [(0, 0), (0.1, 0), (0.05, 0.1)]\n",
"\n",
"poly1 = bm.add_penetration(ada.PrimExtrude(\"Poly1\", points, h, normal, origin, xdir))\n",
"bm"
"poly1 = bm.add_boolean(ada.PrimExtrude(\"Poly1\", points, h, normal, origin, xdir))\n",
"bm.show()"
]
},
{
Expand All @@ -124,8 +124,8 @@
"origin += np.array([0.2, 0, 0])\n",
"points = [(0, 0, r), (0.1, 0, r), (0.05, 0.1, r)]\n",
"\n",
"poly2 = bm.add_penetration(ada.PrimExtrude(\"Poly2\", points, h, normal, origin, xdir))\n",
"bm"
"poly2 = bm.add_boolean(ada.PrimExtrude(\"Poly2\", points, h, normal, origin, xdir))\n",
"bm.show()"
]
},
{
Expand All @@ -142,8 +142,8 @@
"origin += np.array([0.2, 0, 0])\n",
"points = [(0, 0, r), (0.1, 0, r), (0.1, 0.2, r), (0.0, 0.2, r)]\n",
"\n",
"poly3 = bm.add_penetration(ada.PrimExtrude(\"Poly3\", points, h, normal, origin, xdir))\n",
"bm"
"poly3 = bm.add_boolean(ada.PrimExtrude(\"Poly3\", points, h, normal, origin, xdir))\n",
"bm.show()"
]
},
{
Expand All @@ -160,8 +160,8 @@
"# Cylinder Extrude\n",
"x = origin[0] + 0.2\n",
"\n",
"cyl = bm.add_penetration(ada.PrimCyl(\"cylinder\", (x, -0.1, 0), (x, 0.1, 0), 0.1))\n",
"bm"
"cyl = bm.add_boolean(ada.PrimCyl(\"cylinder\", (x, -0.1, 0), (x, 0.1, 0), 0.1))\n",
"bm.show()"
]
},
{
Expand All @@ -178,8 +178,8 @@
"# Box Extrude\n",
"x += 0.2\n",
"\n",
"box = bm.add_penetration(ada.PrimBox(\"box\", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1)))\n",
"bm"
"box = bm.add_boolean(ada.PrimBox(\"box\", (x, -0.1, -0.1), (x + 0.2, 0.1, 0.1)))\n",
"bm.show()"
]
},
{
Expand All @@ -195,7 +195,7 @@
"source": [
"# Export IFC to the Home folder\n",
"a.to_ifc(\"../output/MyBeamWithHoles.ifc\")\n",
"a"
"a.show()"
]
},
{
Expand All @@ -213,7 +213,7 @@
"p = a.get_part(\"MyPart\")\n",
"p.fem = bm.to_fem_obj(0.1, \"shell\", options=GmshOptions(Mesh_MeshSizeFromCurvature=True))\n",
"\n",
"a"
"a.show()"
]
},
{
Expand All @@ -228,10 +228,10 @@
"outputs": [],
"source": [
"# Create a Static Analysis Step with a Gravity load (multiplied with 800 to get deformation)\n",
"step = a.fem.add_step(ada.fem.StepImplicit(\"gravity\", nl_geom=True, init_incr=100.0, total_time=100.0))\n",
"step = a.fem.add_step(ada.fem.StepImplicitStatic(\"gravity\", nl_geom=True, init_incr=100.0, total_time=100.0))\n",
"step.add_load(ada.fem.LoadGravity(\"grav\", -9.81 * 800))\n",
"\n",
"nodes = bm.bbox.sides.back(return_fem_nodes=True)\n",
"nodes = bm.bbox().sides.back(return_fem_nodes=True)\n",
"a.fem.add_bc(ada.fem.Bc(\"Fixed\", ada.fem.FemSet(\"bc_nodes\", nodes), [1, 2, 3]))"
]
},
Expand Down Expand Up @@ -337,9 +337,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.4"
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
60 changes: 36 additions & 24 deletions examples/notebooks/convert_fem.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@
"cells": [
{
"cell_type": "markdown",
"source": [
"# Convert FEM models"
],
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%% md\n"
}
}
},
"source": [
"# Convert FEM models"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true
},
"pycharm": {
"name": "#%%\n"
}
Expand All @@ -28,57 +34,63 @@
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"## Sesam FEM to Abaqus inp and Code Aster\n",
"First drag and drop your FEM file onto the explorer window to the left next to the \"convert_fem.ipynb\"\n",
"notebook. Then run the next cell (change the \"T1.FEM\" name to whatever the name of your FEM file is).\n",
"\n",
"In addition to Sesam FEM models you can also import\n",
"Abaqus/Calculix (.inp) and Code Aster (.med)."
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
]
},
{
"cell_type": "code",
"execution_count": null,
"outputs": [],
"source": [
"a = ada.from_fem(\"T1.FEM\")\n",
"a.to_fem(\"MyAbaqusModel\", \"abaqus\", make_zip_file=True, overwrite=True)\n",
"a.to_fem(\"MyCodeAsterModel\", \"code_aster\", make_zip_file=True, overwrite=True)"
],
"metadata": {
"collapsed": false,
"jupyter": {
"outputs_hidden": false
},
"pycharm": {
"name": "#%%\n"
}
}
},
"outputs": [],
"source": [
"a = ada.from_fem(\"T1.FEM\")\n",
"a.to_fem(\"MyAbaqusModel\", \"abaqus\", make_zip_file=True, overwrite=True)\n",
"a.to_fem(\"MyCodeAsterModel\", \"code_aster\", make_zip_file=True, overwrite=True)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
"nbformat_minor": 4
}
Loading

0 comments on commit fdded8f

Please sign in to comment.