User:Arjun

From ASCEND
Revision as of 20:45, 14 April 2012 by Arjun (talk | contribs)
Jump to navigation Jump to search

I am an undergraduate student of Institute of Technology, Banaras Hindu University, Varanasi, India. I am currently pursuing major in Computer Science & Engineering. I am currently working on project GUI Improvements in Ascend. I have made necessary modifications in IPOPT solver Package to make it work on Ubuntu 11.10. My Skill Set:- C, C++, Tcl/Tk, Python.


Bugs:

.

Bugs reported by me are bug 534, bug 535, bug 536. Bug resolved by me(it was also resolved by shawn) bug 533 with its diff files https://github.com/arjun109/recent_files_patch


Projectile Model

I have developed a model which solves the Projectile Motion of a particle.

The model calculates the various parameters of the projectile motion namely: Range, Time of Flight, Instant Horizontal and Vertical distance at given instant time.

I also did the parametrisation of the model by creating the various instances of the Projectile and compared theta(angle with the horizontal plane of projectile at starting time) and speed(magnitude with which the projectile was projected).

The model could easily be changed to compare various other parameters of the Projection such as: Difference in the initial Plane & Final Plane vs Range. Range vs speed(magnitude with which the projectile was projected).

REQUIRE "atoms.a4l";


MODEL Projectile  ;
	(* variables *)
	max_height	"the maximum height of the projectile"
		IS_A distance;
	range	"distance covered bt the projectile in horizontal direction"
		IS_A distance;
	
	instant_hor_dist  "distance travelled from the starting point in horizontal and vertical direction"
		IS_A distance ;
	instant_ver_dist IS_A displacement ;
	initial_height 		"the initial height "
		IS_A distance;
	final_height	"the final height"
		IS_A distance;
        time_flight , max_flight_time    "total time of flight  and time to reach maximum height by a flight"
		IS_A time;
        magn_speed , horizontal_speed ,vertical_speed "speed split into horizontal speed and vertical speed"
		IS_A speed ;
	theta      "angle with horizontal ground at the time of throwing"
		IS_A angle ;
 	instant_time "any time in between the flight or projectile motion"
		IS_A time ;


 		(* equations *)

	horizontal_speed = magn_speed * cos(theta) ;
	vertical_speed =  magn_speed * sin(theta) ;

	max_flight_time = vertical_speed / 1{EARTH_G}    ;
	
		

	max_height = (vertical_speed ^ 2) / ( 2 * 1{EARTH_G} )  ;
	
	time_flight = max_flight_time + sqrt( (2 * (max_height + initial_height - final_height) / 1{EARTH_G} ) ) ;	
	range = time_flight * horizontal_speed ;
	
	instant_hor_dist = horizontal_speed * instant_time  ;
	instant_ver_dist = ( (vertical_speed * instant_time) - (0.5 * 1{EARTH_G} ) * (instant_time ^ 2) ) ;

METHODS
	METHOD specify;
	    NOTES
		'purpose' SELF {to fix four variables and make the problem well-posed}
	    END NOTES;
		FIX theta;
		FIX magn_speed;
		FIX initial_height;
		FIX final_height;
	END specify;

	







METHOD values;
    NOTES
	'purpose' SELF {to set the values for the fixed variables}
    END NOTES;
	theta		        :=	0.785;
	magn_speed		:=	100 {m/s};
	initial_height		:=	10 {m};
	final_height		:=	50 {m};
END values;

METHOD bound_self;
END bound_self;

METHOD bound_all;
    RUN bound_self;
END bound_all;

METHOD scale_self;
END scale_self;

METHOD scale_all;
    RUN scale_self;
END scale_all;

METHOD default_self;
	time_flight			:=	10 {s};
	max_flight_time			:=	20 {s};
END default_self;

METHOD default_all;
    RUN default_self;
	theta			:=	0.785 {rad};
	magn_speed		:=	500 {m/s};
	initial_height		:=	10 {m};
	final_height		:=	30 {m};
END default_all;


END Projectile ;

Its parameterized version code is as follows

REQUIRE "atoms.a4l";
PROVIDE "ProjectileTabulated.a4c";

