generated from ansys/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
702c86c
commit 9d597fe
Showing
58 changed files
with
5,257 additions
and
382 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{{ name | escape | underline}} | ||
|
||
.. currentmodule:: {{ module }} | ||
|
||
.. autoclass:: {{ objname }} | ||
|
||
{% block methods %} | ||
|
||
{% if methods %} | ||
.. rubric:: {{ _('Methods') }} | ||
|
||
.. autosummary:: | ||
:toctree: | ||
{% for item in methods %} | ||
{% if item != "__init__" %} | ||
{{ name }}.{{ item }} | ||
{% endif %} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} | ||
|
||
{% block attributes %} | ||
{% if attributes %} | ||
.. rubric:: {{ _('Attributes') }} | ||
|
||
.. autosummary:: | ||
:toctree: | ||
{% for item in attributes %} | ||
{% if item.0 != item.upper().0 %} | ||
{{ name }}.{{ item }} | ||
{% endif %} | ||
{%- endfor %} | ||
{% endif %} | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Nodes | ||
===== | ||
These classes are specific to the :mod:`ansys.optislang.core.nodes <ansys.optislang.core.nodes>` module: | ||
|
||
.. currentmodule:: ansys.optislang.core.nodes | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary | ||
:template: class.rst | ||
|
||
Node | ||
System | ||
ParametricSystem | ||
RootSystem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
Optislang | ||
========= | ||
These classes are specific to the ``optislang`` module: | ||
These classes are specific to the :mod:`ansys.optislang.core.optislang <ansys.optislang.core.optislang>` module: | ||
|
||
.. currentmodule:: ansys.optislang.core.optislang | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary | ||
:template: class.rst | ||
|
||
Optislang |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Project | ||
======= | ||
These classes are specific to the :mod:`ansys.optislang.core.project <ansys.optislang.core.project>` module: | ||
|
||
.. currentmodule:: ansys.optislang.core.project | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary | ||
:template: class.rst | ||
|
||
Project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Project parametric | ||
================== | ||
These classes are specific to the :mod:`ansys.optislang.core.project_parametric <ansys.optislang.core.project_parametric>` module: | ||
|
||
.. currentmodule:: ansys.optislang.core.project_parametric | ||
|
||
.. autosummary:: | ||
:toctree: _autosummary | ||
:template: class.rst | ||
|
||
ParameterManager | ||
Design | ||
DesignVariable | ||
DependentParameter | ||
MixedParameter | ||
OptimizationParameter | ||
StochasticParameter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
.. _ref_design_evaluation: | ||
|
||
================== | ||
Design evaluation | ||
================== | ||
Instance of the :class:`RootSystem() <ansys.optislang.core.nodes.RootSystem>` allows user to | ||
create new designs and evaluate them. Instance of the | ||
:class:`RootSystem() <ansys.optislang.core.nodes.RootSystem>` is accessible from instance of the | ||
:class:`Optislang() <ansys.optislang.core.optislang.Optislang>` via its | ||
:func:`project <ansys.optislang.core.project.Project>` property. | ||
|
||
.. code:: python | ||
from ansys.optislang.core import Optislang | ||
from ansys.optislang.core.project_parametric import Design | ||
from ansys.optislang.core import examples | ||
from pathlib.Path import Path | ||
# open project with defined parameters | ||
parametric_project = examples.get_files('calculator_with_params')[1][0] | ||
osl = Optislang(project_path=parametric_project) | ||
# do not modify original file | ||
osl.save_as(Path.cwd() / 'parametric_project.opf') | ||
# get root system | ||
root_system = osl.project.root_system | ||
.. note:: | ||
|
||
Creation and evaluation of designs is currently supported only on the | ||
:class:`RootSystem() <ansys.optislang.core.nodes.RootSystem>`. Therefore, project has to have | ||
parameters already defined at the project root system and workflow has to be | ||
prepared for this (``Receive designs`` and ``Send back designs`` must be set in design flow). | ||
Please, see example :ref:`ref_ten_bar_truss_evaluate_design`. | ||
|
||
|
||
Create new design | ||
----------------- | ||
New :class:`Design() <ansys.optislang.core.project_parametric.Design>` can be created by obtaining | ||
design with reference values from :class:`RootSystem() <ansys.optislang.core.nodes.RootSystem>` | ||
and modifying its parameters or design parameters can be specified from scratch. | ||
|
||
|
||
From reference design | ||
~~~~~~~~~~~~~~~~~~~~~ | ||
Design with all parameters specified in the project with their reference values can be obtained by | ||
:func:`get_reference_design() <ansys.optislang.core.nodes.RootSystem.create_design>` method. | ||
Parameters values may be modified by methods of the instance of | ||
:class:`Design() <ansys.optislang.core.project_parametric.Design>` class. | ||
|
||
.. code:: python | ||
# ... | ||
from ansys.optislang.core.project_parametric import DesignVariable | ||
reference_design = root_system.get_reference_design() | ||
# modify parameter value using either ``name`` and ``value`` | ||
reference_design.set_parameter_by_name(name = 'a', value = 12) | ||
# instance of ``DesignVariable`` or ``Parameter`` may be used as well | ||
a = DesignVariable(name='a', value=12) | ||
reference_design.set_parameter(parameter=a) | ||
From empty design | ||
~~~~~~~~~~~~~~~~~~~ | ||
Design can be also created from scratch directly creating instance of the | ||
:class:`Design() <ansys.optislang.core.project_parametric.Design>` class. | ||
Parameters don't have to be provided when initializing new design. | ||
|
||
.. code:: python | ||
# design created using directly Design() class | ||
direct_design = Design(parameters = {'a': 3, 'b': 4}) | ||
# create empty design and add parameters afterward | ||
empty_design = Design() | ||
empty_design.set_parameter_by_name(name = 'a', value = 3) | ||
empty_design.set_parameter_by_name(name = 'q', value = 4) | ||
# parameters may also be removed | ||
empty_design.remove_parameter(name = 'c') | ||
# or remove all parameters | ||
empty_design.clear_parameters() | ||
Check design parameters | ||
~~~~~~~~~~~~~~~~~~~~~~~ | ||
In order to check whether design contains all parameters defined in the project, | ||
:func:`get_missing_parameters_names() <ansys.optislang.core.nodes.RootSystem.get_missing_parameters_names>` | ||
method can be used. To check, whether design contains parameters which are not defined in the project, method | ||
:func:`get_undefined_parameters_names() <ansys.optislang.core.nodes.RootSystem.get_undefined_parameters_names>` | ||
may be used. This step is not necessary though, because this is always done internally while evaluating design. | ||
|
||
.. code:: python | ||
# ... | ||
missing_parameters = root_system.get_missing_parameters(empty_design) | ||
undefined_parameters = root_system.get_undefined_parameters(direct_design) | ||
Evaluate design | ||
--------------- | ||
Designs can be evaluated using method | ||
:func:`evaluate_design() <ansys.optislang.core.nodes.RootSystem.evaluate_design>`. This method | ||
returns the same instance of :class:`Design() <ansys.optislang.core.project_parametric.Design>` | ||
class with updated results. | ||
|
||
.. code:: python | ||
# ... | ||
# single design | ||
result_design = root_system.evaluate_design(design = reference_design) | ||
.. note:: | ||
|
||
Please, note that the optiSLang retains only last evaluated design at the project root system. | ||
Therefore, results of previous designs have to be stored locally if they are required for | ||
further usage, for example as an instance of | ||
:class:`Design() <ansys.optislang.core.project_parametric.Design>` class. | ||
|
||
Finally, when everything is done and | ||
:class:`Optislang() <ansys.optislang.core.optislang.Optislang>` instance is not needed any more, | ||
terminate it. | ||
|
||
.. code:: python | ||
osl.dispose() | ||
Oops, something went wrong.