Friday, October 4, 2019

Phasor / Rotating Vector Representation of Sinusoidal Quantities - Interactive Simulation


R, Ω L, mH C, μF ν, Hz
Plot CONTROLS: Click the legends above to hide/unhide individual lines/curves. Double click to show exclusively.
Vary the parameters ( R, L, C, ν ) in the above table and see the effects.
Animation stop/resume: -- uncheck to stop animation, check to resume
Reload the page to reset-restart!!

The animated plot named "Phasors" on the left shows five vectors (phasors, refer description given below) - each rotating at an angular speed of ω ;
  1. V representing v ( t )
  2. I representing i ( t )
  3. V R representing v R ( t )
  4. V L representing v L ( t )
  5. V C representing v C ( t )
It can be seen that, among the above five, the second and the third phasors are co-linear and in same direction. Also, the fourth and the fifth phasors are co-linear and in opposite directions. The end-points of these five rotating vectors are projected horizontally on to the five respective sinusoidal waves on the animated plot on the right titled 'Sinusoids: v ( t ), i ( t ) etc.'. In the animation, the constant parameter is the input voltage phasor:

V = 100 + j 200 Volts     [0]

R, L, C and ν can be varied individually via the input table.

Phasor representation of sinusoidally varying quantities is commonly used in Science and Engineering. For example, voltages and currents in ac (alternating current) circuits, forces and displacement mechanical vibration systems, and, several kinds of quantities in automatic control systems.

The above interactive simulation / visualization shows the phasor representation of four voltage sinusoids and one current sinusoid involved in the steady state analysis of a series RLC circuit excited by an ac supply v ( t ).

The applied voltage, v ( t ) at a time t , is,

v ( t ) = V sin ( ω t + φ )    [1]

Here, ω (rad/s) is its angular frequency and φ (rad) is its initial ( t = 0 ) phase angle. And, the frequency ν is,

ν = ω / 2 π     [2]

Using Euler's formula , the v ( t ) can also be represented as,

v ( t ) = Im{ V e j ( ω t + φ ) }    [3]

with j being the imaginary number √ -1 . For brevity, the notation Im{.} is dropped and,

v ( t ) = V e j ( ω t + φ )     [4]

Further, separating the time-invariant and time-dependent parts,

v ( t ) = V e jωt     [5]

Where,

V = V e     [6]

Applying Kirchhoff's voltage law to the above shown series RLC circuit,

v ( t ) = v R ( t ) + v L ( t ) + v C ( t )    [7]

Assuming i ( t ) to be the current in the (series) circuit, such that,

i ( t ) = I e j ( ω t + φ i )     [8]

or,

i ( t ) = I e jωt     [9]

Where,

I = I e i     [10]

As per the definitions of R-L-C elements,

v R ( t ) = iR     [11]

v L ( t ) = j ( iX L ), with inductive reactance X L = ωL     [12]

v C ( t ) = - j ( iX C ), with capacitive reactance X C = 1/ ωC     [13]

After some algebraic manipulations, one gets,

I = V / Z    [14]

in which, the total impedance of the series RLC circuit is,

Z = R + ( X L - X C )    [15]

Credits:
This article uses Plotly.js - "A free open source interactive JavaScript graphing library".

Monday, September 23, 2019

Transverse Vibration of Strings - Interactive simulation of the Wave Equation


Wave # v ν λ k ω Y T φ
1
2
Transverse vibration of strings is modeled by the following relation [123]:
(Please reload the page if equations do not display properly)
\begin{equation} y(t, x) = Y \sin (\omega t - k x + \phi) \end{equation}
Here, \(y\) is the transverse displacement at time \(t\) at a location identified by the coordinate \(x\).
\(\omega\) is the angular frequency of vibration of the string.
\(k\) is the propagation constant,
\begin{equation} k = \frac{2\pi}{\lambda} \end{equation}
\(\lambda\) is the wavelength.
Other important relations are:
Frequency \(\nu\),
\begin{equation} \nu = \frac{\omega}{2\pi} \end{equation}
Time period \(T\),
\begin{equation} T = \frac{1}{\nu} \end{equation}
Wave velocity \(v\),
\begin{equation} v = \nu \lambda \end{equation}
\(Y\) is the amplitude of vibration.
\(\phi\) is the initial (\(t = 0\)) phase angle at (\(x = 0\)).