MODEL Projectile  (
	theta      "angle with horizontal ground at the time of throwing"
		WILL_BE angle ;
	magn_speed  "the initial overall magnitude of speed"
 		WILL_BE speed ;
	initial_height 		"the initial height "
		WILL_BE distance;
	final_height	"the final height"
		WILL_BE distance;

)  ;

			(* variables *)
	max_height	"the maximum height of the projectile"
		IS_A distance;
	
	range	"distance covered bt the projectile in horizontal direction"
		IS_A distance;
	
	instant_hor_dist , instant_ver_dist "distance travelled from the starting point in horizontal and vertical direction"
		IS_A distance ;

        time_flight , max_flight_time    "total time of flight  and time to reach maximum height by a flight"
		IS_A time;
     
	horizontal_speed ,vertical_speed "speed split into horizontal speed and vertical speed"
		IS_A speed ;
	
 	instant_time "any time in between the flight or projectile motion"
		IS_A time ;


 		NOTES 'purpose' SELF { Various Equations necessary for the projectile motion 
					are described below }
    END NOTES;
		
			(* equations *)
       
	horizontal_speed = magn_speed * cos(theta) ;
	vertical_speed = magn_speed * sin(theta) ;
	max_flight_time = vertical_speed / 1{EARTH_G}    ;
	max_height = (vertical_speed ^ 2) / ( 2 * 1{EARTH_G} )  ;
	time_flight = max_flight_time + sqrt( (2 * (max_height + initial_height - final_height) / 1{EARTH_G} ) ) ;	
	range = time_flight * horizontal_speed ;
	instant_hor_dist = horizontal_speed * instant_time  ;
	instant_ver_dist =( (vertical_speed * instant_time) - (0.5 * 1{EARTH_G} ) * (instant_time ^ 2) ) ;

	

METHODS
	METHOD specify;
	    NOTES
		'purpose' SELF {to fix four variables and make the problem well-posed}
	    END NOTES;
		FIX theta;
		FIX magn_speed;
		FIX initial_height;
		FIX final_height;
	END specify;

METHOD values;
    NOTES
	'purpose' SELF {to set the values for the fixed variables}
    END NOTES;
	theta		        :=	0.785;
	magn_speed		:=	100 {m/s};
	initial_height		:=	10 {m};
	final_height		:=	50 {m};
END values;

METHOD bound_self;
END bound_self;

METHOD bound_all;
    RUN bound_self;
END bound_all;

METHOD scale_self;
END scale_self;

METHOD scale_all;
    RUN scale_self;
END scale_all;

METHOD default_self;
	time_flight			:=	10 {s};
	max_flight_time			:=	20 {s};
END default_self;

METHOD default_all;
    RUN default_self;
	theta			:=	0.785 ;
	magn_speed		:=	500 {m/s};
	initial_height		:=	10 {m};
	final_height		:=	30 {m};
END default_all		;


END Projectile 		;




MODEL tabulated_Projectile_values;
    	
	
	n_entries "number of Projectiles to simulate"
	    IS_A integer_constant;
	n_entries :== 10;
    	
	theta[1..n_entries] "set of angle for the Projectiles"
	    IS_A angle;
	
        magn_speed[1..n_entries] "initial magnitude of speed of various Projectiles"
	    IS_A speed;

	initial_height	"the initial height"
		IS_A distance;
	
	final_height	"the final height"
		IS_A distance;

    FOR i IN [1..n_entries] CREATE
	p[i] "the i-th Projectile model"
	    IS_A Projectile(theta[i],magn_speed[i] ,
	initial_height,final_height);
    END FOR;



METHODS

METHOD default_self;
END default_self;

METHOD specify;
	RUN p[1..n_entries].specify;
END specify;

METHOD values;
    NOTES 'purpose' SELF {to set up 10 Projectile models having theta )
	ranging from 0.1 to 1}
    END NOTES;
	initial_height := 25 {m};
	final_height   := 5 {m};
	
	FOR i IN [1..n_entries] DO
		theta[i] := i/10.0;
	END FOR;
END values;

METHOD scale_self;
END scale_self;

END tabulated_Projectile_values;

ADD NOTES IN tabulated_Projectile_values;
'description' SELF {This model sets up an array of Projectile to
	   compute a range of magnitude of speed for different range of theta.}
