User:Ujjavalverma10: Difference between revisions
| (18 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
= Bug Fixes and Reports = | |||
== Bug Fix for issue 505 == | |||
I have submitted a patch that adds support for the following 12 functions : | |||
<br /> | |||
<b> Cosec, Sec, Cot </b> <br /> | |||
<b> Cosech, Sech, Coth </b> <br /> | |||
<b> ArcCosec, ArcSec, ArcCot </b> <br /> | |||
<b> ArcCosech, ArcSech, ArcCoth </b> <br /> | |||
The patch can be found at the following link : [http://ascendbugs.cheme.cmu.edu/view.php?id=505 Issue 505] | |||
In addition to this, I have also reported and resolved [http://ascendbugs.cheme.cmu.edu/view.php?id=509 Issue 509] and [http://ascendbugs.cheme.cmu.edu/view.php?id=508 Issue 508] | |||
==Bug Fix for issue 460== | |||
[http://ascendbugs.cheme.cmu.edu/view.php?id=460 Issue 460] reports that the 'Time to build system' value is sometimes inconsistent. I have verified the reproducibility of this bug and also identified its cause. It is due to <i>incorrect printing format</i>. | |||
<br /> | |||
Replacing Line 91 in /ascend/system/system.c file by the following line of code solves the problem. | |||
<source lang="c"> | |||
FPRINTF(stderr,"Time to build system = %.4lf s (outputs zero for very small build time)\n", ((tm_cpu_time() - comptime)>=0.00001)?(tm_cpu_time()-comptime):0); | |||
</source> | |||
== A Proposed solution for issue 459 == | |||
[http://ascendbugs.cheme.cmu.edu/view.php?id=459 Issue 459] demands a way to assign values to a range of array elements. Python invokes <i>__setslice__</i> method when something like " a[1:4] = .. " is used. Thus this task can be accomplished by overriding the <b>__setslice__</b> method of a list object as follows : | |||
<source lang="py"> | |||
class myList(list): | |||
def __setslice__(self, i, j, sequence): | |||
if(isinstance(sequence,list)): | |||
list.__setslice__(self, i, j, sequence) | |||
else: | |||
try: | |||
for x in range(i,j): | |||
self.__setitem__(x,sequence) | |||
except: | |||
print "Unexpected error:", sys.exc_info()[0] | |||
</source> | |||
The use of this class is demonstrated as follows : | |||
<source lang="py"> | |||
a = myList('123456789'); | |||
print a; | |||
a[1:4] = 5; | |||
print a; | |||
</source> | |||
output : <br /> | |||
['1', '2', '3', '4', '5', '6', '7', '8', '9'] <br /> | |||
['1', 5, 5, 5, '5', '6', '7', '8', '9'] | |||
= New Models = | |||
==A simple model for FRUSTUM OF A CONE== | ==A simple model for FRUSTUM OF A CONE== | ||
I am new to the ASCEND language and intend to contribute something to the community through GSOC2011. I wrote a sample model for Frustum Of A Cone | I am new to the ASCEND language and intend to contribute something to the community through GSOC2011. I have prior experience with GUI development and would be applying for projects involving GUI development. I wrote a sample model for Frustum Of A Cone | ||
<source lang="a4c"> | <source lang="a4c"> | ||
| Line 58: | Line 110: | ||
This [[MODEL]] is quite straight forward to write. ASCEND uses strong typing; it requires one to declare explicitly the type of each variable using [[IS_A]] statements. | This [[MODEL]] is quite straight forward to write. ASCEND uses strong typing; it requires one to declare explicitly the type of each variable using [[IS_A]] statements. | ||
[[Image:Incidence.png|thumb|480px|none|Incidence Graph generated by ASCEND for the model of a <tt>frustum of cone.</tt>]] | |||
==Partitioned Model for FRUSTUM OF A CONE== | |||
Following is a modified version of the Frustum [[MODEL]] which breaks down a frustum into two cones : A top cone cut out from a bottom cone. | |||
<source lang="a4c"> | |||
REQUIRE "atoms.a4l"; | |||
MODEL cone; | |||
(* variables *) | |||
R, | |||
h, | |||
l IS_A distance; | |||
curved_area IS_A area; | |||
vol IS_A volume; | |||
(* equations *) | |||
l = sqrt(h^2 + R^2); | |||
vol = 3.1416*h*R^2/3; | |||
curved_area = 3.1416*l*R; | |||
METHODS | |||
METHOD specify; | |||
FIX R; | |||
FIX h; | |||
END specify; | |||
END cone; | |||
MODEL partitioned_frustrum_of_cone; | |||
(* variables *) | |||
R, | |||
r, | |||
h IS_A distance; | |||
l IS_A distance; | |||
curved_area, | |||
total_area IS_A area; | |||
vol IS_A volume; | |||
metal_density IS_A mass_density; | |||
metal_mass IS_A mass; | |||
(* parts *) | |||
top IS_A cone; | |||
bottom IS_A cone; | |||
(* specifications *) | |||
R = 30.0 {cm}; | |||
r = 10.0 {cm}; | |||
h = 50.0 {cm}; | |||
metal_density = 9.60 {g/cm^3}; | |||
(* equations *) | |||
top.R = r; | |||
top.h = r*h/(R-r); | |||
bottom.R = R; | |||
bottom.h = h + top.h; | |||
l = bottom.l - top.l; | |||
vol = bottom.vol - top.vol; | |||
curved_area = bottom.curved_area - top.curved_area; | |||
total_area = 3.1416*(R^2 + r^2) + curved_area; | |||
metal_mass = metal_density*vol; | |||
METHODS | |||
METHOD specify; | |||
FIX R; | |||
FIX r; | |||
FIX h; | |||
FIX metal_density; | |||
END specify; | |||
METHOD values; | |||
R := 30.0 {cm}; | |||
r := 10.0 {cm}; | |||
h := 50.0 {cm}; | |||
metal_density := 9.60 {g/cm^3}; | |||
END values; | |||
METHOD setup; | |||
RUN specify; | |||
RUN values; | |||
END setup; | |||
END partitioned_frustrum_of_cone; | |||
</source> | |||
Latest revision as of 18:48, 19 April 2011
Bug Fixes and Reports
Bug Fix for issue 505
I have submitted a patch that adds support for the following 12 functions :
Cosec, Sec, Cot
Cosech, Sech, Coth
ArcCosec, ArcSec, ArcCot
ArcCosech, ArcSech, ArcCoth
The patch can be found at the following link : Issue 505 In addition to this, I have also reported and resolved Issue 509 and Issue 508
Bug Fix for issue 460
Issue 460 reports that the 'Time to build system' value is sometimes inconsistent. I have verified the reproducibility of this bug and also identified its cause. It is due to incorrect printing format.
Replacing Line 91 in /ascend/system/system.c file by the following line of code solves the problem.
FPRINTF(stderr,"Time to build system = %.4lf s (outputs zero for very small build time)\n", ((tm_cpu_time() - comptime)>=0.00001)?(tm_cpu_time()-comptime):0);
A Proposed solution for issue 459
Issue 459 demands a way to assign values to a range of array elements. Python invokes __setslice__ method when something like " a[1:4] = .. " is used. Thus this task can be accomplished by overriding the __setslice__ method of a list object as follows :
Invalid language.
You need to specify a language like this: <source lang="html">...</source>
Supported languages for syntax highlighting:
a4c, abap, abc, abnf, actionscript, ada, agda, alan, algol, ampl, amtrix, applescript, arc, arm, as400cl, ascend, asciidoc, asp, aspect, assembler, ats, autohotkey, autoit, avenue, awk, ballerina, bat, bbcode, bcpl, bibtex, biferno, bison, blitzbasic, bms, bnf, boo, c, carbon, ceylon, charmm, chill, chpl, clean, clearbasic, clipper, clojure, clp, cmake, cobol, coffeescript, coldfusion, conf, cpp2, critic, crk, crystal, cs_block_regex, csharp, css, d, dart, delphi, diff, dockerfile, dts, dylan, ebnf, ebnf2, eiffel, elixir, elm, email, erb, erlang, euphoria, exapunks, excel, express, factor, fame, fasm, felix, fish, fortran77, fortran90, frink, fsharp, fstab, fx, gambas, gdb, gdscript, go, graphviz, haml, hare, haskell, haxe, hcl, html, httpd, hugo, icon, idl, idlang, inc_luatex, informix, ini, innosetup, interlis, io, jam, jasmin, java, javascript, js_regex, json, jsp, jsx, julia, kotlin, ldif, less, lhs, lilypond, limbo, lindenscript, lisp, logtalk, lotos, lotus, lua, luban, makefile, maple, markdown, matlab, maya, mercury, meson, miranda, mod2, mod3, modelica, moon, ms, msl, mssql, mxml, n3, nasal, nbc, nemerle, netrexx, nginx, nice, nim, nix, nsis, nxc, oberon, objc, ocaml, octave, oorexx, org, os, oz, paradox, pas, pdf, perl, php, pike, pl1, plperl, plpython, pltcl, po, polygen, pony, pov, powershell, pro, progress, ps, psl, pure, purebasic, purescript, pyrex, python, q, qmake, qml, qu, r, rebol, rego, rexx, rnc, rpg, rpl, rst, ruby, rust, s, sam, sas, scad, scala, scilab, scss, shellscript, slim, small, smalltalk, sml, snmp, snobol, solidity, spec, spn, sql, squirrel, styl, svg, swift, sybase, tcl, tcsh, terraform, tex, toml, tsql, tsx, ttcn3, txt, typescript, upc, vala, vb, verilog, vhd, vimscript, vue, wat, whiley, wren, xml, xpp, yaiff, yaml, yaml_ansible, yang, zig, znn
The use of this class is demonstrated as follows :
Invalid language.
You need to specify a language like this: <source lang="html">...</source>
Supported languages for syntax highlighting:
a4c, abap, abc, abnf, actionscript, ada, agda, alan, algol, ampl, amtrix, applescript, arc, arm, as400cl, ascend, asciidoc, asp, aspect, assembler, ats, autohotkey, autoit, avenue, awk, ballerina, bat, bbcode, bcpl, bibtex, biferno, bison, blitzbasic, bms, bnf, boo, c, carbon, ceylon, charmm, chill, chpl, clean, clearbasic, clipper, clojure, clp, cmake, cobol, coffeescript, coldfusion, conf, cpp2, critic, crk, crystal, cs_block_regex, csharp, css, d, dart, delphi, diff, dockerfile, dts, dylan, ebnf, ebnf2, eiffel, elixir, elm, email, erb, erlang, euphoria, exapunks, excel, express, factor, fame, fasm, felix, fish, fortran77, fortran90, frink, fsharp, fstab, fx, gambas, gdb, gdscript, go, graphviz, haml, hare, haskell, haxe, hcl, html, httpd, hugo, icon, idl, idlang, inc_luatex, informix, ini, innosetup, interlis, io, jam, jasmin, java, javascript, js_regex, json, jsp, jsx, julia, kotlin, ldif, less, lhs, lilypond, limbo, lindenscript, lisp, logtalk, lotos, lotus, lua, luban, makefile, maple, markdown, matlab, maya, mercury, meson, miranda, mod2, mod3, modelica, moon, ms, msl, mssql, mxml, n3, nasal, nbc, nemerle, netrexx, nginx, nice, nim, nix, nsis, nxc, oberon, objc, ocaml, octave, oorexx, org, os, oz, paradox, pas, pdf, perl, php, pike, pl1, plperl, plpython, pltcl, po, polygen, pony, pov, powershell, pro, progress, ps, psl, pure, purebasic, purescript, pyrex, python, q, qmake, qml, qu, r, rebol, rego, rexx, rnc, rpg, rpl, rst, ruby, rust, s, sam, sas, scad, scala, scilab, scss, shellscript, slim, small, smalltalk, sml, snmp, snobol, solidity, spec, spn, sql, squirrel, styl, svg, swift, sybase, tcl, tcsh, terraform, tex, toml, tsql, tsx, ttcn3, txt, typescript, upc, vala, vb, verilog, vhd, vimscript, vue, wat, whiley, wren, xml, xpp, yaiff, yaml, yaml_ansible, yang, zig, znn
output :
['1', '2', '3', '4', '5', '6', '7', '8', '9']
['1', 5, 5, 5, '5', '6', '7', '8', '9']
New Models
A simple model for FRUSTUM OF A CONE
I am new to the ASCEND language and intend to contribute something to the community through GSOC2011. I have prior experience with GUI development and would be applying for projects involving GUI development. I wrote a sample model for Frustum Of A Cone
REQUIRE "system.a4l"; MODEL frustrum_of_cone; (* variables *) R, h, r, l, metal_density, curved_area, total_area, vol, metal_mass IS_A solver_var; (* specifications *) R = 30.0; r = 10.0; h = 50.0; metal_density = 9.60; (* equations *) l = sqrt(h^2 + (R-r)^2); vol = 3.1416*h*(R^2 + r^2 + r*R)/3; curved_area = 3.1416*l*(R+r); total_area = 3.1416*(R^2 + r^2) + curved_area; metal_mass = metal_density*vol; METHODS METHOD specify; FIX R; FIX r; FIX h; FIX metal_density; END specify; METHOD values; R := 30.0 ; r := 10.0; h := 50.0; metal_density := 9.60 ; END values; METHOD setup; RUN specify; RUN values; END setup; END frustrum_of_cone;
This MODEL is quite straight forward to write. ASCEND uses strong typing; it requires one to declare explicitly the type of each variable using IS_A statements.
Partitioned Model for FRUSTUM OF A CONE
Following is a modified version of the Frustum MODEL which breaks down a frustum into two cones : A top cone cut out from a bottom cone.
REQUIRE "atoms.a4l"; MODEL cone; (* variables *) R, h, l IS_A distance; curved_area IS_A area; vol IS_A volume; (* equations *) l = sqrt(h^2 + R^2); vol = 3.1416*h*R^2/3; curved_area = 3.1416*l*R; METHODS METHOD specify; FIX R; FIX h; END specify; END cone; MODEL partitioned_frustrum_of_cone; (* variables *) R, r, h IS_A distance; l IS_A distance; curved_area, total_area IS_A area; vol IS_A volume; metal_density IS_A mass_density; metal_mass IS_A mass; (* parts *) top IS_A cone; bottom IS_A cone; (* specifications *) R = 30.0 {cm}; r = 10.0 {cm}; h = 50.0 {cm}; metal_density = 9.60 {g/cm^3}; (* equations *) top.R = r; top.h = r*h/(R-r); bottom.R = R; bottom.h = h + top.h; l = bottom.l - top.l; vol = bottom.vol - top.vol; curved_area = bottom.curved_area - top.curved_area; total_area = 3.1416*(R^2 + r^2) + curved_area; metal_mass = metal_density*vol; METHODS METHOD specify; FIX R; FIX r; FIX h; FIX metal_density; END specify; METHOD values; R := 30.0 {cm}; r := 10.0 {cm}; h := 50.0 {cm}; metal_density := 9.60 {g/cm^3}; END values; METHOD setup; RUN specify; RUN values; END setup; END partitioned_frustrum_of_cone;