The simulation shows 2 different waves - pre-initialised with all parameters having same values, except for \(Y\) and \(\phi\).
Change the values and see the effects.
Noticeably, certain values are coupled.

References

Wednesday, February 17, 2016

Free Open Source Software for Mechanical Engineering Students, Researchers & Professionals

Looking at the AICTE's list of Open Source alternatives to commercial s/w for Engineering students, and also at the chaos going on in this respect in several engineering campuses, I present here, based on my own experiences, a list of open source solutions for such learning and research situations, in particular, and also for industries.

As I have understood it, the basic set of ideas leading myself and several of my colleagues (for example, at IIT-B, University of Alaska Fairbanks, MIT, 2nd one from MIT, Virginia Tech, Harvard, London School of Economics, Sports Biomechanics Lab at UCDavis, San Francisco State University, The University of Utah, The California Institute of Technology (Caltech)) to the use of such software, since past about 20 years, are as follows:

1. Since there is perpetual shortage of funds, these free alternatives become the natural choice and a natural refuge for students, researchers as well as for professionals. In the Indian education scenario, it was surprising a few years back and is painful, even now, to see students taking bank loans to fund their education. Really tragic and painful stories are being now found in the media.

2. From the social perspective of a researcher and a s/w writer, I find it difficult to accept that such s/w should remain captive under the contemporary fund-owners. Each of such s/w is fundamentally a magnificent storehouse of knowledge and experiences of countless man/woman-hours of countless dedicated researchers, professionals etc.

3. In this discussion, the English word "generic" is very important. As per dictionaries, the word-meaning of "generic" is:

a: characteristic of or relating to a class or group of things; not specific:

b: of or relating to a whole group or class, not sold or made under a particular brand name

Obviously, the second word-meaning above is simply amazing! There is a concept of generic software, very much like generic medicine.  Thus, for example, for the generic 3D mechanical modeling s/w like Creo, Solidworks, Catia etc., there is the powerful open source alternative in the form of FreeCAD. It was really wonderful to find that the steps (like 2d drawing, pocketing, extruding etc.) encountered while undergoing a training on a commercial 3D modeling s/w, were found almost the same  in the online documentation/tutorial of FreeCAD.

Moreover, for a particular generic category of s/w, one may find different industrial entities using different commercial s/w, not much unlike different doctors prescribing from different brands for the same "generic medicine".

4. Particularly in the education institutes and universities, the objective is to impart the student the basic understanding of the s/w in a particular "generic" category. For this objective, the open source alternatives should be the natural choice, keeping in mind a comprehensive view of the situation. Also, it may again be emphasized that almost all of these s/w are widely used in research as well as industrial situations.


 The list (not complete, indeed):

1. Operating System: Linux, in the form of its several distributions. The most commonly used distributions being - Debian, Ubuntu and Fedora. For further motivation, see: 1 & 2.

2.  Office s/w: LibreOffice. No probs at all!!

3. C/C++: Most of the engineering students begin their coding experience with learning C/C++ on the blue TurboC/C++ ide which itself is known to be freely downloadable. However, the open source alternative gcc (used with vim and gnu make) provides a universe of advantages in terms of industry-readiness, comprehensive documentation etc. Still, if one wants to use the the blue TurboC/C++ ide, it is easily installable on Linux.

4. Painting, simple line-diagrams and 2D drafting: xfig.

5. AutoCAD: AutoCAD itself has been freely downloadable and installable via AICTE support since about 5 years. Moreover, there is DraftSight from Dassault systems.

6.3D modeling: As already discussed above, in the context of mechanical engineering, this is the most important case of free and open source alternative in the form of FreeCAD (ref.: University of Alaska Fairbanks, MIT, 2nd one from MIT, Virginia Tech, Harvard, Sports Biomechanics Lab at UCDavis, San Francisco State University, The University of Utah, The California Institute of Technology (Caltech)) which must be used in place of commercial alternatives.

