Skip to content

Commit

Permalink
Deploying to gh-pages from @ e5e4d26 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
A-CGray committed Dec 12, 2024
1 parent 447eb67 commit f38aa2e
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 69 deletions.
42 changes: 28 additions & 14 deletions _modules/tacs/mphys/builder.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,7 @@ <h3>Navigation</h3>
<div class="body" role="main">

<h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span></span><span class="kn">import</span> <span class="nn">copy</span>
<span class="kn">import</span> <span class="nn">warnings</span>

<span class="kn">from</span> <span class="nn">mphys.builder</span> <span class="kn">import</span> <span class="n">Builder</span>
<span></span><span class="kn">from</span> <span class="nn">mphys.core</span> <span class="kn">import</span> <span class="n">Builder</span><span class="p">,</span> <span class="n">MPhysVariables</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="kn">from</span> <span class="nn">tacs.pytacs</span> <span class="kn">import</span> <span class="n">pyTACS</span>
Expand All @@ -62,7 +59,7 @@ <h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span class="n">pytacs_options</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">check_partials</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">conduction</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">coupled</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">coupling_loads</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
<span class="n">write_solution</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
<span class="n">separate_mass_dvs</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
<span class="n">res_ref</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
Expand Down Expand Up @@ -141,9 +138,10 @@ <h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span class="sd"> conduction : bool, optional</span>
<span class="sd"> Flag to determine weather TACS component represents a thermal (True) or structural (False) analysis.</span>
<span class="sd"> Defaults to False.</span>
<span class="sd"> coupled : bool, optional</span>
<span class="sd"> Flag to determine of if multidisciplinary coupling variables should be turned on</span>
<span class="sd"> (used in aerostructural/thermostructural analyses). Defaults to True.</span>
<span class="sd"> coupling_loads : list[str] or str or None, optional</span>
<span class="sd"> List of coupling loads to add to right handside of FEA state equation. These loads correspond to the nodal</span>
<span class="sd"> forces on the model. Multiple load sources can be specified, these will be added together before being</span>
<span class="sd"> applied to the model. This is used in aerostructural/thermostructural analyses. Defaults to None.</span>
<span class="sd"> write_solution : bool, optional</span>
<span class="sd"> Flag to determine whether to write out TACS solutions to f5 file each design iteration. Defaults to True.</span>
<span class="sd"> separate_mass_dvs : bool, optional</span>
Expand Down Expand Up @@ -243,7 +241,12 @@ <h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">pytacs_options</span> <span class="o">=</span> <span class="n">pytacs_options</span>
<span class="bp">self</span><span class="o">.</span><span class="n">check_partials</span> <span class="o">=</span> <span class="n">check_partials</span>
<span class="bp">self</span><span class="o">.</span><span class="n">conduction</span> <span class="o">=</span> <span class="n">conduction</span>
<span class="bp">self</span><span class="o">.</span><span class="n">coupled</span> <span class="o">=</span> <span class="n">coupled</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">coupling_loads</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">coupling_loads</span> <span class="o">=</span> <span class="p">[</span><span class="n">coupling_loads</span><span class="p">]</span>
<span class="k">elif</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">coupling_loads</span><span class="p">,</span> <span class="s2">&quot;__iter__&quot;</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">coupling_loads</span> <span class="o">=</span> <span class="n">coupling_loads</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">coupling_loads</span> <span class="o">=</span> <span class="p">[]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">write_solution</span> <span class="o">=</span> <span class="n">write_solution</span>
<span class="bp">self</span><span class="o">.</span><span class="n">separate_mass_dvs</span> <span class="o">=</span> <span class="n">separate_mass_dvs</span>
<span class="bp">self</span><span class="o">.</span><span class="n">res_ref</span> <span class="o">=</span> <span class="n">res_ref</span>
Expand Down Expand Up @@ -271,7 +274,14 @@ <h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span class="bp">self</span><span class="o">.</span><span class="n">assembler_setup</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fea_assembler</span><span class="p">)</span>

<span class="c1"># Set up elements and TACS assembler</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fea_assembler</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">element_callback</span><span class="p">)</span></div>
<span class="bp">self</span><span class="o">.</span><span class="n">fea_assembler</span><span class="o">.</span><span class="n">initialize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">element_callback</span><span class="p">)</span>

<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">conduction</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span> <span class="o">=</span> <span class="n">MPhysVariables</span><span class="o">.</span><span class="n">Thermal</span>
<span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span><span class="o">.</span><span class="n">STATES</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span><span class="o">.</span><span class="n">TEMPERATURE</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span> <span class="o">=</span> <span class="n">MPhysVariables</span><span class="o">.</span><span class="n">Structures</span>
<span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span><span class="o">.</span><span class="n">STATES</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span><span class="o">.</span><span class="n">DISPLACEMENTS</span></div>