'purpose' SELF {to illustrate the use of arrays in ASCEND}
END NOTES;

Screenshot Of the model on my system:

Bohr Model of an Atom


I have developed a Bohr model of an atom which calculates the following properties of an electron in nth orbit:.

Kinetic Energy/ Potential Energy of an electron in an nth orbit.

Velocity of an electron in an nth orbit.

Quantum of energy to be supplied/released when transition of an electron occurs from energy levels.

Determining the radiation which enables the effective transition.

The model could be enhanced to compare various parameters between the different parameters at the nth orbit.

The code for the model is as follows:

REQUIRE "atoms.a4l";


MODEL Bohr  ;
		(* variables *)
	rn	"the radius of an atom in nth orbit"
		IS_A delta_distance ;
	Z	"Atomic number of an electron"
		IS_A positive_variable;
	n	"orbit in which electron present" 
		IS_A positive_variable ;
	n1,n2   "n1 and n2 are the various orbits between which transition of an atom occurs"
		IS_A positive_variable ;	
	lambda  " wavelength "
		IS_A distance ;
	velocityn "velocity of an atom in nth orbit"
		 IS_A speed ;
	kinetic_energy  "Kinetic, potential and total energy of electron in nth orbit"
		 IS_A energy ;
	potential_energy IS_A energy ;
	total_energy IS_A energy ;
	threshold_energy "energy released or required between transition of electron fron n1th orbit to n2th orbit "
		 IS_A energy ;
 		

		(* equations *)

	rn = n*n * 1{PLANCK_C}^2 * 1{EPSILON0} / (Z* 1{PI} * 1{eMASS} * 1{eCHARGE}^2 ) ;

	velocityn = Z * 1{eCHARGE}^2 /(n*2* 1{EPSILON0} * 1{PLANCK_C})   ;

	kinetic_energy =  (1{eMASS})*(1{eCHARGE}^4)*(Z^2) / ( n^2 * 8 * 1{EPSILON0}^2 * 1{PLANCK_C}^2 )  ;

	total_energy = -kinetic_energy ;

	potential_energy = -2 * kinetic_energy ;
	
	threshold_energy = 1{eMASS}* 1{eCHARGE}^4 * 1{EPSILON0}^-2 * 1{PLANCK_C}^-2 * Z^2 * ( n1^-2  -  n2^-2)/8 ;
	(* if threshold energy positive then enrgy released in terms of radiation if its negative it is required or absorbed*)
	
	lambda = 1{PLANCK_C} * 1{LIGHT_C} / threshold_energy  ;
	

METHODS
	METHOD specify;
	    NOTES
		'purpose' SELF {to fix four variables and make the problem well-posed}
	    END NOTES;
		FIX Z;
		FIX n;
		FIX n1;
		FIX n2;
	END specify;

	
METHOD values;
    NOTES
	'purpose' SELF {to set the values for the fixed variables}
    END NOTES;
	Z		        :=	2;
	n			:=	1 ;
	n1			:=	1 ;
	n2			:=	4 ;
END values;

METHOD bound_self;
END bound_self;

METHOD bound_all;
    RUN bound_self;
END bound_all;

METHOD scale_self;
END scale_self;

METHOD scale_all;
    RUN scale_self;
END scale_all;

METHOD default_self;
	Z 				:=	2 ;
	n				:=	1 ;
END default_self;

METHOD default_all;
    RUN default_self;
	Z		        :=	2;
	n			:=	1 ;
	n1			:=	1 ;
	n2			:=	4 ;
END default_all;


END Bohr ;

The code for the Parameterized version of the model is as follows:

REQUIRE "atoms.a4l";
PROVIDE "BohrTabulated.a4c";