7. Matlab: Octave is the Linux-community  solution I have myself been using since past several years. Scilab is another alternative, very strongly being advocated, for example, by academia from IIT Bombay.

8. CAM: "LinuxCNC controls CNC machines. It can drive milling machines, lathes, 3d printers, laser cutters, plasma cutters, robot arms, hexapods, and more."

In conclusion, with increasing laptop population (each laptop costing less than 10% of the expenditure on a typical engineering/technology UG degree (BTech/BE)), the best alternative to mechanical CAD and/or simulation labs would be to encourage students to bring to class their own laptops loaded with s/w solutions listed above, and/or, may be, the student versions of the commercial software.

The shortcomings found in these open source s/w, if any, should be removed by collaborative contributions from academia, governments etc. Indeed, this has already been happening since past several years.

Please do contact/comment for your suggestions, clarifications etc.

Thursday, February 4, 2016

A simple finite differencing example using Matlab/Octave

Listening to the queries of some students and researchers, a need was felt for writing a small and simple tutorial blog post giving a simple finite differencing example using Matlab/Octave.

Taking 'x' as the independent variable and 'f(x) = sin(x)' as the dependent variable, the attached code demonstrates the calculation of first two derivatives.

In the code, taking xVec (= x0, x2, x3 .... xn) to represent the nodal values of 'x',
and,

y1 = sin(xVec);


and,

y3 = cos(xVec);

the derivatives of f(x) at the nodal points are calculated as:

1st derivative:y2 = Dmatx*y1;% dy/dx = Dmatx * y1

2nd derivative:
y4 = Dmatx*Dmatx*y1;% d2y/dx2 = Dmatx * Dmatx * y1

It must be obvious that (y1, y2, y3, y4) are ((n + 11) by 1) vectors and Dmatx is (n + 1) dimension square matrix.

The resulting plots:


For 1at derivative (with n = 10):

For 2nd derivative (with n = 10):



For 1st derivative (with n = 20):
For 2nd derivative (with n = 20):


Please do contact/comment for your suggestions, clarifications etc.

Downloads.

Happy Matlabbing/Octaving!

Monday, December 21, 2015

A Python/openpyxl based timetable tool for automatically updating class, room/lab, teacher and centralized timetables taking an ERP-like input from an excel spreadsheet

A Python/openpyxl based timetable tool

1. Each row (starting from second) in the file “TT_ERP_Input1.xlsx” in “inputs” directory gives the per-event (lecture, tutorial or lab) input for preparing all the above mentioned four timetables using the four Python script files (*.py).

2. An empty row (actually, just the first cell in that row) is sensed to stop further processing of the above stated input-file.

3. The folder “templates” has templates used to prepare class, teacher, room/lab and centralized timetables.

4. The four python scripts for preparing these four timetables are in the base directory.

5. I have used Python 2.7.9 and openpyxl 2.3.2 versions. Using (Open Source) Linux Mint 17.2. However, it is well known that all these tools work just as fine on any other operating system or distribution. LibreOffice 4.3.3.2 was used as the spreadsheet s/w.

6. Each python-script may be run at command prompt as:

$ python makeclasses.py

or, inside the ipython shell (recommended) as:

In [1]: execfile('makeclasses.py')

Based on the contents of file (inputs/TT_ERP_Input1.xlsx), the exact number of "Class_*.xlsx" files are created in the current folder. Same for the other three “*.py” script-files (Of course, the script "makecentralized.py" creates only one "Centralized.xlsx"). A clash in each of these four types of timetables is highlighted by the corresponding cell filled red.

7. The zip-file “openpyxlTT.zip” has all the four script files, templates etc. with proper directory structure.

Feel free to communicate suggestions, comment,s etc. and to make your own modifications etc.

Happy timetabling !!!!!

Thursday, November 20, 2014

Preparing a LaTeX article for Elsevier - example paper "Solving a heat equation in Octave/Matlab"

Below are the details of one of my recent presentation to postgraduate students.

Presentation Title: Preparing a LaTeX article for Elsevier

Example paper: "Solving a heat equation in Octave/Matlab"

The Octave script: myoctave1.m

The LaTeX input file: elsarticle-template-num.tex

The zip-file containing the five image files( one xfig file and its eps copy, four eps files having screen-shots of windows having resulting from the octave script given below) : allfigures.zip

The commands (on Ubuntu 14.04 with texlive etc.):

For getting the plots from Octave:

in konsole or any other terminal:

user@domain:~$ octave

octave> myoctave1

This pops out four windows having a plot each - the screen-shots given in the file allfigures.zip mentioned above.

For preparing the paper

latex elsarticle-template-num.tex
dvipdf elsarticle-template-num.dvi


The otput:
elsarticle-template-num.dvi

and 

elsarticle-template-num.pdf


Thanks for visiting!

Thursday, February 6, 2014

A tutorial on C++ based GSL code for solving partial differential equations (PDE) with finite differencing

Presented below is a C++ based code example of using GSL for solving partial differential equations with finite differencing.

The example problem is the free vibration case of an Euler Bernoulli beam.

Field equation:

EI (d4w/dx4) + (rho*A) (d2w/dt2) = 0

Boundary conditions:

Clamped:

w = 0, dw/dx = 0

Hinged:

w = 0, d2w/dx2 = 0

Free:

d3w/dx3 = 0, d2w/dx2 = 0

Notations are the usual ones.


The code begins

#include < iostream >
#include < fstream >
#include < math.h >

//REF.: http://www.gnu.org/software/gsl/manual/html_node/Linear-Algebra-Examples.html#Linear-Algebra-Examples
#include < stdio.h >
#include < gsl/gsl_linalg.h >
//REF.: http://www.gnu.org/software/gsl/manual/html_node/Linear-Algebra-Examples.html#Linear-Algebra-Examples

//REF.: https://www.gnu.org/software/gsl/manual/html_node/BLAS-Examples.html#BLAS-Examples
#include < gsl/gsl_eigen.h >
#include < gsl/gsl_blas.h >
//REF.: https://www.gnu.org/software/gsl/manual/html_node/BLAS-Examples.html#BLAS-Examples

using namespace std;