<div class="viewcode-block" id="TacsBuilder.get_coupling_group_subsystem">
Expand All @@ -293,9 +303,9 @@ <h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">TacsCouplingGroup</span><span class="p">(</span>
<span class="n">fea_assembler</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">fea_assembler</span><span class="p">,</span>
<span class="n">conduction</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">conduction</span><span class="p">,</span>
<span class="n">discipline_vars</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span><span class="p">,</span>
<span class="n">check_partials</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">check_partials</span><span class="p">,</span>
<span class="n">coupled</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">coupled</span><span class="p">,</span>
<span class="n">coupling_loads</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">coupling_loads</span><span class="p">,</span>
<span class="n">scenario_name</span><span class="o">=</span><span class="n">scenario_name</span><span class="p">,</span>
<span class="n">problem_setup</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">problem_setup</span><span class="p">,</span>
<span class="n">res_ref</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">res_ref</span><span class="p">,</span>
Expand All @@ -319,7 +329,10 @@ <h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span class="sd"> mesh : :class:`~openmdao.api.Component` or :class:`~openmdao.api.Group`</span>
<span class="sd"> The openmdao subsystem that has an output of coordinates.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">TacsMeshGroup</span><span class="p">(</span><span class="n">fea_assembler</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">fea_assembler</span><span class="p">)</span></div>
<span class="k">return</span> <span class="n">TacsMeshGroup</span><span class="p">(</span>
<span class="n">fea_assembler</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">fea_assembler</span><span class="p">,</span>
<span class="n">discipline_vars</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span><span class="p">,</span>
<span class="p">)</span></div>


<div class="viewcode-block" id="TacsBuilder.get_pre_coupling_subsystem">
Expand All @@ -342,6 +355,7 @@ <h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span class="n">fea_assembler</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">fea_assembler</span><span class="p">,</span>
<span class="n">initial_dv_vals</span><span class="o">=</span><span class="n">initial_dvs</span><span class="p">,</span>
<span class="n">separate_mass_dvs</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">separate_mass_dvs</span><span class="p">,</span>
<span class="n">discipline_vars</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span><span class="p">,</span>
<span class="p">)</span></div>


Expand All @@ -363,7 +377,7 @@ <h1>Source code for tacs.mphys.builder</h1><div class="highlight"><pre>
<span class="k">return</span> <span class="n">TacsPostcouplingGroup</span><span class="p">(</span>
<span class="n">fea_assembler</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">fea_assembler</span><span class="p">,</span>
<span class="n">check_partials</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">check_partials</span><span class="p">,</span>
<span class="n">conduction</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">conduction</span><span class="p">,</span>
<span class="n">discipline_vars</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">discipline_vars</span><span class="p">,</span>
<span class="n">write_solution</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">write_solution</span><span class="p">,</span>
<span class="n">scenario_name</span><span class="o">=</span><span class="n">scenario_name</span><span class="p">,</span>
<span class="n">problem_setup</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">problem_setup</span><span class="p">,</span>
Expand Down
14 changes: 9 additions & 5 deletions _sources/examples/Example-Beam_Optimization.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ First, we import required libraries, define the model bdf file, and define impor
import matplotlib.pyplot as plt
import numpy as np
import openmdao.api as om
from mphys import Multipoint
from mphys.scenario_structural import ScenarioStructural
from mphys.core import Multipoint, MPhysVariables
from mphys.scenarios import ScenarioStructural
from tacs import elements, constitutive, functions
from tacs.mphys import TacsBuilder
Expand Down Expand Up @@ -120,7 +120,6 @@ We use this builder to create an MPhys :class:`~mphys.StructuralScenario`.
mesh_file=bdf_file,
element_callback=element_callback,
problem_setup=problem_setup,
coupled=False,
write_solution=False,
)
struct_builder.initialize(self.comm)
Expand All @@ -135,7 +134,10 @@ We use this builder to create an MPhys :class:`~mphys.StructuralScenario`.
self.mphys_add_scenario(
"tip_shear", ScenarioStructural(struct_builder=struct_builder)
)
self.mphys_connect_scenario_coordinate_source("mesh", "tip_shear", "struct")
self.connect(
f"mesh.{MPhysVariables.Structures.Mesh.COORDINATES}",
f"tip_shear.{MPhysVariables.Structures.COORDINATES}",
)
# Connect dv component to input of structural scenario
self.connect("dv_struct", "tip_shear.dv_struct")
Expand Down Expand Up @@ -196,7 +198,9 @@ Finally, we can plot the optimized thickness distribution using matplotlib and c
.. code-block:: python
# Get optimized solution variables
x = prob.get_val("mesh.x_struct0", get_remote=True)[:-3:3]
x = prob.get_val(f"mesh.{MPhysVariables.Structures.Mesh.COORDINATES}", get_remote=True)[
:-3:3
]
t_opt = prob["dv_struct"]
m_opt = prob["tip_shear.mass"]
Expand Down
10 changes: 6 additions & 4 deletions _sources/examples/Example-Composite_Optimization.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ To begin we first import required libraries, define the model bdf file, and defi
import openmdao.api as om
import numpy as np
from mphys import Multipoint
from mphys.scenario_structural import ScenarioStructural
from mphys.core import Multipoint
from mphys.scenarios import ScenarioStructural

from tacs import elements, constitutive, functions
from tacs.mphys import TacsBuilder
Expand Down Expand Up @@ -168,7 +168,6 @@ We use this builder to create an MPhys :class:`~mphys.StructuralScenario`.
element_callback=element_callback,
problem_setup=problem_setup,
constraint_setup=constraint_setup,
coupled=False,
check_partials=True,
)
struct_builder.initialize(self.comm)
Expand All @@ -181,7 +180,10 @@ We use this builder to create an MPhys :class:`~mphys.StructuralScenario`.
self.mphys_add_scenario(
"pressure_load", ScenarioStructural(struct_builder=struct_builder)
)
self.mphys_connect_scenario_coordinate_source("mesh", "pressure_load", "struct")
self.connect(
f"mesh.{MPhysVariables.Structures.Mesh.COORDINATES}",
f"pressure_load.{MPhysVariables.Structures.COORDINATES}",
)
self.connect("dv_struct", "pressure_load.dv_struct")
Expand Down
Loading

0 comments on commit f38aa2e

Please sign in to comment.