Skip to content

A python module to create Moody charts and plot data in them. A Moody chart is a log-log representation for fluid mechanics, relating friction coefficient, Reynolds number and relative roughness of a pipe.

License

Notifications You must be signed in to change notification settings

agmartin2/MoodyChart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MoodyChart.py

Purpose

MoodyChart.py is a python module to help creating and using Moody charts for analysis of hydraulic head losses in pipes.

It is mostly intended to use TeX as underlying engine (with pgf background), and for that reason strings and values are TeX formatted.

Options

Some keyword options can be passed as arguments when calling the MoodyChart function.

  • Re_plotmin: Plot lower limit of Reynolds number.
  • Re_plotmax: Plot upper limit of Reynolds number.
  • f_plotmin: Plot lower limit of friction coefficient.
  • f_plotmax: Plot upper limit of friction coefficient.
  • lang: Set language for strings (Only en and es are currently supported).
  • color: plot colors (color|mono|octave, default: color)
  • cz_color: color for critical zone (valid matplotlib colors, default: "lightgray")
  • Debug: Enable debugging if set to True

Example of usage

import matplotlib as mpl
mpl.use("pgf")

pgf_with_pdflatex = {
    "pgf.texsystem": "pdflatex",
    "font.family": "serif",
    "pgf.preamble": \
         r"\usepackage[utf8x]{inputenc}" \
         r"\usepackage[T1]{fontenc}" \
         r"\usepackage{times}"
}
mpl.rcParams.update(pgf_with_pdflatex)

# Output file basename
outputname = "example_plot"

import MoodyChart as MC

# Create plot window
# Options are passed as plt = MC.MoodyChart(lang="es",f_plotmax=1e-1,...)
plt = MC.MoodyChart()
ax  = plt.gca()    # Only needed if something else is to be plotted
# Data to plot are passed as two [x1,x2,...],[y1,y2,...] arrays
ax.plot([11789],[4.01e-2],'ro')

# Plotting ...
plt.savefig(outputname + '.pgf', bbox_inches = 'tight')
plt.savefig(outputname + '.pdf', bbox_inches = 'tight')

More about this

This is my first python module, so there is surely room for improvement. Suggestions and bug fixes are welcome.

This module currently provides output only in Spanish and English. I prefer to keep everything on a single file, so I did not adapt it to gettext. As said, I am very new to python and suggestions are welcome.

License

MoodyChart is released under the the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

Author

Agustín Martín Domingo <[email protected]>

About

A python module to create Moody charts and plot data in them. A Moody chart is a log-log representation for fluid mechanics, relating friction coefficient, Reynolds number and relative roughness of a pipe.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages