Skip to content
Merged
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
13 changes: 12 additions & 1 deletion Markdown/ansys_codefest/ansys.codefest.mapdl.Beam.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@

# <kbd>class</kbd> `Beam`
Continuous material linking two nodes.
Dataclass for continuous material linking two nodes.



**Args:**

- <b>`start`</b>: starting node of beam
- <b>`end`</b>: ending node of beam
- <b>`section`</b>: cross-section of beam
- <b>`material`</b>: material of beam
- <b>`number`</b>: beam number
- <b>`stress`</b>: maximum stress experienced by beam. Initialises as 0.

### <kbd>method</kbd> `Beam.__init__`

Expand Down
8 changes: 4 additions & 4 deletions Markdown/ansys_codefest/ansys.codefest.mapdl.BeamXn.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Beam cross-section enum.

In PyMAPDL the beam cross-sections correspond to the following sectypes.

* RECT = RECTANGLE = 1
* RECT = RECTANGLE = 1

* HREC = RECTANGLETUBE = 4
* HREC = RECTANGLETUBE = 4

* CSOLID = CIRCLE = 2
* CSOLID = CIRCLE = 2

* CTUBE = CYLINDER = 3
* CTUBE = CYLINDER = 3

Dimensions structure for each cross-section shown below:

Expand Down
7 changes: 7 additions & 0 deletions Markdown/ansys_codefest/ansys.codefest.mapdl.Blueprint.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
# <kbd>class</kbd> `Blueprint`
The Plan/Blueprint for a simulation. Contains nodes, beams and BCs.



**Args:**

- <b>`nodes`</b>: list of nodes created for the blueprint
- <b>`beams`</b>: list of beams created for the blueprint

### <kbd>method</kbd> `Blueprint.__init__`

```python
Expand Down
73 changes: 41 additions & 32 deletions Markdown/ansys_codefest/ansys.codefest.mapdl.BuildyMcBuildFace.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
# <kbd>class</kbd> `BuildyMcBuildFace`
Instance of the bridge-building machine: BuildyMcBuildFace.

You can submit attempts and look at the challenge input via this class. Instances of this class should NOT be created directly, but should be created by one of the `Start` methods.
You can submit attempts and look at the challenge input via this class. Instances of this class should NOT be created directly, but should be created by one of the `Start` methods. Hence, constructor args are all private parameters.



**Args:**

- <b>`_blueprint`</b>: the blueprint to build designs from
- <b>`_challenge`</b>: Challenge object representing what is being tackled
- <b>`_mapdl_loc`</b>: path to alternative mapdl executable
- <b>`_server`</b>: Optional Server object containing connection details.

### <kbd>method</kbd> `BuildyMcBuildFace.__init__`

Expand All @@ -11,8 +20,7 @@ __init__(
_blueprint: ansys.codefest.mapdl.mechanics.core.Blueprint,
_challenge: ansys.codefest.mapdl.tools.Challenge,
_mapdl_loc: pathlib.Path = None,
_server: ansys.codefest.mapdl.tools.Server = None,
_BuildyMcBuildFace__log_path: pathlib.Path = WindowsPath('.attempt_logs')
_server: ansys.codefest.mapdl.tools.Server = None
) → None
```

Expand Down Expand Up @@ -49,42 +57,18 @@ Construct bridge from a design.

Depending on the design this step may take time. The method does three things in this order:

1. Validate the design can be used to create a simulation

2. Create a simulation blueprint from the design

1. Validate the design can be used to create a simulation 2. Create a simulation blueprint from the design 3. Create a simulation from the blueprint and execute it 4. Create a Bridge object with the simulation and return it
3. Create a simulation from the blueprint and execute it

4. Create a Bridge object with the simulation and return it

Steps 1 and 2 are typically very fast, but 3 can take significantly longer depending on the complexity of your design.

If your submission does not pass the validation step, it does not count as an attempt. Include plot=True as an arg if you'd like matplotlib to plot the result as well.