MODEL Bohr(
	Z	"Atomic number of an electron"
		WILL_BE positive_variable;
	n	"orbit in which electron present" 
		WILL_BE positive_variable ;
	n1      "n1 and n2 are the various orbits between which transition of an atom occurs"
		WILL_BE positive_variable ;
	n2      "n1 and n2 are the various orbits between which transition of an atom occurs"
		WILL_BE positive_variable ;
)  ;

			(* variables *)

	lambda  " wavelength "
		IS_A distance ;
	velocityn "velocity of an atom in nth orbit"
		 IS_A speed ;
	kinetic_energy  "Kinetic, potential and total energy of electron in nth orbit"
		 IS_A energy ;
	potential_energy IS_A energy ;
	total_energy IS_A energy ;
	threshold_energy "energy released or required between transition of electron fron n1th orbit to n2th orbit "
		 IS_A energy ;
	rn	"the radius of an atom in nth orbit"
		IS_A delta_distance ;


 		NOTES 'purpose' SELF { Various Equations necessary for the Bohr Model of an atom 
					are described below }
    END NOTES;
		
			(* equations *)
       
	rn = n*n * 1{PLANCK_C}^2 * 1{EPSILON0} / (Z* 1{PI} * 1{eMASS} * 1{eCHARGE}^2 ) ;

	velocityn = Z * 1{eCHARGE}^2 /(n*2* 1{EPSILON0} * 1{PLANCK_C})   ;

	kinetic_energy =  (1{eMASS})*(1{eCHARGE}^4)*(Z^2) / ( n^2 * 8 * 1{EPSILON0}^2 * 1{PLANCK_C}^2 )  ;

	total_energy = -kinetic_energy ;

	potential_energy = -2 * kinetic_energy ;
	
	threshold_energy = 1{eMASS}* 1{eCHARGE}^4 * 1{EPSILON0}^-2 * 1{PLANCK_C}^-2 * Z^2 * ( n1^-2  -  n2^-2)/8 ;
	(* if threshold energy positive then enrgy released in terms of radiation if its negative it is required or absorbed*)
	
	lambda = 1{PLANCK_C} * 1{LIGHT_C} / threshold_energy  ;


METHODS
	METHOD specify;
	    NOTES
		'purpose' SELF {to fix four variables and make the problem well-posed}
	    END NOTES;
		FIX Z;
		FIX n;
		FIX n1;
		FIX n2;
	END specify;

	
METHOD values;
    NOTES
	'purpose' SELF {to set the values for the fixed variables}
    END NOTES;
	Z		        :=	2;
	n			:=	1 ;
	n1			:=	1 ;
	n2			:=	4 ;
END values;

METHOD bound_self;
END bound_self;

METHOD bound_all;
    RUN bound_self;
END bound_all;

METHOD scale_self;
END scale_self;

METHOD scale_all;
    RUN scale_self;
END scale_all;

METHOD default_self;
	Z 				:=	2 ;
	n				:=	1 ;
END default_self;

METHOD default_all;
    RUN default_self;
	Z		        :=	2;
	n			:=	1 ;
	n1			:=	1 ;
	n2			:=	4 ;
END default_all;


END Bohr ;


MODEL tabulated_Bohr_values;
  	
	
	n_entries "number of Bohr atoms to simulate"
	    IS_A integer_constant;
	n_entries :== 10;
    	
	Z[1..n_entries] "set of atomic numbers for the Bohr model of an atom"
	    IS_A positive_variable;
	
        n[1..n_entries] "nth orbit in which electron is present"
	    IS_A positive_variable;

	n1	"the initial orbit in which electron was present"
		IS_A positive_variable;
	
	n2	"the final orbit in which electron transition occured"
		IS_A positive_variable;

    FOR i IN [1..n_entries] CREATE
	b[i] IS_A Bohr(Z[i],n[i],n1,n2);
    END FOR;



METHODS

METHOD default_self;
END default_self;

METHOD specify;
	RUN b[1..n_entries].specify;
END specify;

METHOD values;
    NOTES 'purpose' SELF {to set up 10 Bohr models models having n 
	ranging from 1 to 10}
    END NOTES;
	n1 := 2 ;
	n2 := 4 ;
	
	FOR i IN [1..n_entries] DO
		n[i] := i ;
	END FOR;
END values;

METHOD scale_self;
END scale_self;

END tabulated_Bohr_values ;

ADD NOTES IN tabulated_Projectile_values;
'description' SELF {This model sets up an array of Bohr Model of an atom to
	   compute a range of various parameters for different orbits of an atom.}
'purpose' SELF {to illustrate the use of arrays in ASCEND}
END NOTES;


The Screenshot for the model running on my system are as follows: . .