Skip to content
 
 

Repository files navigation

Table of Contents

  1. Introduction
    1. What is DynPy?
    2. Key Features
    3. Getting Started on CoCalc
  2. How to Start / Basic Usage
    1. Example Scripts
    2. Creating First Document / Report
    3. Lookin for some help
  3. Reporting Module
    1. Overview of the Reporting Module
    2. Creating Reports
    3. Exporting Reports
    4. Practical Examples
    5. Customization Options (Advanced)
  4. Simulation Engine
  5. Data Handling
  6. Dynamic Modeling
  7. Visualization Tools
  8. Installation & Setup (Optional, for Local Development)
    1. Requirements
    2. Manual Installation
  9. Usage Examples
    1. Simulating a Dynamic System
    2. Data Import & Export
    3. Running a Custom Model
    4. Generating Reports
  10. Licensing Information

Introduction

1. What is DynPy?

DynPy is a Python module designed for engineering calculations on dynamical systems. It provides a comprehensive framework for modeling, simulating, and analyzing dynamic mechanical systems.

2. Key Features

  • Dynamics Module: Tools for modeling mechanical systems and their dynamics.
  • Mechanical Models: A collection of predefined mechanical models developed by experts.
  • Symbolic and Numeric Solvers: Tools for solving Ordinary Differential Equations (ODEs) using symbolic and numerical methods.
  • Reporting Module: A structured reporting system for generating and exporting reports.

3. Getting Started on CoCalc

To begin working with DynPy, you need an account on CoCalc.

  1. Create an account on CoCalc.
  2. Accept the project invitation using this link.
  3. Open the README FIRST file.
  4. Follow the instructions in the introductory guide.

How to Start / Basic Usage

1. Example Scripts

To view exemplary capabilities of dynpy, run the following example script:

from dynpy.models.mechanics.pendulum import Pendulum

Pendulum().interactive_preview()

2. Creating First Document / Report

from dynpy.utilities.report import *
from dynpy.utilities.documents.guides import Guide

doc = Guide('./output/sample_report', title="Sample Report")

section = Section('Exemplary section name')
CurrentContainer(section)

display(Markdown(''' Exemplary Markdown text in the section '''))
display(ReportText(' Exemplary text appended into section '))

doc.append(section)

doc.generate_pdf(clean_tex=True)

3. Looking for some help

from dynpy.utilities.creators import list_of_guides
list_of_guides()

Defining Report Content

Creating a section of document

section = Section('Sample section name')

Creating a subsection of document

subsection = Subsection('Sample subsection name');

Selecting a section or subsection to add content to

section = Section('Sample section name')
CurrentContainer(section);

Adding text to section via ReportText

display(ReportText('Sample text'));

Adding text to section via Markdown

display(Markdown(
'''
Sample text 
'''
))

Adding an image into the section

Picture('/route/to/image', caption = 'Sample caption')

Appending sections and subsections into the document

doc.append(sample_section_name)

Incorporating Simulation Results

# Add simulated data here

Adding Visualizations, Formulas and Data Tables

Creating plot and adding it to document

import matplotlib.pyplot as plt

def create_plot():
    plt.plot([0, 1, 2], [0, 1, 4])
    plt.savefig("./plot.png")

Picture('./plot.png', caption='Sample plot')

Adding formula to the document

d, r, fib, fia, thetaa, thetab = symbols('d r varphi_B varphi_A phi_A phi_B');

harvestine_formula = Eq(d, 2 * r * sp.asin(sp.sqrt(sp.sin((fib - fia) / 2)**2 + (cos(fia) * cos(fib) * sp.sin((thetab - thetaa) / 2)**2))))

display(SympyFormula(harvestine_formula))

Creating table and adding it to document

from dynpy.utilities.adaptable import *

predicted_travel_time = Subsection('Predicted Travel Time');
CurrentContainer(predicted_travel_time);

time_s = Symbol('time_s', positive=True)
time_h = Symbol('time_h')
length = Symbol('length', positive=True)
velocity = Symbol('velocity', positive=True)

dane = {
    'Start': ['NYC', 'Albany', 'Syracuse', 'Buffalo', 'Cleveland', 'Toledo', 'Total line'],
    'Stop': ['Albany', 'Syracuse', 'Buffalo', 'Cleveland', 'Toledo', 'Chicago', ''],
    time_s: [3348, 3386, 2782, 4362, 2606, 4824, 21308],
    time_h: ['00:55:48', '00:56:26', '00:46:22', '01:12:42', '00:43:26', '01:20:24', '05:55:08'],
    length: [215.981, 219.844, 225.822, 295.54, 172.905, 369.093, 1499.185],
    velocity: [232.24, 233.74, 292.22, 243.91, 238.86, 275.44, 253.29]
}

unit_dict = {
    time_s: ureg.second,
    time_h: ureg.hour,
    length: ureg.kilometer,
    velocity: ureg.kilometer / ureg.hour
}

LatexDataFrame.set_default_units(unit_dict)

def format_cell(x):
    if isinstance(x, str):
        return x
    else:
        return f'${latex(x)}$'

tabelka = LatexDataFrame.formatted(
    data = dane,
).map(format_cell)

tabelka.columns = ['Start', 'Stop', 'Time [s]', 'Time [h]', 'Length [km]', 'Velocity [km/h]']

predicted_travel_time.append(tabelka.reported(caption="Travel Time Data Table"))

3. Exporting Reports

Supported Formats

  • PDF
  • LaTeX
  • Markdown

Exporting Procedures

doc.generate_pdf(clean_tex=True)

4. Practical Examples

Generating a Simple Report

from dynpy.utilities.report import *
from dynpy.utilities.templates.document import Guide

doc = Guide('./reports/sample-report')

sample_section = Section('Sample Section')
CurrentContainer(sample_section)

display(ReportText('Sample text'));

second_sample_section = Section('Second Sample Section')
CurrentContainer(second_sample_section)

display(ReportText('Sample text'));

sample_subsection = Subsection('Sample Subsection');
CurrentContainer(sample_subsection);

display(ReportText('Sample text'));

second_sample_subsection = Subsection('Second sample Subsection');
CurrentContainer(second_sample_subsection);

display(ReportText('Sample text'));

doc.append(sample_section)
doc.append(second_sample_section)
doc.append(sample_subsection)
doc.append(second_sample_subsection)

doc.generate_pdf(clean_tex=True)

5. Customization Options (Advanced)

Formatting Text and Equations

///

Customizing Layout and Styles

///

Custom styles

Utilizing Templates for Consistency

///

Use predefined templates

///

Simulation Engine

///

Data Handling

///

Dynamic Modeling

///

Installation & Setup (Optional, for Local Development)

Requirements

Python Version: Python 3.8+. Required Libraries:

  • numpy
  • pylatex
  • sympy
  • pandas
  • matplotlib
  • scipy
  • pint
  • pypandoc
  • wand

Manual Installation

pip install numpy pylatex sympy pandas matplotlib scipy pint pypandoc wand

git clone https://github.com/bogumilchilinski/dynpy.git

Licensing Information

DynPy is distributed under an open-source license. Refer to the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages