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
17 changes: 9 additions & 8 deletions doc/source/contribute_examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,35 @@ Contribute

## Contribute to PyWorkbench example repo

You can share your PyWorkbench project on [PyWorkbench Example repo](https://github.com/ansys-internal/pyworkbench-examples) with PyWorkbench community.
You can share your PyWorkbench projects on [PyWorkbench Example repo](https://github.com/ansys-internal/pyworkbench-examples) with the PyWorkbench community.


## Check out a clone of PyWorkbench Example repo:
## How to contribute to PyWorkbench example repo:
### Check out a clone of PyWorkbench Example repo:
```
git clone https://github.com/ansys-internal/pyworkbench-examples.git pywb_examples
```
## Access the example root directory:
### Access the example root directory:
```
cd pywb_examples
```
## Create a git feature branch:
### Create a git feature branch:
```
git checkout -b feat/your_branch_name
```
## Add your example under a new subdirectory:
### Add your example under a new subdirectory:
```
mkdir examples/your_sub_dir
cp example_files* examples/your_sub_dir/
```
## Update the code owner file:
### Update the code owner file:
```
edit CODEOWNERS
```
## Push your changes to github server:
### Push your changes to github server:
```
git push -u origin feat/your_branch_name
```

## Create a pull request to merge your feature branch into the main branch.
### Create a pull request to merge your feature branch into the main branch.

4 changes: 2 additions & 2 deletions doc/source/start_server.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ By default, server's working directory uses the user preference for temporary
project file directory. One can also specify a different working directory:
`StartServer(WorkingDirectory="/path/to/a/writable/dir")`


Another way to start Workbench server, along with a connected client, is to use [PyWorkbench API](api/index).
## Start Workbench server from client side
Another way to start Workbench server, along with a connected client, is to use [PyWorkbench API](api/index) client-side scripting.
18 changes: 9 additions & 9 deletions doc/source/user_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ wb.connect()
### Launch Workbench server and start a client
During development phase or for debugging purpose, it is useful to start Workbench server on the developer's desktop or some computer within the company network.

One can certainly start a Workbench server by executing command `StartServer()` in any Workbench session and use the returned server port to start a client, like in the example above.
One can always start a Workbench server by executing command `StartServer()` in any running Workbench session and use the returned server port to start a client, like in the example above.

Alternatively, one can launch a Workbench server and start a client programmatically in Python script. To launch it on the local computer:
Alternatively, one can launch a Workbench server and start a client programmatically in client-side Python script. To launch a server on the local computer:
```
from ansys.workbench.core import launch_workbench
wb = launch_workbench()
```
or to launcher server on a remote Windows machine with valid credentials:
or to launcher a server on a remote Windows machine with valid user credentials:
```
from ansys.workbench.core import launch_workbench
host = "server_machine_name_or_ip"
username = "your_username_on_server_machine"
password = "your_password_on_server_machine"
wb = launch_workbench(host=host, username=username, password=password)
```
There are other options to this API, such as specifying a certain Workbench release to launch, or to use specified working directories on server or at client side instead of the default directories.
There are other options to this `launch_workbench` API, such as specifying a certain Workbench release to launch, or to use particular working directories on the server and/or at the client instead of the default directories.
```
from ansys.workbench.core import launch_workbench
wb = launch_workbench(release='241', server_workdir='path_to_a_dir_on_server', client_workdir='path_to_a_dir_on_client')
Expand All @@ -60,7 +60,7 @@ wb.run_script_file('a_script_file_name', log_level='info')
```

### File handling
Data files can be uploaded to the server or downloaded from the server, using `upload_file` or `download_file` API. The client-side working directory is used to hold these files. There is also a working directory on the server for the same purpose. The server's working directory can be obtained via Workbench query `GetServerWorkingDirectory()` that runs on server.
Data files can be uploaded to the server or downloaded from the server, using `upload_file` or `download_file` API. The client-side working directory is used to hold these files unless absolute paths or target directory is specified. There is also a working directory on the server for the same purpose. The server's working directory can be obtained via Workbench query `GetServerWorkingDirectory()` that runs on the server.

For example, this uploads all part files with a given prefix and all agdb files in the working directory, plus another file outside of the working directory, from client to server:
```
Expand Down Expand Up @@ -88,7 +88,7 @@ out_file_des = os.path.join(work_dir, "solve.out")
shutil.copyfile(out_file_src, out_file_des)
''')
```
The client can then download all output file from the server:
This client script downloads all files with .out extension from the server's working directory:
```
wb.download_file('*.out')
```
Expand All @@ -103,7 +103,7 @@ All the file handling APIs come with progress bar that is shown by default. One
wb.download_file('solve.out', show_progress=False)
```

### Start other PyANSYS services based on PyWorkbench
### Start other PyANSYS services from systems in a PyWorkbench project
#### PyMechanical
For any mechanical system in the Workbench project, PyMechanical service can be started and connected to from the same client machine.
The following runs a server side script to create a mechanical system, then starts PyMechanical service for the system and establish a PyMechanical client.
Expand All @@ -112,11 +112,11 @@ from ansys.mechanical.core import launch_mechanical
sys_name = wb.run_script_string(r'''import json
wb_script_result=json.dumps(GetTemplate(TemplateName="Static Structural (ANSYS)").CreateSystem().Name)
''')
server_port=wb.start_mechanical_server(system_name=system_name)
server_port=wb.start_mechanical_server(system_name=sys_name)
mechanical = launch_mechanical(start_instance=False, ip='localhost', port=server_port)"
```
#### PyFluent
This example illustrates how to start PyFluent service and client on a Fluent system created in Workbench.
This example illustrates how to start PyFluent service and client for a Fluent system created in Workbench.
```
import ansys.fluent.core as pyfluent
sys_name = wb.run_script_string(r'''import json
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"

[project]
name = "ansys-workbench-core"
version = "0.5.dev0"
version = "0.6.dev0"
description = "A python wrapper for Ansys Workbench"
readme = "README.md"
requires-python = ">=3.8,<4.0"
Expand Down