Skip to content

Instantly share code, notes, and snippets.

View MechCoder's full-sized avatar
💭
away

manoj kumar MechCoder

💭
away
View GitHub Profile
@MechCoder
MechCoder / Thermo.py
Created September 19, 2012 04:16
A python script to output other properties of steam when temperature and pressure are given.Requires three database files called 'super.dat' , 'ptables.dat' , 'Temptables.dat'
'''Thermo
A python module used to retrieve information about various other properties of steam , when either temperature , pressure and one of enthalpy , entropy , specific volume and quality are given .
Author = S.Manoj Kumar
'''
@MechCoder
MechCoder / SteamSolver.py
Created September 23, 2012 14:12
A GUI which is basically a steam - data calculator
import gtk
import thermo
class SteamSolver:
def __init__(self):
'''Initial window which has a combo box from which the user can choose either of temperature and pressure'''
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
@MechCoder
MechCoder / Hangman.py
Created November 16, 2012 20:10
Play hangman using python
import sys
from PyQt4 import QtGui , QtCore
import time
class Hangman(QtGui.QWidget):
def __init__(self):
super(Hangman , self).__init__()
self.window()
@MechCoder
MechCoder / scrape_ode.py
Created June 18, 2013 12:20
Useless Piece of code, that turned out to be useful
import urllib2
import re
html = urllib2.urlopen('http://12000.org/my_notes/kamek/KERNEL/index.htm', 'r')
html = html.readlines()
ode = open('ode.txt', 'w')
for line in html:
if line.startswith('<PRE'):
index = html.index(line)
ode.write(html[index + 2])
@MechCoder
MechCoder / stopwatch.py
Created June 29, 2013 13:56
Stopwatch using PyGtk
import time
import gtk
import threading
import gobject
gtk.gdk.threads_init()
class main():
def __init__(self):
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_title('Stopwatch')
@MechCoder
MechCoder / better.py
Last active December 19, 2015 11:58
Which one is better?
chi = Function('chi')(x, y)
chix = chi.diff(x)
chiy = chi.diff(y)
cpde = chix + h*chiy - hy*chi
chieq = Symbol("chi")
for i in range(1, deg + 1):
chieq += Add(*[
Symbol("chi_" + str(power) + "_" + str(i - power))*x**power*y**(i - power)
for power in range(i + 1)])
cnum, cden = cancel(chieq.diff(x) + h*chieq.diff(y)
@MechCoder
MechCoder / basis.txt
Created July 13, 2013 06:14
The basis of factors that I got for the given Maple example.
[x*cos(y)**2, cos(y), 1/(x*log(x)*sin(y)), sin(y), x*sin(y)*cos(y), -1/(x**2*log(x)*sin(y)) - 1/(x**2*log(x)**2*sin(y)), cos(y)/(x*log(x)*sin(y)**2), cos(y)**2, x**2*cos(y)**4, cos(y)**2/(x**2*log(x)**2*sin(y)**4), 1/(x**4*log(x)**2*sin(y)**2) + 2/(x**4*log(x)**3*sin(y)**2) + 1/(x**4*log(x)**4*sin(y)**2), 1/(x**2*log(x)**2*sin(y)**2), cos(y)**4, x**2*sin(y)**2*cos(y)**2, sin(y)**2, x**2*sin(y)*cos(y)**3, cos(y)/(x*log(x)*sin(y)), -1/(x**2*log(x)) - 1/(x**2*log(x)**2), x*sin(y)**2*cos(y), cos(y)/log(x), cos(y)**3/(x*log(x)*sin(y)**2), cos(y)**3, cos(y)/(x**2*log(x)**2*sin(y)**3), x*sin(y)*cos(y)**3, -cos(y)**2/(x**2*log(x)*sin(y)) - cos(y)**2/(x**2*log(x)**2*sin(y)), -cos(y)**2/(x*log(x)*sin(y)) - cos(y)**2/(x*log(x)**2*sin(y)), x*cos(y)**4, cos(y)**2/(x*log(x)*sin(y)**2), cos(y)**2/(log(x)*sin(y)), x*cos(y)**3, -cos(y)/(x**2*log(x)*sin(y)) - cos(y)/(x**2*log(x)**2*sin(y)), -1/(x**3*log(x)**2*sin(y)**2) - 1/(x**3*log(x)**3*sin(y)**2), cos(y)**3/(log(x)*sin(y)**2), -cos(y)/(x*log(x)) - cos(y)/(x*log(x)**2), sin
@MechCoder
MechCoder / simplify.py
Last active December 20, 2015 07:39
How to optimise?
C = S(0)
A = simplify(hx.diff(y)
if A:
B = simplify(hy.diff(y) + hy**2)
if B:
C = simplify(hx.diff(x) - hx**2)
if C:
Ax = A.diff(x)
Ay = A.diff(y)
@MechCoder
MechCoder / gist:6201842
Created August 10, 2013 19:37
Solving for f(x)
⎛ ⌠ ⎞
⎜ ⎮ 2 ⎟
⎜ ⎮ b ⋅(a⋅F(a⋅x + b⋅y) - b) ⎟ ⎛ 2 2⎞
-b⋅(a⋅y - b⋅x) + ⎜C₁ - ⎮ ────────────────────────────── dr⎟⋅⎝a + b ⎠
⎜ ⎮ ⎛ 2 2⎞ ⎟
⎜ ⎮ (a + b⋅F(a⋅x + b⋅y))⋅⎝a + b ⎠ ⎟
⎝ ⌡ ⎠
─────────────────────────────────────────────────────────────────────
2 2
a + b
@MechCoder
MechCoder / Integral_subs_rules.txt
Created August 20, 2013 04:58
Rules for integration
Indefinite integrals:
1. If old is an integration variable, and new is a Symbol that is not present in expr, then expr.subs({old: new}), should xreplace old with new.
Example:
expr = Integral(f(x), x)
expr.subs(x, y) // should give
⎮ f(y) dy