| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
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.
To begin working with DynPy, you need an account on CoCalc.
To view exemplary capabilities of dynpy, run the following example script:
from dynpy.models.mechanics.pendulum import Pendulum
Pendulum().interactive_preview()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)from dynpy.utilities.creators import list_of_guides
list_of_guides()section = Section('Sample section name')
subsection = Subsection('Sample subsection name');
section = Section('Sample section name')
CurrentContainer(section);
display(ReportText('Sample text'));
display(Markdown(
'''
Sample text
'''
))
Picture('/route/to/image', caption = 'Sample caption')
doc.append(sample_section_name)# Add simulated data hereCreating 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"))doc.generate_pdf(clean_tex=True)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)/////////////////////Python Version: Python 3.8+. Required Libraries:
pip install numpy pylatex sympy pandas matplotlib scipy pint pypandoc wand
git clone https://github.com/bogumilchilinski/dynpy.gitDynPy is distributed under an open-source license. Refer to the LICENSE file for details.
| Back | FazBrowse Home | New Git URL |