**Examples:**
```python-repl
>>> import ansys.codefest.mapdl as acf
>>> example = acf.Start.builtin_challenge('1a')
>>> design = example.suggest_a_design()
>>> bridge = example.build_bridge(design, mapdl_version=231)
>>> success, feedback, beams = bridge.assess_for_breaks()
>>> success
False
>>> feedback
"..."
``` In the following example we do the same again but connect to a remote instance of MAPDL via the `Server` object.

```python-repl
>>> import ansys.codefest.mapdl as acf
>>> example = acf.Start.builtin_challenge('1a',
server=acf.Server())
>>> design = example.suggest_a_design()
>>> bridge = example.build_bridge(design)
>>> success, feedback, beams = bridge.assess_for_breaks()
>>> success
False
>>> feedback
"..."
```

Materials can optionally be included in the design as a list of IDs (integers) that correspond to the list of beams. See all the materials available (and their IDs) by accessing the `acf.MATERIALS` dict.


Expand All @@ -99,6 +83,31 @@ Materials can optionally be included in the design as a list of IDs (integers) t
**Returns:**
instantiated Bridge object, which can be used to gather results



**Examples:**


In the following examples we step through the whole simulation loop from start to finish. In Example 2 we connect to a server instead of a local connection.

```python
# Example 1
import ansys.codefest.mapdl as acf
example = acf.Start.builtin_challenge('1a')
design = example.suggest_a_design()
bridge = example.build_bridge(design, mapdl_version=231)
success, feedback, beams = bridge.assess_for_breaks()
print(feedback) # should print feedback as a string if no success

# Example 2
import ansys.codefest.mapdl as acf
example = acf.Start.builtin_challenge('1a',
server=acf.Server())
design = example.suggest_a_design()
bridge = example.build_bridge(design)
success, feedback, beams = bridge.assess_for_breaks()
```

---

## <kbd>method</kbd> `BuildyMcBuildFace.calculate_design_cost`
Expand Down
18 changes: 9 additions & 9 deletions Markdown/ansys_codefest/ansys.codefest.mapdl.Challenge.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ The file path to the story file.


**Returns:**
` the location of the story file as a pathlib Path
the location of the story file as a pathlib Path

---

Expand All @@ -72,7 +72,7 @@ The suggestion file path.


**Returns:**
` the location of the suggestion json file as a pathlib Path
the location of the suggestion json file as a pathlib Path



Expand Down Expand Up @@ -115,14 +115,14 @@ Create a Challenge instance from scratch.

**Args:**

- <b>`path_to_level`</b>: path to where the level file should go
- <b>`path_to_suggestion`</b>: path to where the suggestion file should go
- <b>`story_type`</b>: what sort of instructions should be added to the challenge
- <b>`path_to_level`</b>: path to where the level file should go
- <b>`path_to_suggestion`</b>: path to where the suggestion file should go
- <b>`story_type`</b>: what sort of instructions should be added to the challenge



**Returns:**
` The new challenge instance
The new challenge instance

---

Expand All @@ -141,13 +141,13 @@ Create a Challenge instance from a built-in an example.

**Args:**

- <b>`number`</b>: aka ID. This will be something like `'8'` or `'1a'`
- <b>`story_type`</b>: what sort of instructions should be added to the challenge
- <b>`number`</b>: aka ID. This will be something like `'8'` or `'1a'`
- <b>`story_type`</b>: what sort of instructions should be added to the challenge



**Returns:**
` The new challenge instance
The new challenge instance

---

Expand Down
15 changes: 14 additions & 1 deletion Markdown/ansys_codefest/ansys.codefest.mapdl.CrossSection.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@
# <kbd>class</kbd> `CrossSection`
Beam cross-section details.

There are 4 cross-sections available: RECT - BeamXn.RECTANGLE HREC - BeamXn.RECTANGLETUBE CSOLID - BeamXn.CIRCLE CTUBE - BeamXn.CYLINDER
There are 4 cross-sections available.;


- RECT - BeamXn.RECTANGLE
- HREC - BeamXn.RECTANGLETUBE
- CSOLID - BeamXn.CIRCLE
- CTUBE - BeamXn.CYLINDER



**Args:**

- <b>`shape`</b>: Beam cross-section shape
- <b>`dimensions`</b>: Dimensions list to accompany the shape

### <kbd>method</kbd> `CrossSection.__init__`

Expand Down
16 changes: 15 additions & 1 deletion Markdown/ansys_codefest/ansys.codefest.mapdl.Simulation.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@

# <kbd>class</kbd> `Simulation`
Simulation class. Consumes 1 blueprint instance in order to perform =
Simulation class. Consumes 1 blueprint instance in order to perform.

Most args are left as defaults and calculated during the building phase.



**Args:**

- <b>`blueprint`</b>: a blueprint object
- <b>`nodes`</b>: list of nodes to be simulated
- <b>`beams`</b>: list of beams to be simulated
- <b>`mapdl`</b>: base mapdl object (or existing session object)
- <b>`mapdl_version`</b>: version number if specific one is needed
- <b>`mapdl_loc`</b>: location on your harddrive of the mapdl executable if needed
- <b>`server`</b>: server url if connection to remote server needed.

### <kbd>method</kbd> `Simulation.__init__`

Expand Down
7 changes: 6 additions & 1 deletion Markdown/ansys_codefest/ansys.codefest.mapdl.StoryType.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@

# <kbd>class</kbd> `StoryType`
The three types of story presentation ranging from least to most verbose.
The three types of story presentation ranging from least to most verbose. Integer Enum.


- MINIMAL = 0
- CONCISE = 1
- VERBOSE = 2



Expand Down
48 changes: 25 additions & 23 deletions Markdown/ansys_codefest/ansys.codefest.mapdl.Submission.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,31 @@ This class is a `typing.TypedDict` class that specifies the schema all dictionar
**Examples:**


The suggested design for example 1a is shown below. ```python
design = {"nodes": [[3, -2, 1],
[4, -1, 1],
[5, 0, 1],
[6, 1, 1],
[7, 2, 1],
[8, 0, 0],
[9, 0, -1]],
"beams": [[1, 3],
[3, 4],
[4, 5],
[5, 6],
[6, 7],
[7, 2],
[5, 8],
[8, 9],
[9, 59]],
"load_path": [1, 3, 4, 5, 6, 7, 2],
"cross_section": [2, 2, 2, 2, 2, 2, 2, 2, 2],
"dimensions": [[0.025], [0.025], [0.025], [0.025],
[0.025], [0.025], [0.025], [0.025],
[0.025]],
"materials": [1, 1, 1, 1, 1, 1, 3, 3, 3]}
The suggested design for example 1a is shown below.

```
{"nodes": [[3, -2, 1],
[4, -1, 1],
[5, 0, 1],
[6, 1, 1],
[7, 2, 1],
[8, 0, 0],
[9, 0, -1]],
"beams": [[1, 3],
[3, 4],
[4, 5],
[5, 6],
[6, 7],
[7, 2],
[5, 8],
[8, 9],
[9, 59]],
"load_path": [1, 3, 4, 5, 6, 7, 2],
"cross_section": [2, 2, 2, 2, 2, 2, 2, 2, 2],
"dimensions": [[0.025], [0.025], [0.025], [0.025],
[0.025], [0.025], [0.025], [0.025],
[0.025]],
"materials": [1, 1, 1, 1, 1, 1, 3, 3, 3]}
```


Expand Down
6 changes: 6 additions & 0 deletions Markdown/ansys_codefest/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Ansys Codefest Companion Library
- Requires-Dist - ipython>=8.10.0
- Requires-Dist - ansys-mapdl-core>0.68.0
- Requires-Dist - jupyter>=1.0.0
- Requires-Dist - pytest >=2.7.3 ; extra == "test"
- Requires-Dist - pytest-cov ; extra == "test"
- Requires-Dist - pre-commit ; extra == "test"
- Requires-Dist - pytest-rerunfailures ; extra == "test"
- Requires-Dist - pytest-cov ; extra == "test"
- Provides-Extra - test

# Ansys CodeFest Companion Library

Expand Down