int main (){

 cout<<"Hello, i am eulerbeam1... \n";

 fstream ofl1;
 ofl1.open("eulerbeam1.res", ios::out | ios::ate);

 //REF.: http://www.techscience.com/doi/10.3970/sl.2011.006.115.pdf
 double E = 2.1e11, rho = 7.85e3, l = 1, b = 0.01, d = 0.005;
 double I = b*d*d*d/12, A = b*d;
 
 int Nnodes = 60;

 double x0 = 0, xn = 1;
 double deltax = (xn - x0)/(Nnodes - 1);
 double onb2deltax = 1./(2*deltax);

 gsl_vector * vector1 = gsl_vector_alloc(Nnodes);

 gsl_matrix * Cmatx_nt = gsl_matrix_calloc (Nnodes, Nnodes);//Coefficients for first derivative
 gsl_matrix * Cmatx_nt2 = gsl_matrix_calloc (Nnodes, Nnodes);//Coefficients for second derivative
 gsl_matrix * Cmatx_nt3 = gsl_matrix_calloc (Nnodes, Nnodes);//Coefficients for third derivative
 gsl_matrix * Cmatx_nt4 = gsl_matrix_calloc (Nnodes, Nnodes);//Coefficients for fourth derivative
 gsl_matrix * Cmatx_Id = gsl_matrix_calloc (Nnodes, Nnodes);//the Identitiy matrix
 gsl_matrix * Cmatx_K = gsl_matrix_calloc (Nnodes, Nnodes);//the Stiffness matrix
 gsl_matrix * Cmatx_M = gsl_matrix_calloc (Nnodes, Nnodes);//the Mass matrix
 gsl_matrix * Cmatx_invK_M = gsl_matrix_calloc (Nnodes, Nnodes);//for storingthe inv(K)*M

 //for 0th node
 gsl_matrix_set(Cmatx_nt, 0, 0, -1./deltax);
 gsl_matrix_set(Cmatx_nt, 0, 1, 1./deltax);
 //for nth node
 gsl_matrix_set(Cmatx_nt, Nnodes - 1, Nnodes - 2, -1./deltax);
 gsl_matrix_set(Cmatx_nt, Nnodes - 1, Nnodes - 1, 1./deltax);
 for(int i = 1; i < Nnodes - 1; i++){
  gsl_matrix_set(Cmatx_nt, i, i - 1, -onb2deltax);
  gsl_matrix_set(Cmatx_nt, i, i + 1, onb2deltax);
 }

 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
     1.0, Cmatx_nt, Cmatx_nt,
     0.0, Cmatx_nt2);
 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
     1.0, Cmatx_nt, Cmatx_nt2,
     0.0, Cmatx_nt3);
 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
     1.0, Cmatx_nt2, Cmatx_nt2,
     0.0, Cmatx_nt4);

 gsl_matrix_set_identity(Cmatx_Id);


 gsl_matrix_memcpy(Cmatx_K, Cmatx_nt4);

 gsl_matrix_get_row(vector1, Cmatx_Id, 0);//for (deflection, w = 0) at x = 0
 //gsl_matrix_get_row(vector1, Cmatx_nt3, 0);//for (shear force, d3w/dx3 = 0) at x = 0
 gsl_matrix_set_row(Cmatx_K, 0, vector1);

 gsl_matrix_get_row(vector1, Cmatx_Id, Nnodes - 1);//for (deflection, w = 0) at x = 1
 //gsl_matrix_get_row(vector1, Cmatx_nt3, Nnodes - 1);//for (shear force, d3w/dx3 = 0) at x = 1
 gsl_matrix_set_row(Cmatx_K, Nnodes - 1, vector1);

 //gsl_matrix_get_row(vector1, Cmatx_nt, 0);//for (slope, dw/dx = 0) at x = 0
 gsl_matrix_get_row(vector1, Cmatx_nt2, 0);//for (moment, d2w/dx2 = 0) at x = 0
 gsl_matrix_set_row(Cmatx_K, 1, vector1);

 //gsl_matrix_get_row(vector1, Cmatx_nt, Nnodes - 1);//for (slope, dw/dx = 0) at x = 1
 gsl_matrix_get_row(vector1, Cmatx_nt2, Nnodes - 1);//for (moment, d2w/dx2 = 0) at x = 1
 gsl_matrix_set_row(Cmatx_K, Nnodes - 2, vector1);

 gsl_matrix_set_identity(Cmatx_M);
 gsl_matrix_set(Cmatx_M, 0, 0, 0);
 gsl_matrix_set(Cmatx_M, 1, 1, 0);
 gsl_matrix_set(Cmatx_M, Nnodes - 2, Nnodes - 2, 0);
 gsl_matrix_set(Cmatx_M, Nnodes - 1, Nnodes - 1, 0);

//Computing inv(K)*M through LU decomposition
 int signum; 
 gsl_permutation * p_lu = gsl_permutation_alloc (Nnodes);
 gsl_linalg_LU_decomp(Cmatx_K, p_lu, &signum);
 for(int i=0; i < Nnodes; i++){
  gsl_matrix_get_col (vector1, Cmatx_M, i); 
  gsl_linalg_LU_svx(Cmatx_K, p_lu, vector1);
  gsl_matrix_set_col(Cmatx_invK_M, i, vector1);
 }


//Computing eigenvalues and eigenvectors
 gsl_vector_complex *eval = gsl_vector_complex_alloc (Nnodes);
 gsl_matrix_complex *evec = gsl_matrix_complex_alloc (Nnodes, Nnodes);
 gsl_eigen_nonsymmv_workspace * myeigen_ws =
  gsl_eigen_nonsymmv_alloc (Nnodes);
 gsl_eigen_nonsymmv (Cmatx_invK_M, eval, evec, myeigen_ws);
 gsl_eigen_nonsymmv_free (myeigen_ws);
 gsl_eigen_nonsymmv_sort (eval, evec,
   GSL_EIGEN_SORT_ABS_DESC);
  

//saving the frequencies(Hz) in ascending order
 int i, j;
 double dumi= (1./(2*M_PI*l*l))*sqrt(E*I/(rho*A));
 for (i = 0; i < Nnodes; i++)
 {
  gsl_complex eval_i
   = gsl_vector_complex_get (eval, i);
  gsl_vector_complex_view evec_i
   = gsl_matrix_complex_column (evec, i);
  ofl1 << sqrt(1./(GSL_REAL(eval_i)))*dumi << " i" << GSL_IMAG(eval_i) << endl;
 }



 ofl1.close();
 cout << "Hello, i was eulerbeam1... \n";
 return 0;
}



The code ends.
Compilation command on a Linux console/command line:

g++ -lgsl eulerbeam1.cc -o eulerbeam1

Execution:
./eulerbeam1

Results give the following fundamental frequencies (Ref.: http://www.techscience.com/doi/10.3970/sl.2011.006.115.pdf):

Clamped-Clamped: 26.5281Hz
Clamped-Free: 4.44362 Hz
Simply-Supported: 11.7253 Hz






Friday, May 10, 2013

Matlab/Octave for the UG students of the subject - Control Systems


Students of the subject “Control Systems” can use GNU Octave for practising Matlab code.
Following is an example of a simple session while using Octave version 3.6.3 under a Fedora 17 installation.
BODE PLOT
Example 1:
System: (1 + s)

octave:1> sys1 = tf([1 1],[1])

Transfer function 'sys1' from input 'u1' to output ...

y1: s + 1

Continuous-time model.
octave:2> bode(sys1)
octave:5>

The resulting plot:



Example 1:
System: 30/(1 + 0.5s)(s + 1)(s + 5)

octave:13> [numer, denom] = zp2tf([],[-2 -1 -5], 60)
numer = 60
denom =

1 8 17 10

octave:14> sys2 = tf(numer, denom)

Transfer function 'sys2' from input 'u1' to output ...

60
y1: -----------------------
s^3 + 8 s^2 + 17 s + 10

Continuous-time model.
octave:16> close all
octave:17> bode(sys2)
octave:18>
The resulting plot:
Thanks for visiting!

Wednesday, February 20, 2013

A simple Python based tool for preparing randomized multi-set multiple choice question papers

A simple Python based tool for preparing randomized multi-set multiple choice question papers
Scipy.in 2012, IIT-BPecha Kucha Presentation
December 27-29 2012
Ashish Sharma

The Problem
 A class full of students
 So much to teach
 Frequent, continuous evaluations – QUIZES
 Multiple choice or objective type questions
 Not enough invigilators
 Time constraints
 Quality of evaluations

The Solution
 Randomized multiple choice question papers – orders of questions and answers
 Python - for the randomized text manipulation
 The input is a set of three text (txt or tex) files containing – the questions and the answers,  the header and the footer
 The output is a chosen number question papers containing the same sets of questions and answer choices – both randomly differentiated in terms of order

The Code (download the zip file here: for text & for latex) – imports
import sys, random
import fileinput
from subprocess import call
........
infilename = sys.argv[1]
...........
for line in fileinput.input( infilename ):
...........
random.seed()
...........
call(['latex', outfilename + ".tex"])

A Typical Session – for text only
$ ./otqpr.py

Usage: ./otqpr.py infile.[txt/tex] N
N being the number of versions to be created.
infileH.[txt/tex] and infileF.[txt/tex] must exist to define the header and the footer

$ ls
in1F.txt  in1H.txt  in1.txt  otqpr.py

$ ./otqpr.py in1.txt 3

$ ls
in1F.txt  in1H.txt  in1_OUTV0.txt  in1_OUTV1.txt  in1_OUTV2.txt  in1.txt  otqpr.py

A Typical Session – for latex input$ ./otqpr.py

Usage: ./otqpr.py infile.[txt/tex] N
N being the number of versions to be created.
infileH.[txt/tex] and infileF.[txt/tex] must exist to define the header and the footer

$ ls
Fig2.eps in1F.tex  in1H.tex  in1.tex  otqpr.py

$ ./otqpr.py in1.tex 3

$ ls
Fig2.eps in1F.tex  in1H.tex in1_OUTV0.pdf in1_OUTV1.pdf in1_OUTV2.pdf in1.tex otqpr.py

Typical Outputs – formatted .txt files
VERSION 1
Q. 1: The reason we are not crushed under the atmospheric pressure is
(A) the pressure inside us is almost same as the atmospheric pressure (B) the pressure is too small (C) we are strong enough (D) the resulting force is too small
Q. 2: A force can be providing
(A) neither a push nor a pull (B) either a push or a pull (C) only a pull (D) only a push

VERSION 2
Q. 1: The reason we are not crushed under the atmospheric pressure is
(A) we are strong enough (B) the pressure is too small (C) the pressure inside us is almost same as the atmospheric pressure (D) the resulting force is too small
Q. 4: A force can be providing
(A) neither a push nor a pull (B) either a push or a pull (C) only a push (D) only a pull


Thanks!

Thursday, November 22, 2012

Using Octave/Matlab for plotting a histogram showing frequency of byte-values in a file


octave:1> myfile = fopen('Pachmarhi3.png', 'rb');
octave:2> mydata = fread(myfile, 'uint8');
octave:3> size(mydata)
ans =
           72181       1
octave:4> hist(mydata, (0:255)');

octave:5> axis([0 255]);

octave:6> xlabel ("Byte value")

octave:7> ylabel ("Counts")
octave:8> title ("A histogram showing frequency of byte-values in a file");



octave:9>

 The file "Pachmarhi3.png":

Saturday, March 24, 2012

Potential areas for doing PhD using open source tools

1. General modeling and simulation problems across disciplines.
2. Computational mechanics of laminated composite plates - including static, dynamic (vibration) & buckling problems, both linear as well as non-linear
3. Applications of computational tools like Genetic Algorithm, Simulated Annealing, Neural Networks, Fuzzy logic etc.
4. Computation Fluid Mechanics (CFD) applied in several areas like - flow through pipes, bearings etc.
5. Cryptography - chaos based image encryptionwatermarking etc.
6. Computational Geometry applied to various fields like Finite Element Method (FEM), biology, CAD, computer communications, wild fire propagation etc.

Sunday, January 9, 2011

Solid Mechanics

Formulae: Stress Transformation
The necessary formulae for the plane stress case are as follows(ref. Solid Mechanics, Popov).Stresses on the $\theta$-plane.\begin{displaymath} \sigma_{x'}=\frac{\sigma_x+\sigma_y}{2} + \frac{\sigma_x-\sigma_y}{2} cos(2\theta) + \tau_{xy}sin(2\theta) \end{displaymath}\begin{displaymath} \tau_{x'y'}=-\frac{\sigma_x-\sigma_y}{2} sin(2\theta) + \tau_{xy}cos(2\theta) \end{displaymath}Principal planes\begin{displaymath} tan(2\theta_{1})=\frac{2\tau_{xy}}{\sigma_x-\sigma_y} \end{displaymath}This gives principal planes at $\theta_{11}$ and $\theta_{12}(=\theta_{11}+\pi/2)$. Principal stresses $(\sigma_{1}$ and $\sigma_2)$ corresponding to these planes are found from the formula for $(\sigma_{x'})$ above.Maximum shear stress $(\sigma_1$ ~$ \sigma_2)/2$ and its planes

Planes at 
and,
 
are the planes on which maximum shear stress occurs. Sense of maximum shear stresses corresponding to these planes are found from the formula for $(\tau_{x'y'})$ above.


Principal stresses and maximum shear stress can also be found directly as,

Friday, January 7, 2011

Computational Mechanics of Laminted plates

My research


PhD Thesis  produced following publications:
1. Stability and Vibration of Mindlin Sector Plates: An Analytical Approach, AIAA JOURNAL, Ashish Sharma, H.B. Sharda and Y. Nath, Vol. 43, No. 5, May 2005, pp. 1109-1116 
2. Stability and vibration of thick laminated composite sector plates, Ashish Sharma, H.B. Sharda and Y. Nath, Journal of Sound and Vibration, Vol. 287, 2005, pp. 1-23
3. Non-linear analysis of moderately thick sector plates, Y. Nath , H.B. Sharda and Ashish Sharma, Communications in Nonlinear Science and Numerical Simulation 10 (2005) 765-778
4. Nonlinear transient analysis of moderately thick laminated composite sector plates, Ashish Sharma, Y. Nath and H.B. Sharda, Communications in Nonlinear Science and Numerical Simulation
  • The thesis basically involved obtaining different solutions of five simultaneous partial differential equations
  • Two-dimensional Chebyshev polynomials were used for spatial discretization
  • Houbolt time-marching was used for temporal discretization for simulating the non-linear dynamic model
  • The code was written in C++ on LINUX platform
  • For linear algebra, the C++ library named TNT/JAMA were used
  • For word-processing,  pdflatex was used
  • For Figures & Plots, gnuplot and xfig were used

Tuesday, September 21, 2010

My Software Tools


Thanks to millions of individuals all over the world making the phenomenon called Linuxhappen, `i' have found the following tools quite indispensable in my academic pursuits with the help of computers.
  • vim - the nicest editor
  • gcc- the compiler
  • LaTeX- for numerically controlled text processing
  • Emacs- the great so-many-in-one editor
  • gnuplot- the plotting tool
  • xfig- the drawing tool 
  • gsl - the gnu scientific library

My Research Publications

-->
5. Free vibration analysis of moderately thick antisymmetric cross-plylaminated rectangular plates with elastic edge constraints, AvadeshK. Sharma, N.D. Mittal , Ashish Sharma, International Journal of Mechanical Sciences, International Journalof Mechanical Sciences 53 (2011) 688–695
6. Mechanics of Advanced Materials and Structures, Avadesh K. Sharma, N.D. Mittal, Ashish Sharma, Free vibration analysis of moderately thick antisymmetric angle-ply laminated rectangular plates with elastic edge constraints, Vol. 21 (5), 2014, pp. 341-348.
7. International Journal of Mechanical Sciences, Ashish Sharma, Free vibration of moderately thick antisymmetric laminated annular sector plates with elastic edge constraints, Vol. 83, 2014, pp. 124–132

 

Friday, January 29, 2010

ऊष्मप्रवैगिकी का प्रथम सिद्धांत ( First law of Thermodynamics)

UNIT IV ऊष्मप्रवैगिकी का प्रथम सिद्धांत (First law of Thermodynamics) १. ऊष्मप्रवैगिकी के प्रथम सिद्धांत के अनुसार ऊर्जा का एक रूप से दूसरे रूप मे रुपांतरण ही संभव है, विनाश नहीं। २. ऊष्मप्रवैगिकी के प्रथम सिद्धांत के अनुसार किसी निकाय (क) को ताप के रूप मे दी गई ऊर्जा मे से उस निकाय द्वारा करे गए कार्य रूपी ऊर्जा को घटाने पर जो शेष ऊर्जा बचती है वह उस निकाय की आंतरिक ऊर्जा मे हुई बढ़ोतरी के बराबर होती है। (क) निकाय -- एक समस्या विशेष के समाधान के लिये जिस एक निश्चित मात्रा के द्रव्य या जिस एक निश्चित सीमित स्थान पर ध्यान केन्द्रित किया जाता है उसे, यहां पर, निकाय कहा गया है। Translations of important English terms: thermodynamics ऊष्मा-गतिकी, ऊष्मप्रवैगिकी law नियम, सिद्धांत transformation रूपांतरण system निकाय energy ऊर्जा heat ताप work कार्य problem समस्या matter द्रव्य