This project contains an incredibly simple example of automatic differentation as applied to the computation of an I-section beam's second moment of area.
The example file, src/example.py
, computes the second moment of area for an I-section beam, while also using the auto-diff
package to compute the partial derivatives of the beam's second moment of area with respect to the beam's dimensions.
Use of pyenv for is recommended for the management of multiple Python versions. To install pyenv on a Unix-based system then configure the desired version for this project (3.11), steps are follows:
- Install
pyenv
: - Install python version:
pyenv install 3.11
- Set local environment in working directory
pyenv local 3.11
.
This will create a .python-version
file in the working directory.
Use a virtual environment is also recommended. To achieve this with venv
, follow the steps below:
- Install
venv
:sudo apt-get install python3-venv
- Create a virtual environment:
python3 -m venv environment/venv/development
- Activate the virtual environment:
source environment/venv/development/bin/activate
- Install the project dependencies:
pip install -r environment/requirements.txt
If using VSCode, it will also be necessary to set the Python interpreter to the local environment. This can be achieved
by launching the command palette (Ctrl+Shift+P
or F1
) and searching for Python: Select Interpreter
. Select
the file at environment/venv/development/bin/python
to set the interpreter.