<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ascend4.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=BenAllan</id>
	<title>ASCEND - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://ascend4.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=BenAllan"/>
	<link rel="alternate" type="text/html" href="https://ascend4.org/Special:Contributions/BenAllan"/>
	<updated>2026-04-28T20:53:09Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.6</generator>
	<entry>
		<id>https://ascend4.org/index.php?title=Global_variables&amp;diff=3823</id>
		<title>Global variables</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Global_variables&amp;diff=3823"/>
		<updated>2012-07-06T18:41:02Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: /* The object lives in ascend, and a design for global use reduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{task}}&lt;br /&gt;
&lt;br /&gt;
We would like to get rid of the current use of global variables in ASCEND, so that we can start to think about using ASCEND in multithreaded and/or embedded ways. This page will report any cases of global variables that we have found, and perhaps some discussion about how we can best eliminate them. Not all cases will be the same. Globals make some aspects of code reading easier (not crowding C arg lists with context pointers) and some harder: when complex side effects are in play. We try hard to avoid any usage of globals with complex side effects.&lt;br /&gt;
&lt;br /&gt;
== Ways for removing global variables ==&lt;br /&gt;
&lt;br /&gt;
A number of options exist:&lt;br /&gt;
&lt;br /&gt;
* keeping them. This is appropriate in a very limited set of situations, such as for data that has been loaded from a configuration file when the program started.&lt;br /&gt;
* groupin them into a top-level data structure. We imagine structures like &amp;quot;library&amp;quot;, &amp;quot;simulation&amp;quot; and &amp;quot;system&amp;quot; could be created that could hold most global variables.&lt;br /&gt;
* passing them. Where global variables have been used as a convenience to avoid having to expand function parameter lists, we can just change to passing them as parameters.&lt;br /&gt;
* converting them to #defines. May be appropriate for certain constants.&lt;br /&gt;
* converting them to thread-local variables (may need to assess implication for embedded applications)&lt;br /&gt;
* adding mutex constraints (so that they can only be accessed once at a time)&lt;br /&gt;
* migrating them to another code layer, eg into the GUI (this has already been done in some cases)&lt;br /&gt;
&lt;br /&gt;
== Particular kinds of usage and what can be done about it ==&lt;br /&gt;
&lt;br /&gt;
* Lex/Yacc C based scanners and parsers (and some still current versions of GNU bison/flex) generate code full of globals and non-threadsafe functions. It&#039;s not our job to fix this. The &#039;safe&#039; thing to do is put a mutex around the parse function.&lt;br /&gt;
* ASCEND defined parser context flags, once properly identified, can remain global because the mutex for yacc will also protect them. Cosmetically, the &#039;properly identified&#039; problem could be resolved by collecting these variables into a single well-named struct g_parser_context.&lt;br /&gt;
* Type library globals: most of these should be moved into a formal struct ascUniverse. More about that below.&lt;br /&gt;
* Instantiator tuning: most of these should be moved into a struct ascCompilerTuning.&lt;br /&gt;
* Memory recycle pools of small objects, tied to globals. These are tied to globals (typically file-scope static variables hidden behind allocator functions) to avoid passing pool pointers everywhere. In solvers like linsolqr, these pools should be tied to major objects instead of file global. &amp;quot;Too many pool objects, too short lived&amp;quot; is a problem that can be solved (taking mtx as an example, perhaps) by maintaining a list of idle mtx element pools; when to clear the idle pools is a minor problem. In the compiler, many pools should come and go with their Universe or with the destruction of the ascend type list and all dependent instances.&lt;br /&gt;
&lt;br /&gt;
== The object lives in ascend, and a design for global use reduction ==&lt;br /&gt;
The most basic facts: ascend parses a set of type definitions into a self-consistent class hierarchy. These type definitions can then be used with the instantiator to create model instances with relation and variable data. These instance objects answer many queries by accessing pointers to the type definitions used to create the objects. ASCEND has a concept named UNIVERSAL (not unlike globals in C) whereby for a given type definition, only one instance will ever be constructed. Both types and instances are deeply tied to a symbol (constant strings) table. Throughout ascend, both types and symbols are heavily compared for identity by comparing pointers.&lt;br /&gt;
&lt;br /&gt;
Key outcome of the above: if we wrap all the compiler globals in a context object of universal scope, we can then have at a higher (scripting) level multiple universe objects. **Objects from distinct universes cannot be compared except in string form** !&lt;br /&gt;
 &lt;br /&gt;
Given the above, then, ascend model type and instance data can be organized into something like the following. I will use c++ notation, but the implementation will be C. When in the parser, a single global (the universe pointer for the parsing to operate within) is needed and a mutex.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
class ascUniverse {&lt;br /&gt;
public:&lt;br /&gt;
// functions only&lt;br /&gt;
private:&lt;br /&gt;
int auid; // serial number of this universe&lt;br /&gt;
struct ascUniverse *next;&lt;br /&gt;
// struct Symtab symtab;&lt;br /&gt;
// memory pools for statement, vlist, etc, etc&lt;br /&gt;
// struct Simlist simlist;&lt;br /&gt;
// struct Library library&lt;br /&gt;
// etc&lt;br /&gt;
static struct ascUniverse * g_universe_list;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Many parts within the compiler will need only a pointer to the piece of the universe where their data lives; we should not be passing universe pointers everywhere in the compiler. Implementing all this correctly as a refactorization is extremely tedious and should only be done with a test suite and automated refactoring tools.&lt;br /&gt;
&lt;br /&gt;
== Global variables in libascend.so ==&lt;br /&gt;
&lt;br /&gt;
The main place where global variables are a problem for ASCEND is in &amp;lt;tt&amp;gt;libascend&amp;lt;/tt&amp;gt;, our core library include the ASCEND parser/compiler and evaluation routines, but &#039;&#039;&#039;hopefully&#039;&#039;&#039; excluding the solvers.&lt;br /&gt;
&lt;br /&gt;
Below is a list of globals generated using GNU &amp;lt;tt&amp;gt;nm&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;john@thunder:~/ascend$ nm libascend.so  | grep -i &amp;quot; [DdGgSsBb] &amp;quot;;&lt;br /&gt;
001828a0 b AllowedContents&lt;br /&gt;
00926420 b BracesNestLevel&lt;br /&gt;
0092889c b CmpEv&lt;br /&gt;
0092641c b CommentNestLevel&lt;br /&gt;
00180be0 d DimNames&lt;br /&gt;
00927ac8 b EvaluatingSets&lt;br /&gt;
00926548 b FundamentalTypeList&lt;br /&gt;
00928528 b GlobalUniversalTable&lt;br /&gt;
00927c14 b InterfaceNotify&lt;br /&gt;
00927c0c b InterfacePtrATS&lt;br /&gt;
00927c10 b InterfacePtrDelete&lt;br /&gt;
00928790 b L.6247&lt;br /&gt;
0092879c b L.6717&lt;br /&gt;
0092bca0 b LibraryHashTable&lt;br /&gt;
00927ac4 b ListMode&lt;br /&gt;
00926424 b MatchedBackslash&lt;br /&gt;
00927a64 b MinusOne&lt;br /&gt;
00927a84 b One&lt;br /&gt;
001820c0 b RecycledContents&lt;br /&gt;
001818e0 b RecycledList&lt;br /&gt;
00926428 b RequireIndex&lt;br /&gt;
00926460 b RequireStack&lt;br /&gt;
009286e0 B Solv_C_CheckHalt_Flag&lt;br /&gt;
00927aa4 b Three&lt;br /&gt;
00927a94 b Two&lt;br /&gt;
001816a0 d VpTable&lt;br /&gt;
009300dc b X&lt;br /&gt;
00927a74 b Zero&lt;br /&gt;
0017fcc0 d __CTOR_END__&lt;br /&gt;
0017fcbc d __CTOR_LIST__&lt;br /&gt;
0017fcc8 d __DTOR_END__&lt;br /&gt;
0017fcc4 d __DTOR_LIST__&lt;br /&gt;
0017fccc d __JCR_END__&lt;br /&gt;
0017fccc d __JCR_LIST__&lt;br /&gt;
00180a20 d __dso_handle&lt;br /&gt;
00181811 d blockend&lt;br /&gt;
001817fc d blockmagic&lt;br /&gt;
001814fc D calc_ok&lt;br /&gt;
00181500 d calc_print_errors&lt;br /&gt;
00928338 b cap.11161&lt;br /&gt;
009286d8 b cap.7377&lt;br /&gt;
00181520 d commands&lt;br /&gt;
001818a0 b completed.6625&lt;br /&gt;
009300e0 b conopt_fptrs&lt;br /&gt;
00927a54 b constants_inited&lt;br /&gt;
001817d0 d csdata&lt;br /&gt;
00183088 b dcps.2434&lt;br /&gt;
00926488 b default_library_path.7912&lt;br /&gt;
0092648c b default_solvers_path.7911&lt;br /&gt;
0018167c d defaultintegrators.6720&lt;br /&gt;
00927a60 b deriv_store.5961&lt;br /&gt;
00926564 b done.4160&lt;br /&gt;
00183090 b dref.2433&lt;br /&gt;
00927c80 b ds.3670&lt;br /&gt;
00927d60 b ds.4078&lt;br /&gt;
00928540 b ds.4252&lt;br /&gt;
00928060 b ds.4837&lt;br /&gt;
00928140 b ds.5578&lt;br /&gt;
001818a4 b dtor_idx.6627&lt;br /&gt;
009287c8 b elt.4095&lt;br /&gt;
009287cc b elt.4148&lt;br /&gt;
00926430 b errcount.6732&lt;br /&gt;
009263a4 b errcount.8155&lt;br /&gt;
00181670 d errname.6760&lt;br /&gt;
00928384 b error_statement_sym.4928&lt;br /&gt;
00928800 b exception_buffer&lt;br /&gt;
009287e0 b exception_status&lt;br /&gt;
00180a24 d f_first&lt;br /&gt;
00180a28 d f_fpe_top_of_stack&lt;br /&gt;
00926364 b f_fpe_traps&lt;br /&gt;
00180a2c d f_int_top_of_stack&lt;br /&gt;
00926368 b f_int_traps&lt;br /&gt;
001830e0 b f_mem_rec&lt;br /&gt;
001830c8 b f_memory_allocated&lt;br /&gt;
001830c4 b f_memory_length&lt;br /&gt;
001830c0 b f_memory_log_file&lt;br /&gt;
009242e0 b f_panic_callback_func&lt;br /&gt;
001830cc b f_peak_memory_usage&lt;br /&gt;
00180a30 d f_seg_top_of_stack&lt;br /&gt;
0092636c b f_seg_traps&lt;br /&gt;
00925300 b g_Asc_printVtables&lt;br /&gt;
00927acc b g_DeclarativeContext&lt;br /&gt;
00181320 d g_DefinitionErrorMessages&lt;br /&gt;
00927abc b g_EvaluationContext&lt;br /&gt;
00927ac0 b g_EvaluationForTable&lt;br /&gt;
00927ab8 b g_ExtVariablesTable&lt;br /&gt;
00927ab4 b g_ExternalFuncLibrary&lt;br /&gt;
00928018 b g_ExternalNodeStamps&lt;br /&gt;
00180e60 d g_abs_f&lt;br /&gt;
001812b0 D g_alt_ending&lt;br /&gt;
00926490 b g_ammarking&lt;br /&gt;
00180f20 d g_arccos_f&lt;br /&gt;
001810a0 d g_arccosh_f&lt;br /&gt;
00180ee0 d g_arcsin_f&lt;br /&gt;
00181060 d g_arcsinh_f&lt;br /&gt;
00180f60 d g_arctan_f&lt;br /&gt;
001810e0 d g_arctanh_f&lt;br /&gt;
00926494 b g_array_child_pool&lt;br /&gt;
00928444 b g_array_desc_count&lt;br /&gt;
00928448 b g_array_desc_list&lt;br /&gt;
0018309c b g_ascend_dllist&lt;br /&gt;
009264c0 b g_atom_bytes&lt;br /&gt;
009263b0 b g_atom_dim_ptr&lt;br /&gt;
0092bc50 b g_b_inst&lt;br /&gt;
0018187c d g_ba_elimdata&lt;br /&gt;
0092bc6c b g_ba_inst&lt;br /&gt;
0092863c b g_bad_rel_in_list&lt;br /&gt;
0092bc7c b g_bc_inst&lt;br /&gt;
00928434 b g_big_strings&lt;br /&gt;
00928438 b g_big_strings_cnt&lt;br /&gt;
00928640 b g_blockmethod&lt;br /&gt;
00180a60 d g_bt_data&lt;br /&gt;
00926398 b g_callargs&lt;br /&gt;
0092864c b g_case_number&lt;br /&gt;
00928030 b g_cbbccount&lt;br /&gt;
0092802c b g_cbbdcount&lt;br /&gt;
00181160 d g_cbrt_f&lt;br /&gt;
001812ec D g_check_dimensions_noisy&lt;br /&gt;
00926514 b g_clique_list&lt;br /&gt;
00181208 D g_compiler_counter&lt;br /&gt;
00928360 B g_compiler_timing&lt;br /&gt;
00180a34 D g_compiler_warnings&lt;br /&gt;
0092649c b g_cons&lt;br /&gt;
009263a0 b g_constant_type&lt;br /&gt;
009279d4 b g_copy_numnodes&lt;br /&gt;
00180d60 d g_cos_f&lt;br /&gt;
00180fe0 d g_cosh_f&lt;br /&gt;
00181120 d g_cube_f&lt;br /&gt;
00927f54 b g_current_module&lt;br /&gt;
0092bc48 b g_cursim&lt;br /&gt;
00926544 b g_def_child_bit_list&lt;br /&gt;
00926540 b g_def_child_desc_ptr&lt;br /&gt;
0092653c b g_def_child_list_ptr&lt;br /&gt;
009263b4 b g_default_dim_ptr&lt;br /&gt;
009263b8 b g_default_double&lt;br /&gt;
009263c0 b g_default_long&lt;br /&gt;
00928b4c b g_default_symbol&lt;br /&gt;
009263a8 b g_defaulted&lt;br /&gt;
00926534 b g_diagf&lt;br /&gt;
009263ac b g_dim_ptr&lt;br /&gt;
0092ac38 B g_dimen_list&lt;br /&gt;
0092ac30 b g_dimensionless&lt;br /&gt;
009286b4 b g_dis_tag&lt;br /&gt;
009284c0 b g_drt_depth&lt;br /&gt;
00927c28 b g_dummy_type&lt;br /&gt;
0092ac40 b g_dump_ht&lt;br /&gt;
0092bc40 b g_dump_inst_count&lt;br /&gt;
0092bc44 b g_dump_type_count&lt;br /&gt;
00926384 b g_end_identifier&lt;br /&gt;
001830a0 b g_env_list&lt;br /&gt;
00925340 b g_error_reporter_cache&lt;br /&gt;
00925328 b g_error_reporter_callback&lt;br /&gt;
00925320 b g_error_reporter_tree&lt;br /&gt;
00925324 b g_error_reporter_tree_current&lt;br /&gt;
00180c20 d g_exp_f&lt;br /&gt;
00927a50 b g_exprs_pool&lt;br /&gt;
00927c34 b g_externalmodel_type&lt;br /&gt;
009264fc b g_extra_parents&lt;br /&gt;
00926500 b g_extra_parents_sum&lt;br /&gt;
009264f8 b g_extra_paths&lt;br /&gt;
009288a0 b g_foreign_code_call_env&lt;br /&gt;
00927ad0 b g_forvar_recycle_list&lt;br /&gt;
00927ad4 b g_forvarfile&lt;br /&gt;
009289e0 B g_fpe_env&lt;br /&gt;
00927ad8 b g_free_store&lt;br /&gt;
001811a0 d g_func_list&lt;br /&gt;
00926370 b g_header_linenum&lt;br /&gt;
00180ea0 d g_hold_f&lt;br /&gt;
0092bc5c b g_i_inst&lt;br /&gt;
0092bc74 b g_ia_inst&lt;br /&gt;
0092bc60 b g_ic_inst&lt;br /&gt;
0017fce0 d g_instancetypenames&lt;br /&gt;
0018120c d g_instantiate_relns&lt;br /&gt;
00928a80 B g_int_env&lt;br /&gt;
001814f8 d g_iscomplete&lt;br /&gt;
0092844c b g_it_dummy_enum&lt;br /&gt;
00181310 d g_it_dummy_int&lt;br /&gt;
00927c00 b g_iteration&lt;br /&gt;
009284a8 b g_lcl_head&lt;br /&gt;
009284b8 b g_lcl_length&lt;br /&gt;
009284b4 b g_lcl_pivot&lt;br /&gt;
009284b0 b g_lcl_recycle&lt;br /&gt;
009284ac b g_lcl_tail&lt;br /&gt;
009284bc b g_lclrecycle_length&lt;br /&gt;
00181740 D g_linsolqr_timing&lt;br /&gt;
001818c0 b g_list_head_pool&lt;br /&gt;
00180c60 d g_ln_f&lt;br /&gt;
00180c08 D g_lnm_epsilon&lt;br /&gt;
00180ca0 d g_lnm_f&lt;br /&gt;
00180ce0 d g_log10_f&lt;br /&gt;
00927e40 b g_log_shortbuf&lt;br /&gt;
00927d54 b g_logrel_stack&lt;br /&gt;
00927c24 b g_logrel_type&lt;br /&gt;
00927f44 b g_logrelation_bvar_list&lt;br /&gt;
00927f48 b g_logrelation_satrel_list&lt;br /&gt;
00927f50 b g_logterm_pool&lt;br /&gt;
00181288 d g_logterm_ptrs&lt;br /&gt;
00927e34 b g_logwritfp&lt;br /&gt;
0092bc54 b g_lrel_inst&lt;br /&gt;
0092650c b g_maximum_children&lt;br /&gt;
009264f4 b g_maximum_parents&lt;br /&gt;
00926520 b g_maximum_relations&lt;br /&gt;
00926508 b g_minimum_children&lt;br /&gt;
009264f0 b g_minimum_parents&lt;br /&gt;
0092651c b g_minimum_relations&lt;br /&gt;
00926560 b g_missing&lt;br /&gt;
0092bc88 b g_mod_inst&lt;br /&gt;
009264b8 b g_model_bytes&lt;br /&gt;
00928000 b g_model_definition_methods&lt;br /&gt;
00926388 b g_model_parameters&lt;br /&gt;
00927f5c b g_module_list&lt;br /&gt;
00181220 d g_mpi_message&lt;br /&gt;
009287c4 b g_mtx_debug_redirect&lt;br /&gt;
0018185c d g_mtx_null_col_vector_data&lt;br /&gt;
0018181c d g_mtx_null_index_data&lt;br /&gt;
0018183c d g_mtx_null_mark_data&lt;br /&gt;
0018186c d g_mtx_null_row_vector_data&lt;br /&gt;
0018182c d g_mtx_null_sum_data&lt;br /&gt;
0018184c d g_mtx_null_vector_data&lt;br /&gt;
009301b4 b g_mtxerr&lt;br /&gt;
00927f6c b g_name_pool&lt;br /&gt;
009279e0 b g_names_needed&lt;br /&gt;
00927a58 b g_new_var_list&lt;br /&gt;
0092639c b g_notelist&lt;br /&gt;
00927f70 b g_notes_data_base&lt;br /&gt;
009264e8 b g_num_array_instances&lt;br /&gt;
009264dc b g_num_atom_children&lt;br /&gt;
009264bc b g_num_atom_instances&lt;br /&gt;
009264b0 b g_num_complex_instances&lt;br /&gt;
009264d8 b g_num_constant_all&lt;br /&gt;
009264cc b g_num_constant_bool&lt;br /&gt;
009264d0 b g_num_constant_int&lt;br /&gt;
009264c8 b g_num_constant_real&lt;br /&gt;
009264d4 b g_num_constant_sym&lt;br /&gt;
009264b4 b g_num_model_instances&lt;br /&gt;
00927f64 b g_num_names_cur&lt;br /&gt;
00927f68 b g_num_names_max&lt;br /&gt;
009264e0 b g_num_relation_instances&lt;br /&gt;
009264ec b g_num_unsel_instances&lt;br /&gt;
009284a4 b g_number&lt;br /&gt;
00927f90 b g_numlist_head_pool&lt;br /&gt;
00924300 b g_panic_outfile&lt;br /&gt;
00926390 b g_parameter_reduction&lt;br /&gt;
0092638c b g_parameter_wheres&lt;br /&gt;
0018130c d g_parse_count&lt;br /&gt;
00180a38 d g_parse_relns&lt;br /&gt;
009284c4 B g_parser_warnings&lt;br /&gt;
00927f9c b g_pending_count&lt;br /&gt;
00927fa0 b g_pending_list&lt;br /&gt;
00927fa4 b g_pending_list_end&lt;br /&gt;
00927fa8 b g_pending_pool&lt;br /&gt;
0092cca0 B g_plot_type&lt;br /&gt;
00927f94 b g_ppe_pool&lt;br /&gt;
001811fc d g_proc&lt;br /&gt;
00926378 b g_proc_name&lt;br /&gt;
00928004 b g_procframe_stop&lt;br /&gt;
00928008 b g_proto_count&lt;br /&gt;
0092ccc0 b g_proto_ht&lt;br /&gt;
0092bc94 b g_r_inst&lt;br /&gt;
0092bc78 b g_ra_inst&lt;br /&gt;
0092bc64 b g_rc_inst&lt;br /&gt;
00927a00 b g_recycle_expreval_stacks&lt;br /&gt;
00927f84 b g_recycled_npl&lt;br /&gt;
00926380 b g_refines_name&lt;br /&gt;
0092bc84 b g_rel_inst&lt;br /&gt;
00928040 b g_rel_stack&lt;br /&gt;
00928044 b g_rel_stack_pool&lt;br /&gt;
009264e4 b g_relation_guts&lt;br /&gt;
0092652c b g_relation_terms&lt;br /&gt;
00927c20 b g_relation_type&lt;br /&gt;
00928014 b g_relation_var_list&lt;br /&gt;
00928010 B g_relative_inst&lt;br /&gt;
00928618 b g_reuse&lt;br /&gt;
009286c4 b g_reuse&lt;br /&gt;
0092bc58 b g_s_inst&lt;br /&gt;
0092bc80 b g_sa_inst&lt;br /&gt;
0092bc90 b g_sc_inst&lt;br /&gt;
0092800c B g_search_inst&lt;br /&gt;
00928940 B g_seg_env&lt;br /&gt;
00928354 b g_set_pool&lt;br /&gt;
00927c30 b g_set_type&lt;br /&gt;
00928358 b g_sets_pool&lt;br /&gt;
00928220 b g_shortbuf&lt;br /&gt;
001812f4 d g_show_statement_detail&lt;br /&gt;
00927f4c b g_simplify_logrelations&lt;br /&gt;
001812cc D g_simplify_relations&lt;br /&gt;
0092835c B g_simulation_list&lt;br /&gt;
00180d20 d g_sin_f&lt;br /&gt;
00180fa0 d g_sinh_f&lt;br /&gt;
00927f60 b g_sldestroy&lt;br /&gt;
0092877c b g_solver_binary_type&lt;br /&gt;
009286c0 b g_solver_dis_type&lt;br /&gt;
00928778 b g_solver_int_type&lt;br /&gt;
00928780 b g_solver_semi_type&lt;br /&gt;
00928774 b g_solver_var_type&lt;br /&gt;
00180de0 d g_sqr_f&lt;br /&gt;
00180e20 d g_sqrt_f&lt;br /&gt;
00928414 b g_statio_flowtypenames&lt;br /&gt;
001812f8 d g_statio_label&lt;br /&gt;
009283a0 b g_statio_stattypenames&lt;br /&gt;
00928380 b g_statio_suppressions&lt;br /&gt;
00927b00 b g_string_buffer&lt;br /&gt;
00927f58 b g_string_modules_processed&lt;br /&gt;
00928428 b g_string_space&lt;br /&gt;
00927fc0 b g_strings&lt;br /&gt;
00928624 b g_strings&lt;br /&gt;
009286b8 b g_strings&lt;br /&gt;
009286d0 b g_strings&lt;br /&gt;
009286d4 b g_strings&lt;br /&gt;
00928758 b g_strings&lt;br /&gt;
00926498 b g_suppressions&lt;br /&gt;
0092bc8c b g_sym_inst&lt;br /&gt;
0092bc4c b g_syma_inst&lt;br /&gt;
00928430 b g_symbol_collisions&lt;br /&gt;
0092842c b g_symbol_size&lt;br /&gt;
0092dcc0 b g_symbol_table&lt;br /&gt;
00928614 b g_symbol_values_list&lt;br /&gt;
00927c40 b g_symbols&lt;br /&gt;
00928460 b g_symbols&lt;br /&gt;
009287ac b g_symbols&lt;br /&gt;
0092bc68 b g_symc_inst&lt;br /&gt;
00180da0 d g_tan_f&lt;br /&gt;
00181020 d g_tanh_f&lt;br /&gt;
0092843c b g_temporary_var_list&lt;br /&gt;
00928440 b g_temporary_var_recycle&lt;br /&gt;
0092801c b g_term_pool&lt;br /&gt;
001812d0 d g_term_ptrs&lt;br /&gt;
009284c8 b g_tlibs_depth&lt;br /&gt;
0092ab80 b g_token_counts&lt;br /&gt;
00926530 b g_total_array_children&lt;br /&gt;
00926510 b g_total_children&lt;br /&gt;
00926504 b g_total_parents&lt;br /&gt;
00926528 b g_total_reals_in_rels&lt;br /&gt;
00926524 b g_total_relations&lt;br /&gt;
00926518 b g_total_variables&lt;br /&gt;
009264c4 b g_tree_bytes&lt;br /&gt;
0092ac34 b g_trig_dimen&lt;br /&gt;
00927c04 b g_trychildexpansion_errmessage&lt;br /&gt;
009264ac b g_type_count_list&lt;br /&gt;
0092637c b g_type_name&lt;br /&gt;
00926394 b g_typeargs&lt;br /&gt;
00927c08 b g_unasscon_count&lt;br /&gt;
00928500 b g_unit_base_name&lt;br /&gt;
009284f0 b g_unit_explain_error_strings&lt;br /&gt;
00927adc b g_units_alloc&lt;br /&gt;
009284ec b g_units_collisions&lt;br /&gt;
001814c0 d g_units_errors.4640&lt;br /&gt;
0092f0e0 B g_units_hash_table&lt;br /&gt;
0092ecc0 b g_units_id_space&lt;br /&gt;
009263c4 b g_units_ptr&lt;br /&gt;
009284e8 b g_units_size&lt;br /&gt;
009284e0 b g_units_str&lt;br /&gt;
009284e4 b g_units_str_len&lt;br /&gt;
00927f98 b g_unresolved_count&lt;br /&gt;
00926374 b g_untrapped_error&lt;br /&gt;
00181204 D g_use_copyanon&lt;br /&gt;
0092852c b g_value_pool&lt;br /&gt;
00928754 b g_var_tag&lt;br /&gt;
0092bc70 b g_when_inst&lt;br /&gt;
00927c2c b g_when_type&lt;br /&gt;
0092ac3c b g_wild_dimen&lt;br /&gt;
0092642c b g_workbuf&lt;br /&gt;
00180a44 d g_workbuf_len.6555&lt;br /&gt;
00928214 b g_writfp&lt;br /&gt;
00928348 b glob_done&lt;br /&gt;
00927f40 b glob_lrel&lt;br /&gt;
00928340 b glob_rel&lt;br /&gt;
00928344 b glob_varnum&lt;br /&gt;
009279d0 b global_command_list&lt;br /&gt;
00928530 b global_visit_num&lt;br /&gt;
009287bc b hhrowlist.6528&lt;br /&gt;
00183074 b i.2578&lt;br /&gt;
00926354 b i.2755&lt;br /&gt;
00927ae0 b importhandler_library&lt;br /&gt;
00927ae4 b importhandler_sharedpointers&lt;br /&gt;
00926538 b init.5484&lt;br /&gt;
00928794 b init.6246&lt;br /&gt;
009287a0 b init.6716&lt;br /&gt;
0092878c b inst&lt;br /&gt;
009287c0 b last_value_matrix&lt;br /&gt;
00928798 b lastsolver.6445&lt;br /&gt;
00928330 b lhscap.9848&lt;br /&gt;
009287b8 b listlen.6529&lt;br /&gt;
00928784 b loaded.3887&lt;br /&gt;
00180ba0 d metadata.4158&lt;br /&gt;
001817e0 d mtxmagic&lt;br /&gt;
00928700 b name.6123&lt;br /&gt;
00928660 b name.6164&lt;br /&gt;
00181744 d names.4315&lt;br /&gt;
00181760 d names.4320&lt;br /&gt;
0018307c b newsize.2576&lt;br /&gt;
0092635c b newsize.2753&lt;br /&gt;
00181504 d nextid.6241&lt;br /&gt;
001812c8 d nostr.4857&lt;br /&gt;
00181688 d nrels.7185&lt;br /&gt;
0018168c d nrels.7199&lt;br /&gt;
009286fc b nuldev.5971&lt;br /&gt;
00181690 d nvars.7213&lt;br /&gt;
00183080 b oldsize.2575&lt;br /&gt;
00926360 b oldsize.2752&lt;br /&gt;
001817f2 d permmagic&lt;br /&gt;
00928648 b poly.3808&lt;br /&gt;
00928350 b poly.3924&lt;br /&gt;
00928644 b poly_cap.3809&lt;br /&gt;
0092834c b poly_cap.3925&lt;br /&gt;
00927a5c b previous_store.5962&lt;br /&gt;
0092833c b ptr.11160&lt;br /&gt;
009286dc b ptr.7376&lt;br /&gt;
00183078 b punt.2577&lt;br /&gt;
00926358 b punt.2754&lt;br /&gt;
00183098 b ref.2432&lt;br /&gt;
00928334 b rel.9847&lt;br /&gt;
009287a4 b reported_already.8633&lt;br /&gt;
009287a8 b reported_already.8653&lt;br /&gt;
00926580 b result.4159&lt;br /&gt;
009286e4 b rfilter.7742&lt;br /&gt;
0092832c b rhscap.9849&lt;br /&gt;
001817c0 d rsdata&lt;br /&gt;
001812f0 d safe_print_errors&lt;br /&gt;
0017fda0 d slv_reg&lt;br /&gt;
00928320 b soln_list.9691&lt;br /&gt;
00926418 b start_line&lt;br /&gt;
00928534 b stopnum.3912&lt;br /&gt;
00181508 d suppress_rel_flag.6780&lt;br /&gt;
00928788 b sys&lt;br /&gt;
001812a4 d unk.4785&lt;br /&gt;
00925304 b use_xterm_color.2533&lt;br /&gt;
009286ec b vfilter.7802&lt;br /&gt;
009286f4 b vfilter.7892&lt;br /&gt;
00928020 b warnexpt.5603&lt;br /&gt;
00928028 b warnexpt.5731&lt;br /&gt;
00928024 b warnfdiff.5732&lt;br /&gt;
009263f4 b yy_buffer_stack&lt;br /&gt;
009263f0 b yy_buffer_stack_max&lt;br /&gt;
009263ec b yy_buffer_stack_top&lt;br /&gt;
009263f8 b yy_c_buf_p&lt;br /&gt;
0092643c b yy_did_buffer_switch_on_eof&lt;br /&gt;
00926448 b yy_full_lp&lt;br /&gt;
00926440 b yy_full_match&lt;br /&gt;
0092644c b yy_full_state&lt;br /&gt;
00926434 b yy_hold_char&lt;br /&gt;
009263fc b yy_init&lt;br /&gt;
00180a40 d yy_line&lt;br /&gt;
0092640c b yy_looking_for_trail_begin&lt;br /&gt;
00926444 b yy_lp&lt;br /&gt;
00926410 b yy_more_offset&lt;br /&gt;
00926438 b yy_n_chars&lt;br /&gt;
00926414 b yy_prev_more_offset&lt;br /&gt;
00926400 b yy_start&lt;br /&gt;
00926404 b yy_state_buf&lt;br /&gt;
00926408 b yy_state_ptr&lt;br /&gt;
0092ab64 b yytext_ptr&lt;br /&gt;
009263e8 b zz__flex_debug&lt;br /&gt;
00928b50 b zz_char&lt;br /&gt;
009263e0 b zz_in&lt;br /&gt;
0092ab60 b zz_leng&lt;br /&gt;
00180a3c d zz_lineno&lt;br /&gt;
00928b20 b zz_lval&lt;br /&gt;
00928b54 b zz_nerrs&lt;br /&gt;
009263e4 b zz_out&lt;br /&gt;
00928b60 b zz_text&lt;br /&gt;
john@thunder:~/ascend$&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Static variables ==&lt;br /&gt;
&lt;br /&gt;
Another place where quasi-global variables can occur is as static variables within functions. It needs to be assessed whether the above listing includes those types of variables.&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Global_variables&amp;diff=3822</id>
		<title>Global variables</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Global_variables&amp;diff=3822"/>
		<updated>2012-07-06T18:30:38Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{task}}&lt;br /&gt;
&lt;br /&gt;
We would like to get rid of the current use of global variables in ASCEND, so that we can start to think about using ASCEND in multithreaded and/or embedded ways. This page will report any cases of global variables that we have found, and perhaps some discussion about how we can best eliminate them. Not all cases will be the same. Globals make some aspects of code reading easier (not crowding C arg lists with context pointers) and some harder: when complex side effects are in play. We try hard to avoid any usage of globals with complex side effects.&lt;br /&gt;
&lt;br /&gt;
== Ways for removing global variables ==&lt;br /&gt;
&lt;br /&gt;
A number of options exist:&lt;br /&gt;
&lt;br /&gt;
* keeping them. This is appropriate in a very limited set of situations, such as for data that has been loaded from a configuration file when the program started.&lt;br /&gt;
* groupin them into a top-level data structure. We imagine structures like &amp;quot;library&amp;quot;, &amp;quot;simulation&amp;quot; and &amp;quot;system&amp;quot; could be created that could hold most global variables.&lt;br /&gt;
* passing them. Where global variables have been used as a convenience to avoid having to expand function parameter lists, we can just change to passing them as parameters.&lt;br /&gt;
* converting them to #defines. May be appropriate for certain constants.&lt;br /&gt;
* converting them to thread-local variables (may need to assess implication for embedded applications)&lt;br /&gt;
* adding mutex constraints (so that they can only be accessed once at a time)&lt;br /&gt;
* migrating them to another code layer, eg into the GUI (this has already been done in some cases)&lt;br /&gt;
&lt;br /&gt;
== Particular kinds of usage and what can be done about it ==&lt;br /&gt;
&lt;br /&gt;
* Lex/Yacc C based scanners and parsers (and some still current versions of GNU bison/flex) generate code full of globals and non-threadsafe functions. It&#039;s not our job to fix this. The &#039;safe&#039; thing to do is put a mutex around the parse function.&lt;br /&gt;
* ASCEND defined parser context flags, once properly identified, can remain global because the mutex for yacc will also protect them. Cosmetically, the &#039;properly identified&#039; problem could be resolved by collecting these variables into a single well-named struct g_parser_context.&lt;br /&gt;
* Type library globals: most of these should be moved into a formal struct ascUniverse. More about that below.&lt;br /&gt;
* Instantiator tuning: most of these should be moved into a struct ascCompilerTuning.&lt;br /&gt;
* Memory recycle pools of small objects, tied to globals. These are tied to globals (typically file-scope static variables hidden behind allocator functions) to avoid passing pool pointers everywhere. In solvers like linsolqr, these pools should be tied to major objects instead of file global. &amp;quot;Too many pool objects, too short lived&amp;quot; is a problem that can be solved (taking mtx as an example, perhaps) by maintaining a list of idle mtx element pools; when to clear the idle pools is a minor problem. In the compiler, many pools should come and go with their Universe or with the destruction of the ascend type list and all dependent instances.&lt;br /&gt;
&lt;br /&gt;
== The object lives in ascend, and a design for global use reduction ==&lt;br /&gt;
The most basic facts: ascend parses a set of type definitions into a self-consistent class hierarchy. These type definitions can then be used with the instantiator to create model instances with relation and variable data. These instance objects answer many queries by accessing pointers to the type definitions used to create the objects. ASCEND has a concept named UNIVERSAL (not unlike globals in C) whereby for a given type definition, only one instance will ever be constructed. Both types and instances are deeply tied to a symbol (constant strings) table. Throughout ascend, both types and symbols are heavily compared for identity by comparing pointers.&lt;br /&gt;
&lt;br /&gt;
Key outcome of the above: if we wrap all the compiler globals in a context object of universal scope, we can then have at a higher (scripting) level multiple universe objects. *Objects from distinct universes cannot be compared except in string form*!&lt;br /&gt;
 &lt;br /&gt;
Given the above, then, ascend model type and instance data can be organized into something like the following. I will use c++ notation, but the implementation will be C.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
class ascUniverse {&lt;br /&gt;
public:&lt;br /&gt;
// functions only&lt;br /&gt;
private:&lt;br /&gt;
&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Global variables in libascend.so ==&lt;br /&gt;
&lt;br /&gt;
The main place where global variables are a problem for ASCEND is in &amp;lt;tt&amp;gt;libascend&amp;lt;/tt&amp;gt;, our core library include the ASCEND parser/compiler and evaluation routines, but &#039;&#039;&#039;hopefully&#039;&#039;&#039; excluding the solvers.&lt;br /&gt;
&lt;br /&gt;
Below is a list of globals generated using GNU &amp;lt;tt&amp;gt;nm&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;john@thunder:~/ascend$ nm libascend.so  | grep -i &amp;quot; [DdGgSsBb] &amp;quot;;&lt;br /&gt;
001828a0 b AllowedContents&lt;br /&gt;
00926420 b BracesNestLevel&lt;br /&gt;
0092889c b CmpEv&lt;br /&gt;
0092641c b CommentNestLevel&lt;br /&gt;
00180be0 d DimNames&lt;br /&gt;
00927ac8 b EvaluatingSets&lt;br /&gt;
00926548 b FundamentalTypeList&lt;br /&gt;
00928528 b GlobalUniversalTable&lt;br /&gt;
00927c14 b InterfaceNotify&lt;br /&gt;
00927c0c b InterfacePtrATS&lt;br /&gt;
00927c10 b InterfacePtrDelete&lt;br /&gt;
00928790 b L.6247&lt;br /&gt;
0092879c b L.6717&lt;br /&gt;
0092bca0 b LibraryHashTable&lt;br /&gt;
00927ac4 b ListMode&lt;br /&gt;
00926424 b MatchedBackslash&lt;br /&gt;
00927a64 b MinusOne&lt;br /&gt;
00927a84 b One&lt;br /&gt;
001820c0 b RecycledContents&lt;br /&gt;
001818e0 b RecycledList&lt;br /&gt;
00926428 b RequireIndex&lt;br /&gt;
00926460 b RequireStack&lt;br /&gt;
009286e0 B Solv_C_CheckHalt_Flag&lt;br /&gt;
00927aa4 b Three&lt;br /&gt;
00927a94 b Two&lt;br /&gt;
001816a0 d VpTable&lt;br /&gt;
009300dc b X&lt;br /&gt;
00927a74 b Zero&lt;br /&gt;
0017fcc0 d __CTOR_END__&lt;br /&gt;
0017fcbc d __CTOR_LIST__&lt;br /&gt;
0017fcc8 d __DTOR_END__&lt;br /&gt;
0017fcc4 d __DTOR_LIST__&lt;br /&gt;
0017fccc d __JCR_END__&lt;br /&gt;
0017fccc d __JCR_LIST__&lt;br /&gt;
00180a20 d __dso_handle&lt;br /&gt;
00181811 d blockend&lt;br /&gt;
001817fc d blockmagic&lt;br /&gt;
001814fc D calc_ok&lt;br /&gt;
00181500 d calc_print_errors&lt;br /&gt;
00928338 b cap.11161&lt;br /&gt;
009286d8 b cap.7377&lt;br /&gt;
00181520 d commands&lt;br /&gt;
001818a0 b completed.6625&lt;br /&gt;
009300e0 b conopt_fptrs&lt;br /&gt;
00927a54 b constants_inited&lt;br /&gt;
001817d0 d csdata&lt;br /&gt;
00183088 b dcps.2434&lt;br /&gt;
00926488 b default_library_path.7912&lt;br /&gt;
0092648c b default_solvers_path.7911&lt;br /&gt;
0018167c d defaultintegrators.6720&lt;br /&gt;
00927a60 b deriv_store.5961&lt;br /&gt;
00926564 b done.4160&lt;br /&gt;
00183090 b dref.2433&lt;br /&gt;
00927c80 b ds.3670&lt;br /&gt;
00927d60 b ds.4078&lt;br /&gt;
00928540 b ds.4252&lt;br /&gt;
00928060 b ds.4837&lt;br /&gt;
00928140 b ds.5578&lt;br /&gt;
001818a4 b dtor_idx.6627&lt;br /&gt;
009287c8 b elt.4095&lt;br /&gt;
009287cc b elt.4148&lt;br /&gt;
00926430 b errcount.6732&lt;br /&gt;
009263a4 b errcount.8155&lt;br /&gt;
00181670 d errname.6760&lt;br /&gt;
00928384 b error_statement_sym.4928&lt;br /&gt;
00928800 b exception_buffer&lt;br /&gt;
009287e0 b exception_status&lt;br /&gt;
00180a24 d f_first&lt;br /&gt;
00180a28 d f_fpe_top_of_stack&lt;br /&gt;
00926364 b f_fpe_traps&lt;br /&gt;
00180a2c d f_int_top_of_stack&lt;br /&gt;
00926368 b f_int_traps&lt;br /&gt;
001830e0 b f_mem_rec&lt;br /&gt;
001830c8 b f_memory_allocated&lt;br /&gt;
001830c4 b f_memory_length&lt;br /&gt;
001830c0 b f_memory_log_file&lt;br /&gt;
009242e0 b f_panic_callback_func&lt;br /&gt;
001830cc b f_peak_memory_usage&lt;br /&gt;
00180a30 d f_seg_top_of_stack&lt;br /&gt;
0092636c b f_seg_traps&lt;br /&gt;
00925300 b g_Asc_printVtables&lt;br /&gt;
00927acc b g_DeclarativeContext&lt;br /&gt;
00181320 d g_DefinitionErrorMessages&lt;br /&gt;
00927abc b g_EvaluationContext&lt;br /&gt;
00927ac0 b g_EvaluationForTable&lt;br /&gt;
00927ab8 b g_ExtVariablesTable&lt;br /&gt;
00927ab4 b g_ExternalFuncLibrary&lt;br /&gt;
00928018 b g_ExternalNodeStamps&lt;br /&gt;
00180e60 d g_abs_f&lt;br /&gt;
001812b0 D g_alt_ending&lt;br /&gt;
00926490 b g_ammarking&lt;br /&gt;
00180f20 d g_arccos_f&lt;br /&gt;
001810a0 d g_arccosh_f&lt;br /&gt;
00180ee0 d g_arcsin_f&lt;br /&gt;
00181060 d g_arcsinh_f&lt;br /&gt;
00180f60 d g_arctan_f&lt;br /&gt;
001810e0 d g_arctanh_f&lt;br /&gt;
00926494 b g_array_child_pool&lt;br /&gt;
00928444 b g_array_desc_count&lt;br /&gt;
00928448 b g_array_desc_list&lt;br /&gt;
0018309c b g_ascend_dllist&lt;br /&gt;
009264c0 b g_atom_bytes&lt;br /&gt;
009263b0 b g_atom_dim_ptr&lt;br /&gt;
0092bc50 b g_b_inst&lt;br /&gt;
0018187c d g_ba_elimdata&lt;br /&gt;
0092bc6c b g_ba_inst&lt;br /&gt;
0092863c b g_bad_rel_in_list&lt;br /&gt;
0092bc7c b g_bc_inst&lt;br /&gt;
00928434 b g_big_strings&lt;br /&gt;
00928438 b g_big_strings_cnt&lt;br /&gt;
00928640 b g_blockmethod&lt;br /&gt;
00180a60 d g_bt_data&lt;br /&gt;
00926398 b g_callargs&lt;br /&gt;
0092864c b g_case_number&lt;br /&gt;
00928030 b g_cbbccount&lt;br /&gt;
0092802c b g_cbbdcount&lt;br /&gt;
00181160 d g_cbrt_f&lt;br /&gt;
001812ec D g_check_dimensions_noisy&lt;br /&gt;
00926514 b g_clique_list&lt;br /&gt;
00181208 D g_compiler_counter&lt;br /&gt;
00928360 B g_compiler_timing&lt;br /&gt;
00180a34 D g_compiler_warnings&lt;br /&gt;
0092649c b g_cons&lt;br /&gt;
009263a0 b g_constant_type&lt;br /&gt;
009279d4 b g_copy_numnodes&lt;br /&gt;
00180d60 d g_cos_f&lt;br /&gt;
00180fe0 d g_cosh_f&lt;br /&gt;
00181120 d g_cube_f&lt;br /&gt;
00927f54 b g_current_module&lt;br /&gt;
0092bc48 b g_cursim&lt;br /&gt;
00926544 b g_def_child_bit_list&lt;br /&gt;
00926540 b g_def_child_desc_ptr&lt;br /&gt;
0092653c b g_def_child_list_ptr&lt;br /&gt;
009263b4 b g_default_dim_ptr&lt;br /&gt;
009263b8 b g_default_double&lt;br /&gt;
009263c0 b g_default_long&lt;br /&gt;
00928b4c b g_default_symbol&lt;br /&gt;
009263a8 b g_defaulted&lt;br /&gt;
00926534 b g_diagf&lt;br /&gt;
009263ac b g_dim_ptr&lt;br /&gt;
0092ac38 B g_dimen_list&lt;br /&gt;
0092ac30 b g_dimensionless&lt;br /&gt;
009286b4 b g_dis_tag&lt;br /&gt;
009284c0 b g_drt_depth&lt;br /&gt;
00927c28 b g_dummy_type&lt;br /&gt;
0092ac40 b g_dump_ht&lt;br /&gt;
0092bc40 b g_dump_inst_count&lt;br /&gt;
0092bc44 b g_dump_type_count&lt;br /&gt;
00926384 b g_end_identifier&lt;br /&gt;
001830a0 b g_env_list&lt;br /&gt;
00925340 b g_error_reporter_cache&lt;br /&gt;
00925328 b g_error_reporter_callback&lt;br /&gt;
00925320 b g_error_reporter_tree&lt;br /&gt;
00925324 b g_error_reporter_tree_current&lt;br /&gt;
00180c20 d g_exp_f&lt;br /&gt;
00927a50 b g_exprs_pool&lt;br /&gt;
00927c34 b g_externalmodel_type&lt;br /&gt;
009264fc b g_extra_parents&lt;br /&gt;
00926500 b g_extra_parents_sum&lt;br /&gt;
009264f8 b g_extra_paths&lt;br /&gt;
009288a0 b g_foreign_code_call_env&lt;br /&gt;
00927ad0 b g_forvar_recycle_list&lt;br /&gt;
00927ad4 b g_forvarfile&lt;br /&gt;
009289e0 B g_fpe_env&lt;br /&gt;
00927ad8 b g_free_store&lt;br /&gt;
001811a0 d g_func_list&lt;br /&gt;
00926370 b g_header_linenum&lt;br /&gt;
00180ea0 d g_hold_f&lt;br /&gt;
0092bc5c b g_i_inst&lt;br /&gt;
0092bc74 b g_ia_inst&lt;br /&gt;
0092bc60 b g_ic_inst&lt;br /&gt;
0017fce0 d g_instancetypenames&lt;br /&gt;
0018120c d g_instantiate_relns&lt;br /&gt;
00928a80 B g_int_env&lt;br /&gt;
001814f8 d g_iscomplete&lt;br /&gt;
0092844c b g_it_dummy_enum&lt;br /&gt;
00181310 d g_it_dummy_int&lt;br /&gt;
00927c00 b g_iteration&lt;br /&gt;
009284a8 b g_lcl_head&lt;br /&gt;
009284b8 b g_lcl_length&lt;br /&gt;
009284b4 b g_lcl_pivot&lt;br /&gt;
009284b0 b g_lcl_recycle&lt;br /&gt;
009284ac b g_lcl_tail&lt;br /&gt;
009284bc b g_lclrecycle_length&lt;br /&gt;
00181740 D g_linsolqr_timing&lt;br /&gt;
001818c0 b g_list_head_pool&lt;br /&gt;
00180c60 d g_ln_f&lt;br /&gt;
00180c08 D g_lnm_epsilon&lt;br /&gt;
00180ca0 d g_lnm_f&lt;br /&gt;
00180ce0 d g_log10_f&lt;br /&gt;
00927e40 b g_log_shortbuf&lt;br /&gt;
00927d54 b g_logrel_stack&lt;br /&gt;
00927c24 b g_logrel_type&lt;br /&gt;
00927f44 b g_logrelation_bvar_list&lt;br /&gt;
00927f48 b g_logrelation_satrel_list&lt;br /&gt;
00927f50 b g_logterm_pool&lt;br /&gt;
00181288 d g_logterm_ptrs&lt;br /&gt;
00927e34 b g_logwritfp&lt;br /&gt;
0092bc54 b g_lrel_inst&lt;br /&gt;
0092650c b g_maximum_children&lt;br /&gt;
009264f4 b g_maximum_parents&lt;br /&gt;
00926520 b g_maximum_relations&lt;br /&gt;
00926508 b g_minimum_children&lt;br /&gt;
009264f0 b g_minimum_parents&lt;br /&gt;
0092651c b g_minimum_relations&lt;br /&gt;
00926560 b g_missing&lt;br /&gt;
0092bc88 b g_mod_inst&lt;br /&gt;
009264b8 b g_model_bytes&lt;br /&gt;
00928000 b g_model_definition_methods&lt;br /&gt;
00926388 b g_model_parameters&lt;br /&gt;
00927f5c b g_module_list&lt;br /&gt;
00181220 d g_mpi_message&lt;br /&gt;
009287c4 b g_mtx_debug_redirect&lt;br /&gt;
0018185c d g_mtx_null_col_vector_data&lt;br /&gt;
0018181c d g_mtx_null_index_data&lt;br /&gt;
0018183c d g_mtx_null_mark_data&lt;br /&gt;
0018186c d g_mtx_null_row_vector_data&lt;br /&gt;
0018182c d g_mtx_null_sum_data&lt;br /&gt;
0018184c d g_mtx_null_vector_data&lt;br /&gt;
009301b4 b g_mtxerr&lt;br /&gt;
00927f6c b g_name_pool&lt;br /&gt;
009279e0 b g_names_needed&lt;br /&gt;
00927a58 b g_new_var_list&lt;br /&gt;
0092639c b g_notelist&lt;br /&gt;
00927f70 b g_notes_data_base&lt;br /&gt;
009264e8 b g_num_array_instances&lt;br /&gt;
009264dc b g_num_atom_children&lt;br /&gt;
009264bc b g_num_atom_instances&lt;br /&gt;
009264b0 b g_num_complex_instances&lt;br /&gt;
009264d8 b g_num_constant_all&lt;br /&gt;
009264cc b g_num_constant_bool&lt;br /&gt;
009264d0 b g_num_constant_int&lt;br /&gt;
009264c8 b g_num_constant_real&lt;br /&gt;
009264d4 b g_num_constant_sym&lt;br /&gt;
009264b4 b g_num_model_instances&lt;br /&gt;
00927f64 b g_num_names_cur&lt;br /&gt;
00927f68 b g_num_names_max&lt;br /&gt;
009264e0 b g_num_relation_instances&lt;br /&gt;
009264ec b g_num_unsel_instances&lt;br /&gt;
009284a4 b g_number&lt;br /&gt;
00927f90 b g_numlist_head_pool&lt;br /&gt;
00924300 b g_panic_outfile&lt;br /&gt;
00926390 b g_parameter_reduction&lt;br /&gt;
0092638c b g_parameter_wheres&lt;br /&gt;
0018130c d g_parse_count&lt;br /&gt;
00180a38 d g_parse_relns&lt;br /&gt;
009284c4 B g_parser_warnings&lt;br /&gt;
00927f9c b g_pending_count&lt;br /&gt;
00927fa0 b g_pending_list&lt;br /&gt;
00927fa4 b g_pending_list_end&lt;br /&gt;
00927fa8 b g_pending_pool&lt;br /&gt;
0092cca0 B g_plot_type&lt;br /&gt;
00927f94 b g_ppe_pool&lt;br /&gt;
001811fc d g_proc&lt;br /&gt;
00926378 b g_proc_name&lt;br /&gt;
00928004 b g_procframe_stop&lt;br /&gt;
00928008 b g_proto_count&lt;br /&gt;
0092ccc0 b g_proto_ht&lt;br /&gt;
0092bc94 b g_r_inst&lt;br /&gt;
0092bc78 b g_ra_inst&lt;br /&gt;
0092bc64 b g_rc_inst&lt;br /&gt;
00927a00 b g_recycle_expreval_stacks&lt;br /&gt;
00927f84 b g_recycled_npl&lt;br /&gt;
00926380 b g_refines_name&lt;br /&gt;
0092bc84 b g_rel_inst&lt;br /&gt;
00928040 b g_rel_stack&lt;br /&gt;
00928044 b g_rel_stack_pool&lt;br /&gt;
009264e4 b g_relation_guts&lt;br /&gt;
0092652c b g_relation_terms&lt;br /&gt;
00927c20 b g_relation_type&lt;br /&gt;
00928014 b g_relation_var_list&lt;br /&gt;
00928010 B g_relative_inst&lt;br /&gt;
00928618 b g_reuse&lt;br /&gt;
009286c4 b g_reuse&lt;br /&gt;
0092bc58 b g_s_inst&lt;br /&gt;
0092bc80 b g_sa_inst&lt;br /&gt;
0092bc90 b g_sc_inst&lt;br /&gt;
0092800c B g_search_inst&lt;br /&gt;
00928940 B g_seg_env&lt;br /&gt;
00928354 b g_set_pool&lt;br /&gt;
00927c30 b g_set_type&lt;br /&gt;
00928358 b g_sets_pool&lt;br /&gt;
00928220 b g_shortbuf&lt;br /&gt;
001812f4 d g_show_statement_detail&lt;br /&gt;
00927f4c b g_simplify_logrelations&lt;br /&gt;
001812cc D g_simplify_relations&lt;br /&gt;
0092835c B g_simulation_list&lt;br /&gt;
00180d20 d g_sin_f&lt;br /&gt;
00180fa0 d g_sinh_f&lt;br /&gt;
00927f60 b g_sldestroy&lt;br /&gt;
0092877c b g_solver_binary_type&lt;br /&gt;
009286c0 b g_solver_dis_type&lt;br /&gt;
00928778 b g_solver_int_type&lt;br /&gt;
00928780 b g_solver_semi_type&lt;br /&gt;
00928774 b g_solver_var_type&lt;br /&gt;
00180de0 d g_sqr_f&lt;br /&gt;
00180e20 d g_sqrt_f&lt;br /&gt;
00928414 b g_statio_flowtypenames&lt;br /&gt;
001812f8 d g_statio_label&lt;br /&gt;
009283a0 b g_statio_stattypenames&lt;br /&gt;
00928380 b g_statio_suppressions&lt;br /&gt;
00927b00 b g_string_buffer&lt;br /&gt;
00927f58 b g_string_modules_processed&lt;br /&gt;
00928428 b g_string_space&lt;br /&gt;
00927fc0 b g_strings&lt;br /&gt;
00928624 b g_strings&lt;br /&gt;
009286b8 b g_strings&lt;br /&gt;
009286d0 b g_strings&lt;br /&gt;
009286d4 b g_strings&lt;br /&gt;
00928758 b g_strings&lt;br /&gt;
00926498 b g_suppressions&lt;br /&gt;
0092bc8c b g_sym_inst&lt;br /&gt;
0092bc4c b g_syma_inst&lt;br /&gt;
00928430 b g_symbol_collisions&lt;br /&gt;
0092842c b g_symbol_size&lt;br /&gt;
0092dcc0 b g_symbol_table&lt;br /&gt;
00928614 b g_symbol_values_list&lt;br /&gt;
00927c40 b g_symbols&lt;br /&gt;
00928460 b g_symbols&lt;br /&gt;
009287ac b g_symbols&lt;br /&gt;
0092bc68 b g_symc_inst&lt;br /&gt;
00180da0 d g_tan_f&lt;br /&gt;
00181020 d g_tanh_f&lt;br /&gt;
0092843c b g_temporary_var_list&lt;br /&gt;
00928440 b g_temporary_var_recycle&lt;br /&gt;
0092801c b g_term_pool&lt;br /&gt;
001812d0 d g_term_ptrs&lt;br /&gt;
009284c8 b g_tlibs_depth&lt;br /&gt;
0092ab80 b g_token_counts&lt;br /&gt;
00926530 b g_total_array_children&lt;br /&gt;
00926510 b g_total_children&lt;br /&gt;
00926504 b g_total_parents&lt;br /&gt;
00926528 b g_total_reals_in_rels&lt;br /&gt;
00926524 b g_total_relations&lt;br /&gt;
00926518 b g_total_variables&lt;br /&gt;
009264c4 b g_tree_bytes&lt;br /&gt;
0092ac34 b g_trig_dimen&lt;br /&gt;
00927c04 b g_trychildexpansion_errmessage&lt;br /&gt;
009264ac b g_type_count_list&lt;br /&gt;
0092637c b g_type_name&lt;br /&gt;
00926394 b g_typeargs&lt;br /&gt;
00927c08 b g_unasscon_count&lt;br /&gt;
00928500 b g_unit_base_name&lt;br /&gt;
009284f0 b g_unit_explain_error_strings&lt;br /&gt;
00927adc b g_units_alloc&lt;br /&gt;
009284ec b g_units_collisions&lt;br /&gt;
001814c0 d g_units_errors.4640&lt;br /&gt;
0092f0e0 B g_units_hash_table&lt;br /&gt;
0092ecc0 b g_units_id_space&lt;br /&gt;
009263c4 b g_units_ptr&lt;br /&gt;
009284e8 b g_units_size&lt;br /&gt;
009284e0 b g_units_str&lt;br /&gt;
009284e4 b g_units_str_len&lt;br /&gt;
00927f98 b g_unresolved_count&lt;br /&gt;
00926374 b g_untrapped_error&lt;br /&gt;
00181204 D g_use_copyanon&lt;br /&gt;
0092852c b g_value_pool&lt;br /&gt;
00928754 b g_var_tag&lt;br /&gt;
0092bc70 b g_when_inst&lt;br /&gt;
00927c2c b g_when_type&lt;br /&gt;
0092ac3c b g_wild_dimen&lt;br /&gt;
0092642c b g_workbuf&lt;br /&gt;
00180a44 d g_workbuf_len.6555&lt;br /&gt;
00928214 b g_writfp&lt;br /&gt;
00928348 b glob_done&lt;br /&gt;
00927f40 b glob_lrel&lt;br /&gt;
00928340 b glob_rel&lt;br /&gt;
00928344 b glob_varnum&lt;br /&gt;
009279d0 b global_command_list&lt;br /&gt;
00928530 b global_visit_num&lt;br /&gt;
009287bc b hhrowlist.6528&lt;br /&gt;
00183074 b i.2578&lt;br /&gt;
00926354 b i.2755&lt;br /&gt;
00927ae0 b importhandler_library&lt;br /&gt;
00927ae4 b importhandler_sharedpointers&lt;br /&gt;
00926538 b init.5484&lt;br /&gt;
00928794 b init.6246&lt;br /&gt;
009287a0 b init.6716&lt;br /&gt;
0092878c b inst&lt;br /&gt;
009287c0 b last_value_matrix&lt;br /&gt;
00928798 b lastsolver.6445&lt;br /&gt;
00928330 b lhscap.9848&lt;br /&gt;
009287b8 b listlen.6529&lt;br /&gt;
00928784 b loaded.3887&lt;br /&gt;
00180ba0 d metadata.4158&lt;br /&gt;
001817e0 d mtxmagic&lt;br /&gt;
00928700 b name.6123&lt;br /&gt;
00928660 b name.6164&lt;br /&gt;
00181744 d names.4315&lt;br /&gt;
00181760 d names.4320&lt;br /&gt;
0018307c b newsize.2576&lt;br /&gt;
0092635c b newsize.2753&lt;br /&gt;
00181504 d nextid.6241&lt;br /&gt;
001812c8 d nostr.4857&lt;br /&gt;
00181688 d nrels.7185&lt;br /&gt;
0018168c d nrels.7199&lt;br /&gt;
009286fc b nuldev.5971&lt;br /&gt;
00181690 d nvars.7213&lt;br /&gt;
00183080 b oldsize.2575&lt;br /&gt;
00926360 b oldsize.2752&lt;br /&gt;
001817f2 d permmagic&lt;br /&gt;
00928648 b poly.3808&lt;br /&gt;
00928350 b poly.3924&lt;br /&gt;
00928644 b poly_cap.3809&lt;br /&gt;
0092834c b poly_cap.3925&lt;br /&gt;
00927a5c b previous_store.5962&lt;br /&gt;
0092833c b ptr.11160&lt;br /&gt;
009286dc b ptr.7376&lt;br /&gt;
00183078 b punt.2577&lt;br /&gt;
00926358 b punt.2754&lt;br /&gt;
00183098 b ref.2432&lt;br /&gt;
00928334 b rel.9847&lt;br /&gt;
009287a4 b reported_already.8633&lt;br /&gt;
009287a8 b reported_already.8653&lt;br /&gt;
00926580 b result.4159&lt;br /&gt;
009286e4 b rfilter.7742&lt;br /&gt;
0092832c b rhscap.9849&lt;br /&gt;
001817c0 d rsdata&lt;br /&gt;
001812f0 d safe_print_errors&lt;br /&gt;
0017fda0 d slv_reg&lt;br /&gt;
00928320 b soln_list.9691&lt;br /&gt;
00926418 b start_line&lt;br /&gt;
00928534 b stopnum.3912&lt;br /&gt;
00181508 d suppress_rel_flag.6780&lt;br /&gt;
00928788 b sys&lt;br /&gt;
001812a4 d unk.4785&lt;br /&gt;
00925304 b use_xterm_color.2533&lt;br /&gt;
009286ec b vfilter.7802&lt;br /&gt;
009286f4 b vfilter.7892&lt;br /&gt;
00928020 b warnexpt.5603&lt;br /&gt;
00928028 b warnexpt.5731&lt;br /&gt;
00928024 b warnfdiff.5732&lt;br /&gt;
009263f4 b yy_buffer_stack&lt;br /&gt;
009263f0 b yy_buffer_stack_max&lt;br /&gt;
009263ec b yy_buffer_stack_top&lt;br /&gt;
009263f8 b yy_c_buf_p&lt;br /&gt;
0092643c b yy_did_buffer_switch_on_eof&lt;br /&gt;
00926448 b yy_full_lp&lt;br /&gt;
00926440 b yy_full_match&lt;br /&gt;
0092644c b yy_full_state&lt;br /&gt;
00926434 b yy_hold_char&lt;br /&gt;
009263fc b yy_init&lt;br /&gt;
00180a40 d yy_line&lt;br /&gt;
0092640c b yy_looking_for_trail_begin&lt;br /&gt;
00926444 b yy_lp&lt;br /&gt;
00926410 b yy_more_offset&lt;br /&gt;
00926438 b yy_n_chars&lt;br /&gt;
00926414 b yy_prev_more_offset&lt;br /&gt;
00926400 b yy_start&lt;br /&gt;
00926404 b yy_state_buf&lt;br /&gt;
00926408 b yy_state_ptr&lt;br /&gt;
0092ab64 b yytext_ptr&lt;br /&gt;
009263e8 b zz__flex_debug&lt;br /&gt;
00928b50 b zz_char&lt;br /&gt;
009263e0 b zz_in&lt;br /&gt;
0092ab60 b zz_leng&lt;br /&gt;
00180a3c d zz_lineno&lt;br /&gt;
00928b20 b zz_lval&lt;br /&gt;
00928b54 b zz_nerrs&lt;br /&gt;
009263e4 b zz_out&lt;br /&gt;
00928b60 b zz_text&lt;br /&gt;
john@thunder:~/ascend$&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Static variables ==&lt;br /&gt;
&lt;br /&gt;
Another place where quasi-global variables can occur is as static variables within functions. It needs to be assessed whether the above listing includes those types of variables.&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Global_variables&amp;diff=3821</id>
		<title>Global variables</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Global_variables&amp;diff=3821"/>
		<updated>2012-07-06T18:29:41Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{task}}&lt;br /&gt;
&lt;br /&gt;
We would like to get rid of the current use of global variables in ASCEND, so that we can start to think about using ASCEND in multithreaded and/or embedded ways. This page will report any cases of global variables that we have found, and perhaps some discussion about how we can best eliminate them. Not all cases will be the same. Globals make some aspects of code reading easier (not crowding C arg lists with context pointers) and some harder: when complex side effects are in play. We try hard to avoid any usage of globals with complex side effects.&lt;br /&gt;
&lt;br /&gt;
== Ways for removing global variables ==&lt;br /&gt;
&lt;br /&gt;
A number of options exist:&lt;br /&gt;
&lt;br /&gt;
* keeping them. This is appropriate in a very limited set of situations, such as for data that has been loaded from a configuration file when the program started.&lt;br /&gt;
* groupin them into a top-level data structure. We imagine structures like &amp;quot;library&amp;quot;, &amp;quot;simulation&amp;quot; and &amp;quot;system&amp;quot; could be created that could hold most global variables.&lt;br /&gt;
* passing them. Where global variables have been used as a convenience to avoid having to expand function parameter lists, we can just change to passing them as parameters.&lt;br /&gt;
* converting them to #defines. May be appropriate for certain constants.&lt;br /&gt;
* converting them to thread-local variables (may need to assess implication for embedded applications)&lt;br /&gt;
* adding mutex constraints (so that they can only be accessed once at a time)&lt;br /&gt;
* migrating them to another code layer, eg into the GUI (this has already been done in some cases)&lt;br /&gt;
&lt;br /&gt;
== Particular kinds of usage and what can be done about it ==&lt;br /&gt;
&lt;br /&gt;
* Lex/Yacc C based scanners and parsers (and some still current versions of GNU bison/flex) generate code full of globals and non-threadsafe functions. It&#039;s not our job to fix this. The &#039;safe&#039; thing to do is put a mutex around the parse function.&lt;br /&gt;
* ASCEND defined parser context flags, once properly identified, can remain global because the mutex for yacc will also protect them. Cosmetically, the &#039;properly identified&#039; problem could be resolved by collecting these variables into a single well-named struct g_parser_context.&lt;br /&gt;
* Type library globals: most of these should be moved into a formal struct ascUniverse. More about that below.&lt;br /&gt;
* Instantiator tuning: most of these should be moved into a struct ascCompilerTuning.&lt;br /&gt;
* Memory recycle pools of small objects, tied to globals. These are tied to globals (typically file-scope static variables hidden behind allocator functions) to avoid passing pool pointers everywhere. In solvers like linsolqr, these pools should be tied to major objects instead of file global. &amp;quot;Too many pool objects, too short lived&amp;quot; is a problem that can be solved (taking mtx as an example, perhaps) by maintaining a list of idle mtx element pools; when to clear the idle pools is a minor problem. In the compiler, many pools should come and go with their Universe or with the destruction of the ascend type list and all dependent instances.&lt;br /&gt;
&lt;br /&gt;
== The object lives in ascend, and a design for global use reduction ==&lt;br /&gt;
The most basic facts: ascend parses a set of type definitions into a self-consistent class hierarchy. These type definitions can then be used with the instantiator to create model instances with relation and variable data. These instance objects answer many queries by accessing pointers to the type definitions used to create the objects. ASCEND has a concept named UNIVERSAL (not unlike globals in C) whereby for a given type definition, only one instance will ever be constructed. Both types and instances are deeply tied to a symbol (constant strings) table. Throughout ascend, both types and symbols are heavily compared for identity by comparing pointers.&lt;br /&gt;
&lt;br /&gt;
Key outcome of the above: if we wrap all the compiler globals in a context object of universal scope, we can then have at a higher (scripting) level multiple universe objects. *Objects from distinct universes cannot be compared except in string form*!&lt;br /&gt;
 &lt;br /&gt;
Given the above, then, ascend model type and instance data can be organized into something like the following. I will use c++ notation, but the implementation will be C.&lt;br /&gt;
&amp;lt;source&amp;gt;&lt;br /&gt;
class ascUniverse {&lt;br /&gt;
public:&lt;br /&gt;
// functions only&lt;br /&gt;
private:&lt;br /&gt;
&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Global variables in libascend.so ==&lt;br /&gt;
&lt;br /&gt;
The main place where global variables are a problem for ASCEND is in &amp;lt;tt&amp;gt;libascend&amp;lt;/tt&amp;gt;, our core library include the ASCEND parser/compiler and evaluation routines, but &#039;&#039;&#039;hopefully&#039;&#039;&#039; excluding the solvers.&lt;br /&gt;
&lt;br /&gt;
Below is a list of globals generated using GNU &amp;lt;tt&amp;gt;nm&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;john@thunder:~/ascend$ nm libascend.so  | grep -i &amp;quot; [DdGgSsBb] &amp;quot;;&lt;br /&gt;
001828a0 b AllowedContents&lt;br /&gt;
00926420 b BracesNestLevel&lt;br /&gt;
0092889c b CmpEv&lt;br /&gt;
0092641c b CommentNestLevel&lt;br /&gt;
00180be0 d DimNames&lt;br /&gt;
00927ac8 b EvaluatingSets&lt;br /&gt;
00926548 b FundamentalTypeList&lt;br /&gt;
00928528 b GlobalUniversalTable&lt;br /&gt;
00927c14 b InterfaceNotify&lt;br /&gt;
00927c0c b InterfacePtrATS&lt;br /&gt;
00927c10 b InterfacePtrDelete&lt;br /&gt;
00928790 b L.6247&lt;br /&gt;
0092879c b L.6717&lt;br /&gt;
0092bca0 b LibraryHashTable&lt;br /&gt;
00927ac4 b ListMode&lt;br /&gt;
00926424 b MatchedBackslash&lt;br /&gt;
00927a64 b MinusOne&lt;br /&gt;
00927a84 b One&lt;br /&gt;
001820c0 b RecycledContents&lt;br /&gt;
001818e0 b RecycledList&lt;br /&gt;
00926428 b RequireIndex&lt;br /&gt;
00926460 b RequireStack&lt;br /&gt;
009286e0 B Solv_C_CheckHalt_Flag&lt;br /&gt;
00927aa4 b Three&lt;br /&gt;
00927a94 b Two&lt;br /&gt;
001816a0 d VpTable&lt;br /&gt;
009300dc b X&lt;br /&gt;
00927a74 b Zero&lt;br /&gt;
0017fcc0 d __CTOR_END__&lt;br /&gt;
0017fcbc d __CTOR_LIST__&lt;br /&gt;
0017fcc8 d __DTOR_END__&lt;br /&gt;
0017fcc4 d __DTOR_LIST__&lt;br /&gt;
0017fccc d __JCR_END__&lt;br /&gt;
0017fccc d __JCR_LIST__&lt;br /&gt;
00180a20 d __dso_handle&lt;br /&gt;
00181811 d blockend&lt;br /&gt;
001817fc d blockmagic&lt;br /&gt;
001814fc D calc_ok&lt;br /&gt;
00181500 d calc_print_errors&lt;br /&gt;
00928338 b cap.11161&lt;br /&gt;
009286d8 b cap.7377&lt;br /&gt;
00181520 d commands&lt;br /&gt;
001818a0 b completed.6625&lt;br /&gt;
009300e0 b conopt_fptrs&lt;br /&gt;
00927a54 b constants_inited&lt;br /&gt;
001817d0 d csdata&lt;br /&gt;
00183088 b dcps.2434&lt;br /&gt;
00926488 b default_library_path.7912&lt;br /&gt;
0092648c b default_solvers_path.7911&lt;br /&gt;
0018167c d defaultintegrators.6720&lt;br /&gt;
00927a60 b deriv_store.5961&lt;br /&gt;
00926564 b done.4160&lt;br /&gt;
00183090 b dref.2433&lt;br /&gt;
00927c80 b ds.3670&lt;br /&gt;
00927d60 b ds.4078&lt;br /&gt;
00928540 b ds.4252&lt;br /&gt;
00928060 b ds.4837&lt;br /&gt;
00928140 b ds.5578&lt;br /&gt;
001818a4 b dtor_idx.6627&lt;br /&gt;
009287c8 b elt.4095&lt;br /&gt;
009287cc b elt.4148&lt;br /&gt;
00926430 b errcount.6732&lt;br /&gt;
009263a4 b errcount.8155&lt;br /&gt;
00181670 d errname.6760&lt;br /&gt;
00928384 b error_statement_sym.4928&lt;br /&gt;
00928800 b exception_buffer&lt;br /&gt;
009287e0 b exception_status&lt;br /&gt;
00180a24 d f_first&lt;br /&gt;
00180a28 d f_fpe_top_of_stack&lt;br /&gt;
00926364 b f_fpe_traps&lt;br /&gt;
00180a2c d f_int_top_of_stack&lt;br /&gt;
00926368 b f_int_traps&lt;br /&gt;
001830e0 b f_mem_rec&lt;br /&gt;
001830c8 b f_memory_allocated&lt;br /&gt;
001830c4 b f_memory_length&lt;br /&gt;
001830c0 b f_memory_log_file&lt;br /&gt;
009242e0 b f_panic_callback_func&lt;br /&gt;
001830cc b f_peak_memory_usage&lt;br /&gt;
00180a30 d f_seg_top_of_stack&lt;br /&gt;
0092636c b f_seg_traps&lt;br /&gt;
00925300 b g_Asc_printVtables&lt;br /&gt;
00927acc b g_DeclarativeContext&lt;br /&gt;
00181320 d g_DefinitionErrorMessages&lt;br /&gt;
00927abc b g_EvaluationContext&lt;br /&gt;
00927ac0 b g_EvaluationForTable&lt;br /&gt;
00927ab8 b g_ExtVariablesTable&lt;br /&gt;
00927ab4 b g_ExternalFuncLibrary&lt;br /&gt;
00928018 b g_ExternalNodeStamps&lt;br /&gt;
00180e60 d g_abs_f&lt;br /&gt;
001812b0 D g_alt_ending&lt;br /&gt;
00926490 b g_ammarking&lt;br /&gt;
00180f20 d g_arccos_f&lt;br /&gt;
001810a0 d g_arccosh_f&lt;br /&gt;
00180ee0 d g_arcsin_f&lt;br /&gt;
00181060 d g_arcsinh_f&lt;br /&gt;
00180f60 d g_arctan_f&lt;br /&gt;
001810e0 d g_arctanh_f&lt;br /&gt;
00926494 b g_array_child_pool&lt;br /&gt;
00928444 b g_array_desc_count&lt;br /&gt;
00928448 b g_array_desc_list&lt;br /&gt;
0018309c b g_ascend_dllist&lt;br /&gt;
009264c0 b g_atom_bytes&lt;br /&gt;
009263b0 b g_atom_dim_ptr&lt;br /&gt;
0092bc50 b g_b_inst&lt;br /&gt;
0018187c d g_ba_elimdata&lt;br /&gt;
0092bc6c b g_ba_inst&lt;br /&gt;
0092863c b g_bad_rel_in_list&lt;br /&gt;
0092bc7c b g_bc_inst&lt;br /&gt;
00928434 b g_big_strings&lt;br /&gt;
00928438 b g_big_strings_cnt&lt;br /&gt;
00928640 b g_blockmethod&lt;br /&gt;
00180a60 d g_bt_data&lt;br /&gt;
00926398 b g_callargs&lt;br /&gt;
0092864c b g_case_number&lt;br /&gt;
00928030 b g_cbbccount&lt;br /&gt;
0092802c b g_cbbdcount&lt;br /&gt;
00181160 d g_cbrt_f&lt;br /&gt;
001812ec D g_check_dimensions_noisy&lt;br /&gt;
00926514 b g_clique_list&lt;br /&gt;
00181208 D g_compiler_counter&lt;br /&gt;
00928360 B g_compiler_timing&lt;br /&gt;
00180a34 D g_compiler_warnings&lt;br /&gt;
0092649c b g_cons&lt;br /&gt;
009263a0 b g_constant_type&lt;br /&gt;
009279d4 b g_copy_numnodes&lt;br /&gt;
00180d60 d g_cos_f&lt;br /&gt;
00180fe0 d g_cosh_f&lt;br /&gt;
00181120 d g_cube_f&lt;br /&gt;
00927f54 b g_current_module&lt;br /&gt;
0092bc48 b g_cursim&lt;br /&gt;
00926544 b g_def_child_bit_list&lt;br /&gt;
00926540 b g_def_child_desc_ptr&lt;br /&gt;
0092653c b g_def_child_list_ptr&lt;br /&gt;
009263b4 b g_default_dim_ptr&lt;br /&gt;
009263b8 b g_default_double&lt;br /&gt;
009263c0 b g_default_long&lt;br /&gt;
00928b4c b g_default_symbol&lt;br /&gt;
009263a8 b g_defaulted&lt;br /&gt;
00926534 b g_diagf&lt;br /&gt;
009263ac b g_dim_ptr&lt;br /&gt;
0092ac38 B g_dimen_list&lt;br /&gt;
0092ac30 b g_dimensionless&lt;br /&gt;
009286b4 b g_dis_tag&lt;br /&gt;
009284c0 b g_drt_depth&lt;br /&gt;
00927c28 b g_dummy_type&lt;br /&gt;
0092ac40 b g_dump_ht&lt;br /&gt;
0092bc40 b g_dump_inst_count&lt;br /&gt;
0092bc44 b g_dump_type_count&lt;br /&gt;
00926384 b g_end_identifier&lt;br /&gt;
001830a0 b g_env_list&lt;br /&gt;
00925340 b g_error_reporter_cache&lt;br /&gt;
00925328 b g_error_reporter_callback&lt;br /&gt;
00925320 b g_error_reporter_tree&lt;br /&gt;
00925324 b g_error_reporter_tree_current&lt;br /&gt;
00180c20 d g_exp_f&lt;br /&gt;
00927a50 b g_exprs_pool&lt;br /&gt;
00927c34 b g_externalmodel_type&lt;br /&gt;
009264fc b g_extra_parents&lt;br /&gt;
00926500 b g_extra_parents_sum&lt;br /&gt;
009264f8 b g_extra_paths&lt;br /&gt;
009288a0 b g_foreign_code_call_env&lt;br /&gt;
00927ad0 b g_forvar_recycle_list&lt;br /&gt;
00927ad4 b g_forvarfile&lt;br /&gt;
009289e0 B g_fpe_env&lt;br /&gt;
00927ad8 b g_free_store&lt;br /&gt;
001811a0 d g_func_list&lt;br /&gt;
00926370 b g_header_linenum&lt;br /&gt;
00180ea0 d g_hold_f&lt;br /&gt;
0092bc5c b g_i_inst&lt;br /&gt;
0092bc74 b g_ia_inst&lt;br /&gt;
0092bc60 b g_ic_inst&lt;br /&gt;
0017fce0 d g_instancetypenames&lt;br /&gt;
0018120c d g_instantiate_relns&lt;br /&gt;
00928a80 B g_int_env&lt;br /&gt;
001814f8 d g_iscomplete&lt;br /&gt;
0092844c b g_it_dummy_enum&lt;br /&gt;
00181310 d g_it_dummy_int&lt;br /&gt;
00927c00 b g_iteration&lt;br /&gt;
009284a8 b g_lcl_head&lt;br /&gt;
009284b8 b g_lcl_length&lt;br /&gt;
009284b4 b g_lcl_pivot&lt;br /&gt;
009284b0 b g_lcl_recycle&lt;br /&gt;
009284ac b g_lcl_tail&lt;br /&gt;
009284bc b g_lclrecycle_length&lt;br /&gt;
00181740 D g_linsolqr_timing&lt;br /&gt;
001818c0 b g_list_head_pool&lt;br /&gt;
00180c60 d g_ln_f&lt;br /&gt;
00180c08 D g_lnm_epsilon&lt;br /&gt;
00180ca0 d g_lnm_f&lt;br /&gt;
00180ce0 d g_log10_f&lt;br /&gt;
00927e40 b g_log_shortbuf&lt;br /&gt;
00927d54 b g_logrel_stack&lt;br /&gt;
00927c24 b g_logrel_type&lt;br /&gt;
00927f44 b g_logrelation_bvar_list&lt;br /&gt;
00927f48 b g_logrelation_satrel_list&lt;br /&gt;
00927f50 b g_logterm_pool&lt;br /&gt;
00181288 d g_logterm_ptrs&lt;br /&gt;
00927e34 b g_logwritfp&lt;br /&gt;
0092bc54 b g_lrel_inst&lt;br /&gt;
0092650c b g_maximum_children&lt;br /&gt;
009264f4 b g_maximum_parents&lt;br /&gt;
00926520 b g_maximum_relations&lt;br /&gt;
00926508 b g_minimum_children&lt;br /&gt;
009264f0 b g_minimum_parents&lt;br /&gt;
0092651c b g_minimum_relations&lt;br /&gt;
00926560 b g_missing&lt;br /&gt;
0092bc88 b g_mod_inst&lt;br /&gt;
009264b8 b g_model_bytes&lt;br /&gt;
00928000 b g_model_definition_methods&lt;br /&gt;
00926388 b g_model_parameters&lt;br /&gt;
00927f5c b g_module_list&lt;br /&gt;
00181220 d g_mpi_message&lt;br /&gt;
009287c4 b g_mtx_debug_redirect&lt;br /&gt;
0018185c d g_mtx_null_col_vector_data&lt;br /&gt;
0018181c d g_mtx_null_index_data&lt;br /&gt;
0018183c d g_mtx_null_mark_data&lt;br /&gt;
0018186c d g_mtx_null_row_vector_data&lt;br /&gt;
0018182c d g_mtx_null_sum_data&lt;br /&gt;
0018184c d g_mtx_null_vector_data&lt;br /&gt;
009301b4 b g_mtxerr&lt;br /&gt;
00927f6c b g_name_pool&lt;br /&gt;
009279e0 b g_names_needed&lt;br /&gt;
00927a58 b g_new_var_list&lt;br /&gt;
0092639c b g_notelist&lt;br /&gt;
00927f70 b g_notes_data_base&lt;br /&gt;
009264e8 b g_num_array_instances&lt;br /&gt;
009264dc b g_num_atom_children&lt;br /&gt;
009264bc b g_num_atom_instances&lt;br /&gt;
009264b0 b g_num_complex_instances&lt;br /&gt;
009264d8 b g_num_constant_all&lt;br /&gt;
009264cc b g_num_constant_bool&lt;br /&gt;
009264d0 b g_num_constant_int&lt;br /&gt;
009264c8 b g_num_constant_real&lt;br /&gt;
009264d4 b g_num_constant_sym&lt;br /&gt;
009264b4 b g_num_model_instances&lt;br /&gt;
00927f64 b g_num_names_cur&lt;br /&gt;
00927f68 b g_num_names_max&lt;br /&gt;
009264e0 b g_num_relation_instances&lt;br /&gt;
009264ec b g_num_unsel_instances&lt;br /&gt;
009284a4 b g_number&lt;br /&gt;
00927f90 b g_numlist_head_pool&lt;br /&gt;
00924300 b g_panic_outfile&lt;br /&gt;
00926390 b g_parameter_reduction&lt;br /&gt;
0092638c b g_parameter_wheres&lt;br /&gt;
0018130c d g_parse_count&lt;br /&gt;
00180a38 d g_parse_relns&lt;br /&gt;
009284c4 B g_parser_warnings&lt;br /&gt;
00927f9c b g_pending_count&lt;br /&gt;
00927fa0 b g_pending_list&lt;br /&gt;
00927fa4 b g_pending_list_end&lt;br /&gt;
00927fa8 b g_pending_pool&lt;br /&gt;
0092cca0 B g_plot_type&lt;br /&gt;
00927f94 b g_ppe_pool&lt;br /&gt;
001811fc d g_proc&lt;br /&gt;
00926378 b g_proc_name&lt;br /&gt;
00928004 b g_procframe_stop&lt;br /&gt;
00928008 b g_proto_count&lt;br /&gt;
0092ccc0 b g_proto_ht&lt;br /&gt;
0092bc94 b g_r_inst&lt;br /&gt;
0092bc78 b g_ra_inst&lt;br /&gt;
0092bc64 b g_rc_inst&lt;br /&gt;
00927a00 b g_recycle_expreval_stacks&lt;br /&gt;
00927f84 b g_recycled_npl&lt;br /&gt;
00926380 b g_refines_name&lt;br /&gt;
0092bc84 b g_rel_inst&lt;br /&gt;
00928040 b g_rel_stack&lt;br /&gt;
00928044 b g_rel_stack_pool&lt;br /&gt;
009264e4 b g_relation_guts&lt;br /&gt;
0092652c b g_relation_terms&lt;br /&gt;
00927c20 b g_relation_type&lt;br /&gt;
00928014 b g_relation_var_list&lt;br /&gt;
00928010 B g_relative_inst&lt;br /&gt;
00928618 b g_reuse&lt;br /&gt;
009286c4 b g_reuse&lt;br /&gt;
0092bc58 b g_s_inst&lt;br /&gt;
0092bc80 b g_sa_inst&lt;br /&gt;
0092bc90 b g_sc_inst&lt;br /&gt;
0092800c B g_search_inst&lt;br /&gt;
00928940 B g_seg_env&lt;br /&gt;
00928354 b g_set_pool&lt;br /&gt;
00927c30 b g_set_type&lt;br /&gt;
00928358 b g_sets_pool&lt;br /&gt;
00928220 b g_shortbuf&lt;br /&gt;
001812f4 d g_show_statement_detail&lt;br /&gt;
00927f4c b g_simplify_logrelations&lt;br /&gt;
001812cc D g_simplify_relations&lt;br /&gt;
0092835c B g_simulation_list&lt;br /&gt;
00180d20 d g_sin_f&lt;br /&gt;
00180fa0 d g_sinh_f&lt;br /&gt;
00927f60 b g_sldestroy&lt;br /&gt;
0092877c b g_solver_binary_type&lt;br /&gt;
009286c0 b g_solver_dis_type&lt;br /&gt;
00928778 b g_solver_int_type&lt;br /&gt;
00928780 b g_solver_semi_type&lt;br /&gt;
00928774 b g_solver_var_type&lt;br /&gt;
00180de0 d g_sqr_f&lt;br /&gt;
00180e20 d g_sqrt_f&lt;br /&gt;
00928414 b g_statio_flowtypenames&lt;br /&gt;
001812f8 d g_statio_label&lt;br /&gt;
009283a0 b g_statio_stattypenames&lt;br /&gt;
00928380 b g_statio_suppressions&lt;br /&gt;
00927b00 b g_string_buffer&lt;br /&gt;
00927f58 b g_string_modules_processed&lt;br /&gt;
00928428 b g_string_space&lt;br /&gt;
00927fc0 b g_strings&lt;br /&gt;
00928624 b g_strings&lt;br /&gt;
009286b8 b g_strings&lt;br /&gt;
009286d0 b g_strings&lt;br /&gt;
009286d4 b g_strings&lt;br /&gt;
00928758 b g_strings&lt;br /&gt;
00926498 b g_suppressions&lt;br /&gt;
0092bc8c b g_sym_inst&lt;br /&gt;
0092bc4c b g_syma_inst&lt;br /&gt;
00928430 b g_symbol_collisions&lt;br /&gt;
0092842c b g_symbol_size&lt;br /&gt;
0092dcc0 b g_symbol_table&lt;br /&gt;
00928614 b g_symbol_values_list&lt;br /&gt;
00927c40 b g_symbols&lt;br /&gt;
00928460 b g_symbols&lt;br /&gt;
009287ac b g_symbols&lt;br /&gt;
0092bc68 b g_symc_inst&lt;br /&gt;
00180da0 d g_tan_f&lt;br /&gt;
00181020 d g_tanh_f&lt;br /&gt;
0092843c b g_temporary_var_list&lt;br /&gt;
00928440 b g_temporary_var_recycle&lt;br /&gt;
0092801c b g_term_pool&lt;br /&gt;
001812d0 d g_term_ptrs&lt;br /&gt;
009284c8 b g_tlibs_depth&lt;br /&gt;
0092ab80 b g_token_counts&lt;br /&gt;
00926530 b g_total_array_children&lt;br /&gt;
00926510 b g_total_children&lt;br /&gt;
00926504 b g_total_parents&lt;br /&gt;
00926528 b g_total_reals_in_rels&lt;br /&gt;
00926524 b g_total_relations&lt;br /&gt;
00926518 b g_total_variables&lt;br /&gt;
009264c4 b g_tree_bytes&lt;br /&gt;
0092ac34 b g_trig_dimen&lt;br /&gt;
00927c04 b g_trychildexpansion_errmessage&lt;br /&gt;
009264ac b g_type_count_list&lt;br /&gt;
0092637c b g_type_name&lt;br /&gt;
00926394 b g_typeargs&lt;br /&gt;
00927c08 b g_unasscon_count&lt;br /&gt;
00928500 b g_unit_base_name&lt;br /&gt;
009284f0 b g_unit_explain_error_strings&lt;br /&gt;
00927adc b g_units_alloc&lt;br /&gt;
009284ec b g_units_collisions&lt;br /&gt;
001814c0 d g_units_errors.4640&lt;br /&gt;
0092f0e0 B g_units_hash_table&lt;br /&gt;
0092ecc0 b g_units_id_space&lt;br /&gt;
009263c4 b g_units_ptr&lt;br /&gt;
009284e8 b g_units_size&lt;br /&gt;
009284e0 b g_units_str&lt;br /&gt;
009284e4 b g_units_str_len&lt;br /&gt;
00927f98 b g_unresolved_count&lt;br /&gt;
00926374 b g_untrapped_error&lt;br /&gt;
00181204 D g_use_copyanon&lt;br /&gt;
0092852c b g_value_pool&lt;br /&gt;
00928754 b g_var_tag&lt;br /&gt;
0092bc70 b g_when_inst&lt;br /&gt;
00927c2c b g_when_type&lt;br /&gt;
0092ac3c b g_wild_dimen&lt;br /&gt;
0092642c b g_workbuf&lt;br /&gt;
00180a44 d g_workbuf_len.6555&lt;br /&gt;
00928214 b g_writfp&lt;br /&gt;
00928348 b glob_done&lt;br /&gt;
00927f40 b glob_lrel&lt;br /&gt;
00928340 b glob_rel&lt;br /&gt;
00928344 b glob_varnum&lt;br /&gt;
009279d0 b global_command_list&lt;br /&gt;
00928530 b global_visit_num&lt;br /&gt;
009287bc b hhrowlist.6528&lt;br /&gt;
00183074 b i.2578&lt;br /&gt;
00926354 b i.2755&lt;br /&gt;
00927ae0 b importhandler_library&lt;br /&gt;
00927ae4 b importhandler_sharedpointers&lt;br /&gt;
00926538 b init.5484&lt;br /&gt;
00928794 b init.6246&lt;br /&gt;
009287a0 b init.6716&lt;br /&gt;
0092878c b inst&lt;br /&gt;
009287c0 b last_value_matrix&lt;br /&gt;
00928798 b lastsolver.6445&lt;br /&gt;
00928330 b lhscap.9848&lt;br /&gt;
009287b8 b listlen.6529&lt;br /&gt;
00928784 b loaded.3887&lt;br /&gt;
00180ba0 d metadata.4158&lt;br /&gt;
001817e0 d mtxmagic&lt;br /&gt;
00928700 b name.6123&lt;br /&gt;
00928660 b name.6164&lt;br /&gt;
00181744 d names.4315&lt;br /&gt;
00181760 d names.4320&lt;br /&gt;
0018307c b newsize.2576&lt;br /&gt;
0092635c b newsize.2753&lt;br /&gt;
00181504 d nextid.6241&lt;br /&gt;
001812c8 d nostr.4857&lt;br /&gt;
00181688 d nrels.7185&lt;br /&gt;
0018168c d nrels.7199&lt;br /&gt;
009286fc b nuldev.5971&lt;br /&gt;
00181690 d nvars.7213&lt;br /&gt;
00183080 b oldsize.2575&lt;br /&gt;
00926360 b oldsize.2752&lt;br /&gt;
001817f2 d permmagic&lt;br /&gt;
00928648 b poly.3808&lt;br /&gt;
00928350 b poly.3924&lt;br /&gt;
00928644 b poly_cap.3809&lt;br /&gt;
0092834c b poly_cap.3925&lt;br /&gt;
00927a5c b previous_store.5962&lt;br /&gt;
0092833c b ptr.11160&lt;br /&gt;
009286dc b ptr.7376&lt;br /&gt;
00183078 b punt.2577&lt;br /&gt;
00926358 b punt.2754&lt;br /&gt;
00183098 b ref.2432&lt;br /&gt;
00928334 b rel.9847&lt;br /&gt;
009287a4 b reported_already.8633&lt;br /&gt;
009287a8 b reported_already.8653&lt;br /&gt;
00926580 b result.4159&lt;br /&gt;
009286e4 b rfilter.7742&lt;br /&gt;
0092832c b rhscap.9849&lt;br /&gt;
001817c0 d rsdata&lt;br /&gt;
001812f0 d safe_print_errors&lt;br /&gt;
0017fda0 d slv_reg&lt;br /&gt;
00928320 b soln_list.9691&lt;br /&gt;
00926418 b start_line&lt;br /&gt;
00928534 b stopnum.3912&lt;br /&gt;
00181508 d suppress_rel_flag.6780&lt;br /&gt;
00928788 b sys&lt;br /&gt;
001812a4 d unk.4785&lt;br /&gt;
00925304 b use_xterm_color.2533&lt;br /&gt;
009286ec b vfilter.7802&lt;br /&gt;
009286f4 b vfilter.7892&lt;br /&gt;
00928020 b warnexpt.5603&lt;br /&gt;
00928028 b warnexpt.5731&lt;br /&gt;
00928024 b warnfdiff.5732&lt;br /&gt;
009263f4 b yy_buffer_stack&lt;br /&gt;
009263f0 b yy_buffer_stack_max&lt;br /&gt;
009263ec b yy_buffer_stack_top&lt;br /&gt;
009263f8 b yy_c_buf_p&lt;br /&gt;
0092643c b yy_did_buffer_switch_on_eof&lt;br /&gt;
00926448 b yy_full_lp&lt;br /&gt;
00926440 b yy_full_match&lt;br /&gt;
0092644c b yy_full_state&lt;br /&gt;
00926434 b yy_hold_char&lt;br /&gt;
009263fc b yy_init&lt;br /&gt;
00180a40 d yy_line&lt;br /&gt;
0092640c b yy_looking_for_trail_begin&lt;br /&gt;
00926444 b yy_lp&lt;br /&gt;
00926410 b yy_more_offset&lt;br /&gt;
00926438 b yy_n_chars&lt;br /&gt;
00926414 b yy_prev_more_offset&lt;br /&gt;
00926400 b yy_start&lt;br /&gt;
00926404 b yy_state_buf&lt;br /&gt;
00926408 b yy_state_ptr&lt;br /&gt;
0092ab64 b yytext_ptr&lt;br /&gt;
009263e8 b zz__flex_debug&lt;br /&gt;
00928b50 b zz_char&lt;br /&gt;
009263e0 b zz_in&lt;br /&gt;
0092ab60 b zz_leng&lt;br /&gt;
00180a3c d zz_lineno&lt;br /&gt;
00928b20 b zz_lval&lt;br /&gt;
00928b54 b zz_nerrs&lt;br /&gt;
009263e4 b zz_out&lt;br /&gt;
00928b60 b zz_text&lt;br /&gt;
john@thunder:~/ascend$&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Static variables ==&lt;br /&gt;
&lt;br /&gt;
Another place where quasi-global variables can occur is as static variables within functions. It needs to be assessed whether the above listing includes those types of variables.&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Global_variables&amp;diff=3820</id>
		<title>Global variables</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Global_variables&amp;diff=3820"/>
		<updated>2012-07-06T18:14:11Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{task}}&lt;br /&gt;
&lt;br /&gt;
We would like to get rid of the current use of global variables in ASCEND, so that we can start to think about using ASCEND in multithreaded and/or embedded ways. This page will report any cases of global variables that we have found, and perhaps some discussion about how we can best eliminate them. Not all cases will be the same. Globals make some aspects of code reading easier (not crowding C arg lists with context pointers) and some harder: when complex side effects are in play. We try hard to avoid any usage of globals with complex side effects.&lt;br /&gt;
&lt;br /&gt;
== Ways for removing global variables ==&lt;br /&gt;
&lt;br /&gt;
A number of options exist:&lt;br /&gt;
&lt;br /&gt;
* keeping them. This is appropriate in a very limited set of situations, such as for data that has been loaded from a configuration file when the program started.&lt;br /&gt;
* groupin them into a top-level data structure. We imagine structures like &amp;quot;library&amp;quot;, &amp;quot;simulation&amp;quot; and &amp;quot;system&amp;quot; could be created that could hold most global variables.&lt;br /&gt;
* passing them. Where global variables have been used as a convenience to avoid having to expand function parameter lists, we can just change to passing them as parameters.&lt;br /&gt;
* converting them to #defines. May be appropriate for certain constants.&lt;br /&gt;
* converting them to thread-local variables (may need to assess implication for embedded applications)&lt;br /&gt;
* adding mutex constraints (so that they can only be accessed once at a time)&lt;br /&gt;
* migrating them to another code layer, eg into the GUI (this has already been done in some cases)&lt;br /&gt;
&lt;br /&gt;
== Particular kinds of usage and what can be done about it ==&lt;br /&gt;
&lt;br /&gt;
* Lex/Yacc C based scanners and parsers (and some still current versions of GNU bison/flex) generate code full of globals and non-threadsafe functions. It&#039;s not our job to fix this. The &#039;safe&#039; thing to do is put a mutex around the parse function.&lt;br /&gt;
* ASCEND defined parser context flags, once properly identified, can remain global because the mutex for yacc will also protect them. Cosmetically, the &#039;properly identified&#039; problem could be resolved by collecting these variables into a single well-named struct g_parser_context.&lt;br /&gt;
* Type library globals: most of these should be moved into a formal struct ascUniverse. More about that below.&lt;br /&gt;
* Instantiator tuning: most of these should be moved into a struct ascCompilerTuning.&lt;br /&gt;
* Memory recycle pools of small objects, tied to globals. These are tied to globals (typically file-scope static variables hidden behind allocator functions) to avoid passing pool pointers everywhere. In solvers like linsolqr, these pools should be tied to major objects instead of file global. &amp;quot;Too many pool objects, too short lived&amp;quot; is a problem that can be solved (taking mtx as an example, perhaps) by maintaining a list of idle mtx element pools; when to clear the idle pools is a minor problem. In the compiler, many pools should come and go with their Universe or with the destruction of the ascend type list and all dependent instances.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Global variables in libascend.so ==&lt;br /&gt;
&lt;br /&gt;
The main place where global variables are a problem for ASCEND is in &amp;lt;tt&amp;gt;libascend&amp;lt;/tt&amp;gt;, our core library include the ASCEND parser/compiler and evaluation routines, but &#039;&#039;&#039;hopefully&#039;&#039;&#039; excluding the solvers.&lt;br /&gt;
&lt;br /&gt;
Below is a list of globals generated using GNU &amp;lt;tt&amp;gt;nm&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;john@thunder:~/ascend$ nm libascend.so  | grep -i &amp;quot; [DdGgSsBb] &amp;quot;;&lt;br /&gt;
001828a0 b AllowedContents&lt;br /&gt;
00926420 b BracesNestLevel&lt;br /&gt;
0092889c b CmpEv&lt;br /&gt;
0092641c b CommentNestLevel&lt;br /&gt;
00180be0 d DimNames&lt;br /&gt;
00927ac8 b EvaluatingSets&lt;br /&gt;
00926548 b FundamentalTypeList&lt;br /&gt;
00928528 b GlobalUniversalTable&lt;br /&gt;
00927c14 b InterfaceNotify&lt;br /&gt;
00927c0c b InterfacePtrATS&lt;br /&gt;
00927c10 b InterfacePtrDelete&lt;br /&gt;
00928790 b L.6247&lt;br /&gt;
0092879c b L.6717&lt;br /&gt;
0092bca0 b LibraryHashTable&lt;br /&gt;
00927ac4 b ListMode&lt;br /&gt;
00926424 b MatchedBackslash&lt;br /&gt;
00927a64 b MinusOne&lt;br /&gt;
00927a84 b One&lt;br /&gt;
001820c0 b RecycledContents&lt;br /&gt;
001818e0 b RecycledList&lt;br /&gt;
00926428 b RequireIndex&lt;br /&gt;
00926460 b RequireStack&lt;br /&gt;
009286e0 B Solv_C_CheckHalt_Flag&lt;br /&gt;
00927aa4 b Three&lt;br /&gt;
00927a94 b Two&lt;br /&gt;
001816a0 d VpTable&lt;br /&gt;
009300dc b X&lt;br /&gt;
00927a74 b Zero&lt;br /&gt;
0017fcc0 d __CTOR_END__&lt;br /&gt;
0017fcbc d __CTOR_LIST__&lt;br /&gt;
0017fcc8 d __DTOR_END__&lt;br /&gt;
0017fcc4 d __DTOR_LIST__&lt;br /&gt;
0017fccc d __JCR_END__&lt;br /&gt;
0017fccc d __JCR_LIST__&lt;br /&gt;
00180a20 d __dso_handle&lt;br /&gt;
00181811 d blockend&lt;br /&gt;
001817fc d blockmagic&lt;br /&gt;
001814fc D calc_ok&lt;br /&gt;
00181500 d calc_print_errors&lt;br /&gt;
00928338 b cap.11161&lt;br /&gt;
009286d8 b cap.7377&lt;br /&gt;
00181520 d commands&lt;br /&gt;
001818a0 b completed.6625&lt;br /&gt;
009300e0 b conopt_fptrs&lt;br /&gt;
00927a54 b constants_inited&lt;br /&gt;
001817d0 d csdata&lt;br /&gt;
00183088 b dcps.2434&lt;br /&gt;
00926488 b default_library_path.7912&lt;br /&gt;
0092648c b default_solvers_path.7911&lt;br /&gt;
0018167c d defaultintegrators.6720&lt;br /&gt;
00927a60 b deriv_store.5961&lt;br /&gt;
00926564 b done.4160&lt;br /&gt;
00183090 b dref.2433&lt;br /&gt;
00927c80 b ds.3670&lt;br /&gt;
00927d60 b ds.4078&lt;br /&gt;
00928540 b ds.4252&lt;br /&gt;
00928060 b ds.4837&lt;br /&gt;
00928140 b ds.5578&lt;br /&gt;
001818a4 b dtor_idx.6627&lt;br /&gt;
009287c8 b elt.4095&lt;br /&gt;
009287cc b elt.4148&lt;br /&gt;
00926430 b errcount.6732&lt;br /&gt;
009263a4 b errcount.8155&lt;br /&gt;
00181670 d errname.6760&lt;br /&gt;
00928384 b error_statement_sym.4928&lt;br /&gt;
00928800 b exception_buffer&lt;br /&gt;
009287e0 b exception_status&lt;br /&gt;
00180a24 d f_first&lt;br /&gt;
00180a28 d f_fpe_top_of_stack&lt;br /&gt;
00926364 b f_fpe_traps&lt;br /&gt;
00180a2c d f_int_top_of_stack&lt;br /&gt;
00926368 b f_int_traps&lt;br /&gt;
001830e0 b f_mem_rec&lt;br /&gt;
001830c8 b f_memory_allocated&lt;br /&gt;
001830c4 b f_memory_length&lt;br /&gt;
001830c0 b f_memory_log_file&lt;br /&gt;
009242e0 b f_panic_callback_func&lt;br /&gt;
001830cc b f_peak_memory_usage&lt;br /&gt;
00180a30 d f_seg_top_of_stack&lt;br /&gt;
0092636c b f_seg_traps&lt;br /&gt;
00925300 b g_Asc_printVtables&lt;br /&gt;
00927acc b g_DeclarativeContext&lt;br /&gt;
00181320 d g_DefinitionErrorMessages&lt;br /&gt;
00927abc b g_EvaluationContext&lt;br /&gt;
00927ac0 b g_EvaluationForTable&lt;br /&gt;
00927ab8 b g_ExtVariablesTable&lt;br /&gt;
00927ab4 b g_ExternalFuncLibrary&lt;br /&gt;
00928018 b g_ExternalNodeStamps&lt;br /&gt;
00180e60 d g_abs_f&lt;br /&gt;
001812b0 D g_alt_ending&lt;br /&gt;
00926490 b g_ammarking&lt;br /&gt;
00180f20 d g_arccos_f&lt;br /&gt;
001810a0 d g_arccosh_f&lt;br /&gt;
00180ee0 d g_arcsin_f&lt;br /&gt;
00181060 d g_arcsinh_f&lt;br /&gt;
00180f60 d g_arctan_f&lt;br /&gt;
001810e0 d g_arctanh_f&lt;br /&gt;
00926494 b g_array_child_pool&lt;br /&gt;
00928444 b g_array_desc_count&lt;br /&gt;
00928448 b g_array_desc_list&lt;br /&gt;
0018309c b g_ascend_dllist&lt;br /&gt;
009264c0 b g_atom_bytes&lt;br /&gt;
009263b0 b g_atom_dim_ptr&lt;br /&gt;
0092bc50 b g_b_inst&lt;br /&gt;
0018187c d g_ba_elimdata&lt;br /&gt;
0092bc6c b g_ba_inst&lt;br /&gt;
0092863c b g_bad_rel_in_list&lt;br /&gt;
0092bc7c b g_bc_inst&lt;br /&gt;
00928434 b g_big_strings&lt;br /&gt;
00928438 b g_big_strings_cnt&lt;br /&gt;
00928640 b g_blockmethod&lt;br /&gt;
00180a60 d g_bt_data&lt;br /&gt;
00926398 b g_callargs&lt;br /&gt;
0092864c b g_case_number&lt;br /&gt;
00928030 b g_cbbccount&lt;br /&gt;
0092802c b g_cbbdcount&lt;br /&gt;
00181160 d g_cbrt_f&lt;br /&gt;
001812ec D g_check_dimensions_noisy&lt;br /&gt;
00926514 b g_clique_list&lt;br /&gt;
00181208 D g_compiler_counter&lt;br /&gt;
00928360 B g_compiler_timing&lt;br /&gt;
00180a34 D g_compiler_warnings&lt;br /&gt;
0092649c b g_cons&lt;br /&gt;
009263a0 b g_constant_type&lt;br /&gt;
009279d4 b g_copy_numnodes&lt;br /&gt;
00180d60 d g_cos_f&lt;br /&gt;
00180fe0 d g_cosh_f&lt;br /&gt;
00181120 d g_cube_f&lt;br /&gt;
00927f54 b g_current_module&lt;br /&gt;
0092bc48 b g_cursim&lt;br /&gt;
00926544 b g_def_child_bit_list&lt;br /&gt;
00926540 b g_def_child_desc_ptr&lt;br /&gt;
0092653c b g_def_child_list_ptr&lt;br /&gt;
009263b4 b g_default_dim_ptr&lt;br /&gt;
009263b8 b g_default_double&lt;br /&gt;
009263c0 b g_default_long&lt;br /&gt;
00928b4c b g_default_symbol&lt;br /&gt;
009263a8 b g_defaulted&lt;br /&gt;
00926534 b g_diagf&lt;br /&gt;
009263ac b g_dim_ptr&lt;br /&gt;
0092ac38 B g_dimen_list&lt;br /&gt;
0092ac30 b g_dimensionless&lt;br /&gt;
009286b4 b g_dis_tag&lt;br /&gt;
009284c0 b g_drt_depth&lt;br /&gt;
00927c28 b g_dummy_type&lt;br /&gt;
0092ac40 b g_dump_ht&lt;br /&gt;
0092bc40 b g_dump_inst_count&lt;br /&gt;
0092bc44 b g_dump_type_count&lt;br /&gt;
00926384 b g_end_identifier&lt;br /&gt;
001830a0 b g_env_list&lt;br /&gt;
00925340 b g_error_reporter_cache&lt;br /&gt;
00925328 b g_error_reporter_callback&lt;br /&gt;
00925320 b g_error_reporter_tree&lt;br /&gt;
00925324 b g_error_reporter_tree_current&lt;br /&gt;
00180c20 d g_exp_f&lt;br /&gt;
00927a50 b g_exprs_pool&lt;br /&gt;
00927c34 b g_externalmodel_type&lt;br /&gt;
009264fc b g_extra_parents&lt;br /&gt;
00926500 b g_extra_parents_sum&lt;br /&gt;
009264f8 b g_extra_paths&lt;br /&gt;
009288a0 b g_foreign_code_call_env&lt;br /&gt;
00927ad0 b g_forvar_recycle_list&lt;br /&gt;
00927ad4 b g_forvarfile&lt;br /&gt;
009289e0 B g_fpe_env&lt;br /&gt;
00927ad8 b g_free_store&lt;br /&gt;
001811a0 d g_func_list&lt;br /&gt;
00926370 b g_header_linenum&lt;br /&gt;
00180ea0 d g_hold_f&lt;br /&gt;
0092bc5c b g_i_inst&lt;br /&gt;
0092bc74 b g_ia_inst&lt;br /&gt;
0092bc60 b g_ic_inst&lt;br /&gt;
0017fce0 d g_instancetypenames&lt;br /&gt;
0018120c d g_instantiate_relns&lt;br /&gt;
00928a80 B g_int_env&lt;br /&gt;
001814f8 d g_iscomplete&lt;br /&gt;
0092844c b g_it_dummy_enum&lt;br /&gt;
00181310 d g_it_dummy_int&lt;br /&gt;
00927c00 b g_iteration&lt;br /&gt;
009284a8 b g_lcl_head&lt;br /&gt;
009284b8 b g_lcl_length&lt;br /&gt;
009284b4 b g_lcl_pivot&lt;br /&gt;
009284b0 b g_lcl_recycle&lt;br /&gt;
009284ac b g_lcl_tail&lt;br /&gt;
009284bc b g_lclrecycle_length&lt;br /&gt;
00181740 D g_linsolqr_timing&lt;br /&gt;
001818c0 b g_list_head_pool&lt;br /&gt;
00180c60 d g_ln_f&lt;br /&gt;
00180c08 D g_lnm_epsilon&lt;br /&gt;
00180ca0 d g_lnm_f&lt;br /&gt;
00180ce0 d g_log10_f&lt;br /&gt;
00927e40 b g_log_shortbuf&lt;br /&gt;
00927d54 b g_logrel_stack&lt;br /&gt;
00927c24 b g_logrel_type&lt;br /&gt;
00927f44 b g_logrelation_bvar_list&lt;br /&gt;
00927f48 b g_logrelation_satrel_list&lt;br /&gt;
00927f50 b g_logterm_pool&lt;br /&gt;
00181288 d g_logterm_ptrs&lt;br /&gt;
00927e34 b g_logwritfp&lt;br /&gt;
0092bc54 b g_lrel_inst&lt;br /&gt;
0092650c b g_maximum_children&lt;br /&gt;
009264f4 b g_maximum_parents&lt;br /&gt;
00926520 b g_maximum_relations&lt;br /&gt;
00926508 b g_minimum_children&lt;br /&gt;
009264f0 b g_minimum_parents&lt;br /&gt;
0092651c b g_minimum_relations&lt;br /&gt;
00926560 b g_missing&lt;br /&gt;
0092bc88 b g_mod_inst&lt;br /&gt;
009264b8 b g_model_bytes&lt;br /&gt;
00928000 b g_model_definition_methods&lt;br /&gt;
00926388 b g_model_parameters&lt;br /&gt;
00927f5c b g_module_list&lt;br /&gt;
00181220 d g_mpi_message&lt;br /&gt;
009287c4 b g_mtx_debug_redirect&lt;br /&gt;
0018185c d g_mtx_null_col_vector_data&lt;br /&gt;
0018181c d g_mtx_null_index_data&lt;br /&gt;
0018183c d g_mtx_null_mark_data&lt;br /&gt;
0018186c d g_mtx_null_row_vector_data&lt;br /&gt;
0018182c d g_mtx_null_sum_data&lt;br /&gt;
0018184c d g_mtx_null_vector_data&lt;br /&gt;
009301b4 b g_mtxerr&lt;br /&gt;
00927f6c b g_name_pool&lt;br /&gt;
009279e0 b g_names_needed&lt;br /&gt;
00927a58 b g_new_var_list&lt;br /&gt;
0092639c b g_notelist&lt;br /&gt;
00927f70 b g_notes_data_base&lt;br /&gt;
009264e8 b g_num_array_instances&lt;br /&gt;
009264dc b g_num_atom_children&lt;br /&gt;
009264bc b g_num_atom_instances&lt;br /&gt;
009264b0 b g_num_complex_instances&lt;br /&gt;
009264d8 b g_num_constant_all&lt;br /&gt;
009264cc b g_num_constant_bool&lt;br /&gt;
009264d0 b g_num_constant_int&lt;br /&gt;
009264c8 b g_num_constant_real&lt;br /&gt;
009264d4 b g_num_constant_sym&lt;br /&gt;
009264b4 b g_num_model_instances&lt;br /&gt;
00927f64 b g_num_names_cur&lt;br /&gt;
00927f68 b g_num_names_max&lt;br /&gt;
009264e0 b g_num_relation_instances&lt;br /&gt;
009264ec b g_num_unsel_instances&lt;br /&gt;
009284a4 b g_number&lt;br /&gt;
00927f90 b g_numlist_head_pool&lt;br /&gt;
00924300 b g_panic_outfile&lt;br /&gt;
00926390 b g_parameter_reduction&lt;br /&gt;
0092638c b g_parameter_wheres&lt;br /&gt;
0018130c d g_parse_count&lt;br /&gt;
00180a38 d g_parse_relns&lt;br /&gt;
009284c4 B g_parser_warnings&lt;br /&gt;
00927f9c b g_pending_count&lt;br /&gt;
00927fa0 b g_pending_list&lt;br /&gt;
00927fa4 b g_pending_list_end&lt;br /&gt;
00927fa8 b g_pending_pool&lt;br /&gt;
0092cca0 B g_plot_type&lt;br /&gt;
00927f94 b g_ppe_pool&lt;br /&gt;
001811fc d g_proc&lt;br /&gt;
00926378 b g_proc_name&lt;br /&gt;
00928004 b g_procframe_stop&lt;br /&gt;
00928008 b g_proto_count&lt;br /&gt;
0092ccc0 b g_proto_ht&lt;br /&gt;
0092bc94 b g_r_inst&lt;br /&gt;
0092bc78 b g_ra_inst&lt;br /&gt;
0092bc64 b g_rc_inst&lt;br /&gt;
00927a00 b g_recycle_expreval_stacks&lt;br /&gt;
00927f84 b g_recycled_npl&lt;br /&gt;
00926380 b g_refines_name&lt;br /&gt;
0092bc84 b g_rel_inst&lt;br /&gt;
00928040 b g_rel_stack&lt;br /&gt;
00928044 b g_rel_stack_pool&lt;br /&gt;
009264e4 b g_relation_guts&lt;br /&gt;
0092652c b g_relation_terms&lt;br /&gt;
00927c20 b g_relation_type&lt;br /&gt;
00928014 b g_relation_var_list&lt;br /&gt;
00928010 B g_relative_inst&lt;br /&gt;
00928618 b g_reuse&lt;br /&gt;
009286c4 b g_reuse&lt;br /&gt;
0092bc58 b g_s_inst&lt;br /&gt;
0092bc80 b g_sa_inst&lt;br /&gt;
0092bc90 b g_sc_inst&lt;br /&gt;
0092800c B g_search_inst&lt;br /&gt;
00928940 B g_seg_env&lt;br /&gt;
00928354 b g_set_pool&lt;br /&gt;
00927c30 b g_set_type&lt;br /&gt;
00928358 b g_sets_pool&lt;br /&gt;
00928220 b g_shortbuf&lt;br /&gt;
001812f4 d g_show_statement_detail&lt;br /&gt;
00927f4c b g_simplify_logrelations&lt;br /&gt;
001812cc D g_simplify_relations&lt;br /&gt;
0092835c B g_simulation_list&lt;br /&gt;
00180d20 d g_sin_f&lt;br /&gt;
00180fa0 d g_sinh_f&lt;br /&gt;
00927f60 b g_sldestroy&lt;br /&gt;
0092877c b g_solver_binary_type&lt;br /&gt;
009286c0 b g_solver_dis_type&lt;br /&gt;
00928778 b g_solver_int_type&lt;br /&gt;
00928780 b g_solver_semi_type&lt;br /&gt;
00928774 b g_solver_var_type&lt;br /&gt;
00180de0 d g_sqr_f&lt;br /&gt;
00180e20 d g_sqrt_f&lt;br /&gt;
00928414 b g_statio_flowtypenames&lt;br /&gt;
001812f8 d g_statio_label&lt;br /&gt;
009283a0 b g_statio_stattypenames&lt;br /&gt;
00928380 b g_statio_suppressions&lt;br /&gt;
00927b00 b g_string_buffer&lt;br /&gt;
00927f58 b g_string_modules_processed&lt;br /&gt;
00928428 b g_string_space&lt;br /&gt;
00927fc0 b g_strings&lt;br /&gt;
00928624 b g_strings&lt;br /&gt;
009286b8 b g_strings&lt;br /&gt;
009286d0 b g_strings&lt;br /&gt;
009286d4 b g_strings&lt;br /&gt;
00928758 b g_strings&lt;br /&gt;
00926498 b g_suppressions&lt;br /&gt;
0092bc8c b g_sym_inst&lt;br /&gt;
0092bc4c b g_syma_inst&lt;br /&gt;
00928430 b g_symbol_collisions&lt;br /&gt;
0092842c b g_symbol_size&lt;br /&gt;
0092dcc0 b g_symbol_table&lt;br /&gt;
00928614 b g_symbol_values_list&lt;br /&gt;
00927c40 b g_symbols&lt;br /&gt;
00928460 b g_symbols&lt;br /&gt;
009287ac b g_symbols&lt;br /&gt;
0092bc68 b g_symc_inst&lt;br /&gt;
00180da0 d g_tan_f&lt;br /&gt;
00181020 d g_tanh_f&lt;br /&gt;
0092843c b g_temporary_var_list&lt;br /&gt;
00928440 b g_temporary_var_recycle&lt;br /&gt;
0092801c b g_term_pool&lt;br /&gt;
001812d0 d g_term_ptrs&lt;br /&gt;
009284c8 b g_tlibs_depth&lt;br /&gt;
0092ab80 b g_token_counts&lt;br /&gt;
00926530 b g_total_array_children&lt;br /&gt;
00926510 b g_total_children&lt;br /&gt;
00926504 b g_total_parents&lt;br /&gt;
00926528 b g_total_reals_in_rels&lt;br /&gt;
00926524 b g_total_relations&lt;br /&gt;
00926518 b g_total_variables&lt;br /&gt;
009264c4 b g_tree_bytes&lt;br /&gt;
0092ac34 b g_trig_dimen&lt;br /&gt;
00927c04 b g_trychildexpansion_errmessage&lt;br /&gt;
009264ac b g_type_count_list&lt;br /&gt;
0092637c b g_type_name&lt;br /&gt;
00926394 b g_typeargs&lt;br /&gt;
00927c08 b g_unasscon_count&lt;br /&gt;
00928500 b g_unit_base_name&lt;br /&gt;
009284f0 b g_unit_explain_error_strings&lt;br /&gt;
00927adc b g_units_alloc&lt;br /&gt;
009284ec b g_units_collisions&lt;br /&gt;
001814c0 d g_units_errors.4640&lt;br /&gt;
0092f0e0 B g_units_hash_table&lt;br /&gt;
0092ecc0 b g_units_id_space&lt;br /&gt;
009263c4 b g_units_ptr&lt;br /&gt;
009284e8 b g_units_size&lt;br /&gt;
009284e0 b g_units_str&lt;br /&gt;
009284e4 b g_units_str_len&lt;br /&gt;
00927f98 b g_unresolved_count&lt;br /&gt;
00926374 b g_untrapped_error&lt;br /&gt;
00181204 D g_use_copyanon&lt;br /&gt;
0092852c b g_value_pool&lt;br /&gt;
00928754 b g_var_tag&lt;br /&gt;
0092bc70 b g_when_inst&lt;br /&gt;
00927c2c b g_when_type&lt;br /&gt;
0092ac3c b g_wild_dimen&lt;br /&gt;
0092642c b g_workbuf&lt;br /&gt;
00180a44 d g_workbuf_len.6555&lt;br /&gt;
00928214 b g_writfp&lt;br /&gt;
00928348 b glob_done&lt;br /&gt;
00927f40 b glob_lrel&lt;br /&gt;
00928340 b glob_rel&lt;br /&gt;
00928344 b glob_varnum&lt;br /&gt;
009279d0 b global_command_list&lt;br /&gt;
00928530 b global_visit_num&lt;br /&gt;
009287bc b hhrowlist.6528&lt;br /&gt;
00183074 b i.2578&lt;br /&gt;
00926354 b i.2755&lt;br /&gt;
00927ae0 b importhandler_library&lt;br /&gt;
00927ae4 b importhandler_sharedpointers&lt;br /&gt;
00926538 b init.5484&lt;br /&gt;
00928794 b init.6246&lt;br /&gt;
009287a0 b init.6716&lt;br /&gt;
0092878c b inst&lt;br /&gt;
009287c0 b last_value_matrix&lt;br /&gt;
00928798 b lastsolver.6445&lt;br /&gt;
00928330 b lhscap.9848&lt;br /&gt;
009287b8 b listlen.6529&lt;br /&gt;
00928784 b loaded.3887&lt;br /&gt;
00180ba0 d metadata.4158&lt;br /&gt;
001817e0 d mtxmagic&lt;br /&gt;
00928700 b name.6123&lt;br /&gt;
00928660 b name.6164&lt;br /&gt;
00181744 d names.4315&lt;br /&gt;
00181760 d names.4320&lt;br /&gt;
0018307c b newsize.2576&lt;br /&gt;
0092635c b newsize.2753&lt;br /&gt;
00181504 d nextid.6241&lt;br /&gt;
001812c8 d nostr.4857&lt;br /&gt;
00181688 d nrels.7185&lt;br /&gt;
0018168c d nrels.7199&lt;br /&gt;
009286fc b nuldev.5971&lt;br /&gt;
00181690 d nvars.7213&lt;br /&gt;
00183080 b oldsize.2575&lt;br /&gt;
00926360 b oldsize.2752&lt;br /&gt;
001817f2 d permmagic&lt;br /&gt;
00928648 b poly.3808&lt;br /&gt;
00928350 b poly.3924&lt;br /&gt;
00928644 b poly_cap.3809&lt;br /&gt;
0092834c b poly_cap.3925&lt;br /&gt;
00927a5c b previous_store.5962&lt;br /&gt;
0092833c b ptr.11160&lt;br /&gt;
009286dc b ptr.7376&lt;br /&gt;
00183078 b punt.2577&lt;br /&gt;
00926358 b punt.2754&lt;br /&gt;
00183098 b ref.2432&lt;br /&gt;
00928334 b rel.9847&lt;br /&gt;
009287a4 b reported_already.8633&lt;br /&gt;
009287a8 b reported_already.8653&lt;br /&gt;
00926580 b result.4159&lt;br /&gt;
009286e4 b rfilter.7742&lt;br /&gt;
0092832c b rhscap.9849&lt;br /&gt;
001817c0 d rsdata&lt;br /&gt;
001812f0 d safe_print_errors&lt;br /&gt;
0017fda0 d slv_reg&lt;br /&gt;
00928320 b soln_list.9691&lt;br /&gt;
00926418 b start_line&lt;br /&gt;
00928534 b stopnum.3912&lt;br /&gt;
00181508 d suppress_rel_flag.6780&lt;br /&gt;
00928788 b sys&lt;br /&gt;
001812a4 d unk.4785&lt;br /&gt;
00925304 b use_xterm_color.2533&lt;br /&gt;
009286ec b vfilter.7802&lt;br /&gt;
009286f4 b vfilter.7892&lt;br /&gt;
00928020 b warnexpt.5603&lt;br /&gt;
00928028 b warnexpt.5731&lt;br /&gt;
00928024 b warnfdiff.5732&lt;br /&gt;
009263f4 b yy_buffer_stack&lt;br /&gt;
009263f0 b yy_buffer_stack_max&lt;br /&gt;
009263ec b yy_buffer_stack_top&lt;br /&gt;
009263f8 b yy_c_buf_p&lt;br /&gt;
0092643c b yy_did_buffer_switch_on_eof&lt;br /&gt;
00926448 b yy_full_lp&lt;br /&gt;
00926440 b yy_full_match&lt;br /&gt;
0092644c b yy_full_state&lt;br /&gt;
00926434 b yy_hold_char&lt;br /&gt;
009263fc b yy_init&lt;br /&gt;
00180a40 d yy_line&lt;br /&gt;
0092640c b yy_looking_for_trail_begin&lt;br /&gt;
00926444 b yy_lp&lt;br /&gt;
00926410 b yy_more_offset&lt;br /&gt;
00926438 b yy_n_chars&lt;br /&gt;
00926414 b yy_prev_more_offset&lt;br /&gt;
00926400 b yy_start&lt;br /&gt;
00926404 b yy_state_buf&lt;br /&gt;
00926408 b yy_state_ptr&lt;br /&gt;
0092ab64 b yytext_ptr&lt;br /&gt;
009263e8 b zz__flex_debug&lt;br /&gt;
00928b50 b zz_char&lt;br /&gt;
009263e0 b zz_in&lt;br /&gt;
0092ab60 b zz_leng&lt;br /&gt;
00180a3c d zz_lineno&lt;br /&gt;
00928b20 b zz_lval&lt;br /&gt;
00928b54 b zz_nerrs&lt;br /&gt;
009263e4 b zz_out&lt;br /&gt;
00928b60 b zz_text&lt;br /&gt;
john@thunder:~/ascend$&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Static variables ==&lt;br /&gt;
&lt;br /&gt;
Another place where quasi-global variables can occur is as static variables within functions. It needs to be assessed whether the above listing includes those types of variables.&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Building_ASCEND&amp;diff=3361</id>
		<title>Building ASCEND</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Building_ASCEND&amp;diff=3361"/>
		<updated>2012-03-11T21:30:17Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: /* Ubuntu 11.10 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page contains specific instructions for building ASCEND on systems that we know about. First you should read about [[VersionManagement]] for information on how to get hold of the source code.&lt;br /&gt;
&lt;br /&gt;
Building ASCEND (as of March 2006) requires the [http://www.scons.org/ SCons] build tool. In our opinion, SCons is a significant advance on Autotools, so we encourage you to give it a chance, if you&#039;re not familiar with it. If you are interested in the implementation details of our build scripts, please see our [[developer&#039;s manual]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; If you are having trouble building ASCEND, it might be worth checking out the [[BuildBot]] (link [http://ascend.cheme.cmu.edu:8011/ here]) to see if the latest sources have compiled correctly on our test server.&lt;br /&gt;
&lt;br /&gt;
== General instructions ==&lt;br /&gt;
&lt;br /&gt;
Building with SCons (as of Jun 2010, we recommend version 1.x) should be as simple as typing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;scons&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Get info on the [[SCons_options_for_building_ASCEND|current build options]] by typing &amp;lt;tt&amp;gt;scons -Qh&amp;lt;/tt&amp;gt;. To clean up after your build, type &amp;lt;tt&amp;gt;scons -c&amp;lt;/tt&amp;gt;. To include any building options, type &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; followed by options. For instance, type &amp;lt;tt&amp;gt;scons WITH_LOCAL_HELP = /usr/local/share/ascend/manual&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Any build option that you see in &amp;lt;tt&amp;gt;scons -Qh&amp;lt;/tt&amp;gt; can be entered into a file &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; that you can create in the root source directory (ie &amp;lt;tt&amp;gt;~/src/ascend/trunk&amp;lt;/tt&amp;gt;). For example, you might create a config.py file like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;WITH_LOCAL_HELP = /usr/local/share/ascend/manual&lt;br /&gt;
DEFAULT_ASCENDLIBRARY = /usr/local/share/ascend/models&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So, if you want to set configuration options so that they always get applied, edit your &amp;lt;tt&amp;gt;config.py&amp;lt;/tt&amp;gt; file.&lt;br /&gt;
&lt;br /&gt;
On top of that, you should also be aware that the SCons build will cache your build options in a file called &amp;lt;tt&amp;gt;options.cache&amp;lt;/tt&amp;gt;. That means that if you type a scons command with command-line options, then later without those command line options, the options from the first run will still be there, because they will have been saved in the cache.&lt;br /&gt;
&lt;br /&gt;
A major fiddle with SCons, especially on Windows, is ensuring that all the required programs are present in your path. You need to install Bison (from the GnuWin32 project). For SCons to run correctly from the MSYS command line, you will also need to add &amp;lt;tt&amp;gt;/c/Python25/Scripts:/c/Python25&amp;lt;/tt&amp;gt; to your path, so that the &#039;scons&#039; script is discovered.&lt;br /&gt;
&lt;br /&gt;
The SCons system will manage the building of FORTRAN components and is able to link to an installed version of CONOPT.&lt;br /&gt;
&lt;br /&gt;
For instructions on building with Autotools, see the old versions of this page. We&#039;re not actively supporting the Autotools build any more.&lt;br /&gt;
&lt;br /&gt;
Running &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; will create a locally-executable version of ASCEND that can be run from the source tree (&amp;lt;tt&amp;gt;pygtk/ascdev&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;tcltk/generic/interface/ascend4&amp;lt;/tt&amp;gt;, possibly subject to some environment variable settings. Alternatively, you can install ASCEND and run it from a &#039;proper&#039; location such as ~/bin/ascend or /usr/bin/ascend, etc. To install files for ASCEND, run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;scons install INSTALL_PREFIX=/usr/local&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above will install the PyGTK GUI at /usr/local/bin/ascend and the Tcl/Tk GUI at /usr/local/bin/ascend4. Other sensible values of INSTALL_PREFIX include &amp;lt;tt&amp;gt;~/ascend&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;~&amp;lt;/tt&amp;gt;, which will install the PyGTK GUI at ~/ascend/bin/ascend and ~/bin/ascend respectively. These latter ones are good if you don&#039;t have root privileges on your system. There are a range of other INSTALL_* options available with our build script, type &amp;lt;tt&amp;gt;scons -qH&amp;lt;/tt&amp;gt; to see them. Also note the importance of the &amp;lt;tt&amp;gt;ABSOLUTE_PATHS&amp;lt;/tt&amp;gt; option for our build script. Note then when you run &#039;&amp;lt;tt&amp;gt;scons install&amp;lt;/tt&amp;gt;&#039; you don&#039;t get all the files in the model library, you only get a filter set according to the [[PACKAGE metafiles]] contained in the [[ModelLibrary]].&lt;br /&gt;
&lt;br /&gt;
Some more details on the implementation of the ASCEND build process via SCons is given in [[Developer&#039;s_Manual#Build_system]].&lt;br /&gt;
&lt;br /&gt;
== Tcl/Tk GUI ==&lt;br /&gt;
&lt;br /&gt;
In order to build the original Tck/Tk GUI, you need a Tcl/Tk distribution. Recently we have modified ASCEND so that it can run with Tcl/Tk 8.4. Standard Tcl/Tk binary packages can be used, such as those included in Fedora Core 5 (Note, the tcl-devel and tk-devel packages required as well). For Windows they available from ActiveState, see:&lt;br /&gt;
&lt;br /&gt;
http://www.activestate.com/activetcl&lt;br /&gt;
&lt;br /&gt;
At present, detection of Tcl/Tk is not particularly sophisticated. &amp;lt;tt&amp;gt;SConstruct&amp;lt;/tt&amp;gt; just looks for &amp;lt;tt&amp;gt;tcl.h&amp;lt;/tt&amp;gt; in your standard include path. So you might need to tweak. Check the &amp;lt;tt&amp;gt;scons -h&amp;lt;/tt&amp;gt; list of configuration options for more. On Debian-based systems, try something like &amp;lt;tt&amp;gt;scons TCL_CPPPATH=/usr/include/tcl8.4&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Python interface ==&lt;br /&gt;
&lt;br /&gt;
See PythonWrapper for more information. You will need to have SWIG 1.3.24 or newer and Python 2.4 or newer installed. These are both easy to install for both Windows and Linux.&lt;br /&gt;
&lt;br /&gt;
To run the PyGTK interface requires more dependencies, see the PythonWrapper page for full details.&lt;br /&gt;
&lt;br /&gt;
== Instructions for Linux ==&lt;br /&gt;
&lt;br /&gt;
In general, see [[Prerequisites for Linux]]. You will be using &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; to build ASCEND. We update these distribution-specific notes at the time that we implement support for that particular distro, so it&#039;s possible that if you&#039;re using an old distro, you may need to go back and use an old version of the code.&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu 11.10 ===&lt;br /&gt;
&lt;br /&gt;
Tested with thunk {{changeset|3840}} on Ubuntu Oneiric 11.10 32-bit in a VirtualBox machine.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sh&amp;gt;&lt;br /&gt;
sudo apt-get install subversion swig g++ gfortran python-dev scons flex bison \&lt;br /&gt;
 graphviz-dev libsundials-serial-dev liblapack-dev libblas-dev ipython \&lt;br /&gt;
 python-matplotlib&lt;br /&gt;
svn co svn://ascend4.org/code/trunk ascend&lt;br /&gt;
cd ascend&lt;br /&gt;
scons&lt;br /&gt;
pygtk/ascdev models/johnpye/testlog10.a4c&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are some warnings &#039;Unable to locate theme engine in module_path: &amp;quot;pixmap&amp;quot;&#039; if gtk-engines-pixbuf is not installed, but basically seems to be working fine. If you want to create a binary package suitable for this release,see [[dtar]], but note that currently (Oct 2011) we haven&#039;t yet made the necessary changes to related {{src|debian}} file(s). Note that Oneiric comes with SWIG 1.3.40, so no problems with {{bug|517}} at this stage.&lt;br /&gt;
&lt;br /&gt;
Note yet tested: [[IDA]], [[IPOPT]], [[CONOPT]], [[dtar]].&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu 11.04 ===&lt;br /&gt;
&lt;br /&gt;
Tested with trunk {{changeset|3618}} on Ubuntu Natty 11.04 32-bit. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sh&amp;gt;&lt;br /&gt;
sudo apt-get install subversion swig g++ gfortran python-dev scons flex bison \&lt;br /&gt;
 graphviz-dev libsundials-serial-dev liblapack-dev tcl8.5-dev tk8.5-dev \&lt;br /&gt;
 libtktable2.9 libblas-dev ipython python-matplotlib&lt;br /&gt;
scons -j2&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not yet tested: [[CONOPT]], [[IPOPT]], [[IDA]], [[dtar]]. Otherwise all appears fine when running with &amp;lt;tt&amp;gt;pygtk/ascdev&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To install, try &amp;lt;tt&amp;gt;sudo scons install INSTALL_PREFIX=/usr/local&amp;lt;/tt&amp;gt;. After that, you may need to &amp;lt;tt&amp;gt;export LD_LIBRARY_PATH=/usr/local/lib&amp;lt;/tt&amp;gt; (or &amp;lt;tt&amp;gt;lib64&amp;lt;/tt&amp;gt;) before it runs (with the command &amp;lt;tt&amp;gt;ascend&amp;lt;/tt&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
An ASCEND package can be created using &amp;lt;tt&amp;gt;scons dist&amp;lt;/tt&amp;gt; and [[dtar]]. This package seems to work fine, except for some missing integration into the new Unity GUI shell.&lt;br /&gt;
 &lt;br /&gt;
If IPOPT 3.9.x is also installed (see instructions for 10.04 below) then ASCEND will fail to load external libraries unless the correct LD_LIBRARY_PATH has bee set for IPOPT (/usr/lib/coin:/usr/lib/coin/ThirdParty). It is expected that testing with IPOPT 3.10 will resolve this problem.&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu 10.10 ===&lt;br /&gt;
&lt;br /&gt;
ASCEND compiles fine on Ubuntu 10.10, but you need to use the latest code from the &#039;trunk&#039; of our [[VersionManagement|subversion repo]]. Subversion r3082 corrects a bug that was preventing use of SCons 2.x, as supplied as part of this distro. Otherwise, required packages are the same as for 10.04, see below. It is recommended that all &#039;optional&#039; packages are installed at the time of building ASCEND.&lt;br /&gt;
&lt;br /&gt;
For IPOPT, which is an optional component of ASCEND, you should see the build instructions [[IPOPT|here]].&lt;br /&gt;
&lt;br /&gt;
It appears that in Ubuntu 10.10, GraphViz has been upgraded and is not longer compatible with ASCEND. ASCEND should build fine without it, although you will be missing the [[incidence graph]] feature as a result (see {{bug|443}}).&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu 10.04 ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt;There is currently a problem with building ASCEND on this platform, due to an error thrown by SWIG version 1.3.40 (ASCEND {{bug|403}}). This error is not seen when running SWIG version 1.3.38 or earlier. &#039;&#039;A temporary workaround is to install the Ubuntu Karmic version if SWIG, available [http://packages.ubuntu.com/karmic/i386/swig/download from here].&#039;&#039;&amp;lt;/s&amp;gt; (this bug is now fixed in the subversion repo)&lt;br /&gt;
&lt;br /&gt;
For [[IPOPT]], which is an optional solver that can be used by ASCEND, you should additionally see the build instructions [[IPOPT|here]].&lt;br /&gt;
&lt;br /&gt;
To build ASCEND on a clean Ubuntu 10.04 box, the following packages were required (as of trunk r2777):&lt;br /&gt;
&lt;br /&gt;
* subversion&lt;br /&gt;
* swig &amp;lt;s&amp;gt;&#039;&#039;(see note above)&#039;&#039;&amp;lt;/s&amp;gt;&lt;br /&gt;
* g++&lt;br /&gt;
* gfortran&lt;br /&gt;
* python-dev&lt;br /&gt;
* scons&lt;br /&gt;
&lt;br /&gt;
The following are optional but recommended:&lt;br /&gt;
&lt;br /&gt;
* flex&lt;br /&gt;
* bison&lt;br /&gt;
* graphviz-dev&lt;br /&gt;
* libsundials-serial-dev&lt;br /&gt;
* liblapack-dev (used by IPOPT)&lt;br /&gt;
* tcl8.5-dev&lt;br /&gt;
* tk8.5-dev&lt;br /&gt;
* libtktable2.9&lt;br /&gt;
* libblas-dev&lt;br /&gt;
&lt;br /&gt;
At runtime, the following packages will add capability to ASCEND:&lt;br /&gt;
* ipython&lt;br /&gt;
* python-matplotlib&lt;br /&gt;
&lt;br /&gt;
=== Kubuntu 10.04 ===&lt;br /&gt;
&lt;br /&gt;
Building on Kubuntu (KDE) is identical to Ubuntu (GNOME) with the exception that python-gtk2 and python-glade2 must be installed before running the resulting program. This was tested with trunk r3039. At this point in time, building also requires the package libgsl0-dev, because of some dependencies in [[FPROPS]] which need to be removed/made optional.&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu 9.10 ===&lt;br /&gt;
&lt;br /&gt;
Ongoing development of ASCEND is primarily done on this Ubuntu 9.10. Although ASCEND builds against the standard Ubuntu packages for Sundials, you will obtain better functionality with the [[IDA]] solver if you use a version built from latest 2.4.0 source code. The latest release fixes problems with boundary-crossing during integration.&lt;br /&gt;
&lt;br /&gt;
To build ASCEND on a clean Ubuntu 9.10 box, the following packages are required (as of trunk r2667):&lt;br /&gt;
&lt;br /&gt;
* scons&lt;br /&gt;
* swig&lt;br /&gt;
* python-dev&lt;br /&gt;
* scons&lt;br /&gt;
* g++&lt;br /&gt;
* gfortran&lt;br /&gt;
&lt;br /&gt;
The following packages are optional:&lt;br /&gt;
&lt;br /&gt;
* libsundials-serial-dev&lt;br /&gt;
* graphviz-dev&lt;br /&gt;
* flex&lt;br /&gt;
* bison&lt;br /&gt;
* libblas-dev&lt;br /&gt;
* tcl8.5-dev&lt;br /&gt;
* tk8.5-dev&lt;br /&gt;
* tktable2.9&lt;br /&gt;
&lt;br /&gt;
At runtime, the following packages will add capability to ASCEND:&lt;br /&gt;
&lt;br /&gt;
* ipython&lt;br /&gt;
* python-matplotlib&lt;br /&gt;
&lt;br /&gt;
For the [[IPOPT]] solver, you will also need to build that separately from source -- see [[IPOPT]] for details.&lt;br /&gt;
For the [[CONOPT]] and [[CMSlv]] solvers, you must obtain libconsub3.so, see [[CONOPT]] for details.&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu 9.04 ===&lt;br /&gt;
&lt;br /&gt;
ASCEND should build on this system without any problems, providing the prerequisited that you need are installed. Watch closely the &#039;scons&#039; output for fleeting comments which may suggest that you&#039;re missing a library or a header file, etc. Prereqs should be the same as for Ubuntu 8.04.&lt;br /&gt;
&lt;br /&gt;
Note that after updating to Ubuntu 9.04, you will probably need to rebuild and reinstall things like IPOPT and CONOPT, as gfortran errors seem to arise otherwise.&lt;br /&gt;
&lt;br /&gt;
For the [[IDA]] solver, you may need to add the scons option SUNDIALS_CPPPATH=/usr/include/sundials to make this integrator build correctly.&lt;br /&gt;
&lt;br /&gt;
=== Ubuntu 8.04 LTS ===&lt;br /&gt;
&lt;br /&gt;
ASCEND built fine on Ubuntu 8.0.4 LTS when we last tried it. Numerous prerequisites must be installed, but all of these except IPOPT and CONOPT are currently available from the Ubuntu repositories. Specifically, check libsundials-serial-dev, swig, flex, bison, python-dev, tk-dev, libtktable2.9. Haven&#039;t yet tested with CONOPT, so conditional modelling has not yet been checked.&lt;br /&gt;
&lt;br /&gt;
Special treatment for the gfortran compiler is no longer required (as was required for Ubuntu 7.10).&lt;br /&gt;
&lt;br /&gt;
Building of a .deb package can be performed using the [[dtar]] tool included in the source distribution. Usage: scons dist &amp;amp;amp;&amp;amp;amp; ~/ascend/tools/dtar/dtar ~/ascend/dist/ascend-0.9.5.116.tar.bz2 ~/ascend/dist/debian.tar.gz.&lt;br /&gt;
&lt;br /&gt;
Ubuntu 8.04 uses GtkSourceView2 instead of the earlier version, with the result that source code highlighting in GEdit using a different &amp;lt;tt&amp;gt;.lang&amp;lt;/tt&amp;gt; file. We have written a new version of this file, see the page on [[syntax highlighting]] for more info.&lt;br /&gt;
&lt;br /&gt;
Currently, LyX 1.5 is not available on Ubuntu, and the manual .lyx files require this newer version. So for the moment, you must use &amp;lt;tt&amp;gt;scons WITH_DOC_BUILD=0&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
ASCEND has been runninng on earlier Ubuntu versions, right back to version 5.10.&lt;br /&gt;
&lt;br /&gt;
=== CentOS 5.6 ===&lt;br /&gt;
&lt;br /&gt;
The following steps have been tested using a clean virtual machine created using the CentOS 5.6 net installer for x86_64.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sh&amp;gt;&lt;br /&gt;
# log in as root...&lt;br /&gt;
su&lt;br /&gt;
yum install scons subversion tk-devel flex bison gcc-gfortran gcc-c++ python-devel sundials-devel graphviz-devel &lt;br /&gt;
wget http://pkgs.repoforge.org/scons/scons-1.2.0-1.el5.rf.noarch.rpm&lt;br /&gt;
rpm -i scons-1.2.0-1.el5.rf.noarch.rpm&lt;br /&gt;
exit&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, back as &#039;normal&#039; user, obtain a copy of the ASCEND source code from our [[VersionManagement|svn info]] as folder &#039;ascend&#039; (we tried with trunk revision 3601), then&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sh&amp;gt;&lt;br /&gt;
cd ascend&lt;br /&gt;
scons&lt;br /&gt;
# ascend now runs via &#039;pygtk/ascdev&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
If you want to use Matplotlib for plotting in ASCEND with CentOS, try using http://repoforge.org/use/ and &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=sh&amp;gt;&lt;br /&gt;
install python-matplotlib python-numpy&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Fedora 11 ===&lt;br /&gt;
&lt;br /&gt;
The following steps build ASCEND on a clean Fedora 11 machine (I tested using the Live CD installed to a qemu/kvm virtual machine):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sh&amp;quot;&amp;gt;su&lt;br /&gt;
yum install scons subversion tk-devel flex bison gcc-gfortran gcc-c++ python-devel sundials-devel graphviz-devel swig&lt;br /&gt;
scons&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;s&amp;gt;Currently (as of 16 Jun 2009), the above results in a error message from g++ while compiling the SWIG output. See {{bug|403}}. Testing on Windows has shown that SWIG 1.3.39 and 1.3.40 have this problem, but 1.3.36 does not have this problem.&amp;lt;/s&amp;gt; &#039;&#039;This bug is fixed in the pre-0.9.8 code from our SVN server.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Fedora 9 ===&lt;br /&gt;
&lt;br /&gt;
ASCEND builds without any problems on Fedora 9. You need to install several packages first, including swig, tk-devel, python-devel, scons, flex, bison, gcc-gfortran, gcc-c++. There may be some problems getting the GraphViz and CUnit-related functionality working, let us know if you have problems with that. -- JP, Jun 2008.&lt;br /&gt;
&lt;br /&gt;
You can build an RPM version of ASCEND using &amp;lt;tt&amp;gt;scons dist&amp;lt;/tt&amp;gt; followed by &amp;lt;tt&amp;gt;rpm -ta ascend-0.9.5.116.tar.bz2&amp;lt;/tt&amp;gt;, providing you have RPM correctly set up. See also [[Building an RPM Package for ASCEND]].&lt;br /&gt;
&lt;br /&gt;
=== OpenSUSE ===&lt;br /&gt;
&lt;br /&gt;
OpenSUSE does not provide an up to date version of SCons (as of this writing, suse 10.2 comes with scons-0.96.91-37). You will need to download a newer version (0.96.93) ([http://sourceforge.net/project/showfiles.php?group_id=30337&amp;amp;package_id=22359 from SF.net].&lt;br /&gt;
Do not try 0.97 SCons, as it is not yet supported by the ASCEND SConscripts on the SUSE platform.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Update (Mar 2010)&#039;&#039; it is suggested that you try latest SCons 1.x if possible, and report your experiences here.&lt;br /&gt;
&lt;br /&gt;
=== Arch Linux ===&lt;br /&gt;
&lt;br /&gt;
To build ASCEND on Arch Linux, follow these steps:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;sudo pacman -S gcc gcc-fortran flex bison python scons swig tcl tk graphviz blas&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download and build sundials manually (see [[Prerequisites for Linux]]).&lt;br /&gt;
&lt;br /&gt;
Then follow the [[Building_ASCEND#General_instructions|Genereal instructions]] (running scons and scons install).&lt;br /&gt;
&lt;br /&gt;
If you have problem with SWIG 1.3.40 (scons reports that SWIG package was not found), download older version of [http://www.swig.org SWIG](1.3.38 worked for me, 1.3.24 didn&#039;t) and build it manually (./configure, make, make install). Then re-run swig with parameter &amp;lt;tt&amp;gt;SWIG=/usr/local/bin/swig&amp;lt;/tt&amp;gt; (or different location where you installed SWIG).&lt;br /&gt;
&lt;br /&gt;
When running ascend script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;LDPATH = [INSTALL_LIB] + GTKLIBPATH + LDPATH&lt;br /&gt;
TypeError: can only concatenate list (not &amp;amp;quot;NoneType&amp;amp;quot;) to list&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;LDPATH = [INSTALL_LIB] + GTKLIBPATH + LDPATH&amp;lt;/source&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;if GTKLIBPATH:&lt;br /&gt;
	LDPATH = [INSTALL_LIB] + GTKLIBPATH + LDPATH&lt;br /&gt;
else:&lt;br /&gt;
&lt;br /&gt;
	LDPATH = [INSTALL_LIB] + LDPATH&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(found [http://www.mail-archive.com/ascend-sim-users@lists.sourceforge.net/msg00089.html here]).&lt;br /&gt;
&lt;br /&gt;
=== Gentoo ===&lt;br /&gt;
&lt;br /&gt;
Some details for build ASCEND on Gentoo Linux are on a sub-page at [[Building ASCEND/Gentoo]].&lt;br /&gt;
&lt;br /&gt;
== Instructions for Windows ==&lt;br /&gt;
&lt;br /&gt;
The only currently-supported way to build ASCEND on Windows is using MinGW/MSYS and the GCC compiler. There has previously been partial success with the Microsoft compiler tools, but these are not currently actively being used or tested.&lt;br /&gt;
&lt;br /&gt;
=== Windows 7 (64-bit target, with 64-bit Python and 64-bit GTK+) ===&lt;br /&gt;
&lt;br /&gt;
This is now supported! See [[Building ASCEND for 64-bit Windows]]. We haven&#039;t yet released a binary though, due to a few minor outstanding tasks to do with building the installer package.&lt;br /&gt;
&lt;br /&gt;
=== Windows 7 (32-bit target) ===&lt;br /&gt;
&lt;br /&gt;
(ongoing!)&lt;br /&gt;
&lt;br /&gt;
* Install &#039;mingw-get-inst&#039; from http://sourceforge.net/projects/mingw/files/MinGW/, selecting C++ and Fortran compilers as well as MSYS Developer Kit (last item on the list).&lt;br /&gt;
* From the Start menu, launch MinGW Shell and use it for any command-line commands in the following.&lt;br /&gt;
* &amp;lt;tt&amp;gt;mingw-get install msys-flex msys-bison&amp;lt;/tt&amp;gt;&lt;br /&gt;
* Install [http://www.python.org/ftp/python/2.7.2/python-2.7.2.msi Python 2.7.2]&lt;br /&gt;
* Install [http://prdownloads.sourceforge.net/scons/scons-2.0.1.win32.exe SCons 2.0.1] (be sure to right-click and Run as Administrator)&lt;br /&gt;
* Install [http://sourceforge.net/projects/swig/files/swigwin/swigwin-2.0.4/swigwin-2.0.4.zip/download swigwin 2.0.4]&lt;br /&gt;
* Install [http://ftp.acc.umu.se/pub/GNOME/binaries/win32/pygtk/2.22/pygtk-all-in-one-2.22.6.win32-py2.7.msi pygtk-all-in-one-2.22.6.win32-py2.7.msi]&lt;br /&gt;
* Obtain a copy of the ASCEND source code and untar it to ~/ascend. Best option is to use the &#039;svn trunk&#039; code, at this stage (Aug 2011).&lt;br /&gt;
&lt;br /&gt;
=== Windows 7 64-bit with 32-bit Python ===&lt;br /&gt;
&lt;br /&gt;
We are currently in the process of testing the ASCEND build on 64-bit Windows 7, running via Virtual Box on a Dell Optiplex 980, with the host OS being Ubuntu 10.04.2 LTS.&lt;br /&gt;
&lt;br /&gt;
* install &#039;mingw-get-inst&#039;, selecting to install C, C++ and Fortran compilers, plus the MSYS Basic System and the MinGW Developer Toolkit.&lt;br /&gt;
* install the [http://sourceforge.net/projects/win32svn/files/1.6.15/Setup-Subversion-1.6.15.msi/download win32svn package] from SF.net&lt;br /&gt;
* check out the source code from our [[VersionManagement|svn trunk]].&lt;br /&gt;
* download [http://www.python.org/download Python 2.7.1] 32-bit version and install with default settings. Python 3 is likely still to cause problems with our code, and we haven&#039;t tested it yet. We tried using the 64-bit version of Python 2.7.1, but SCons didn&#039;t seem to be able to detect it.&lt;br /&gt;
* download [http://sourceforge.net/projects/win32svn/files/1.6.15/Setup-Subversion-1.6.15.msi/download Glade3] and install it. &lt;br /&gt;
* download [http://sourceforge.net/projects/scons/files/scons/2.0.1/scons-2.0.1.win32.exe/download SCons 2.0.1] and install it by right-clicking and &#039;run as administrator&#039; (note that failing to do this might have been the reason that we failed with the 64-bit version of Python, above -- if you get 64-bit Python to work, let us know).&lt;br /&gt;
* Add c:\Python27 and c:\Python27\Scripts to your PATH.&lt;br /&gt;
* download [http://sourceforge.net/projects/swig/files/swigwin/swigwin-1.3.40/swigwin-1.3.40.zip/download swigwin 1.3.40] and unzip it into your MSYS home directory, then add ~/swigwin-1.3.40 to your PATH.&lt;br /&gt;
* download [http://prdownloads.sourceforge.net/gnuwin32/flex-2.5.4a-1.exe?download Flex 2.5.4a] and [http://downloads.sourceforge.net/gnuwin32/bison-2.4.1-setup.exe Bison 2.4.1] from gnuwin32.sf.net, and install them. Add the c:\Program Files (x86)\GnuWin32\bin location to your PATH.&lt;br /&gt;
* run scons from within your ASCEND working directory.&lt;br /&gt;
* the build process completes successfully&lt;br /&gt;
&lt;br /&gt;
To actually run the resulting binary, you need to also have PyGTK and GTK+ installed on your machine. The best way to do that is via the [http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.22/ new PyGTK All-in-One installer].&lt;br /&gt;
&lt;br /&gt;
The resulting binary can then be run from the MSYS prompt using the following, providing GTK is available in the PATH:&lt;br /&gt;
 cd ~/ascend&lt;br /&gt;
 pygtk/ascdev&lt;br /&gt;
&lt;br /&gt;
We have a mechanism for [[building a installer for ASCEND on Windows]] that makes use of NSIS. We are in the process of testing it on Windows 7.&lt;br /&gt;
&lt;br /&gt;
As an aside, the above highlights that it would be desirable to move from the use of libglade to GtkBuilder (as noted {{bug|493}}). We would then be able to use  standard PyGTK installers again, rather than needing the huge PyGTK-All-In-One with the optional libglade.dll that it includes.&lt;br /&gt;
&lt;br /&gt;
=== Windows XP with MinGW/MSYS ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;It is currently suggested that you attempt the same process as given above for Windows 7, instead of that given below.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The following instructions were tested on 32 bit Windows XP running on a DELL Precision (Core 2 Duo) machine in Nov 2009 and 32 bit Windows VISTA running on a ThinkPad X61 (Core 2 Duo) machine in March 2010.&lt;br /&gt;
&lt;br /&gt;
First install the MinGW/MSYS environment. Download MinGW-5.1.6.exe, and select the basic options plus &#039;g++&#039; (the C++ compiler). Then download and install MSYS-1.0.11.exe.&lt;br /&gt;
&lt;br /&gt;
Now install Python-2.6.4.msi.&lt;br /&gt;
&lt;br /&gt;
Install pywin32-214.win32-py2.6.exe.&lt;br /&gt;
&lt;br /&gt;
Next, download and install SCons, scons-1.2.0.win32.exe.&lt;br /&gt;
&lt;br /&gt;
Download swigwin-1.3.36 (&#039;&#039;later versions are OK&#039;&#039;) and unzip it in your root directory (it&#039;s just a folder with that name).&lt;br /&gt;
&lt;br /&gt;
Download and install Flex (2.5.4a-1) and Bison (2.4.1) from GnuWin32, installing in the default location.&lt;br /&gt;
&lt;br /&gt;
Download GFortran &#039;native installer&#039; for MinGW from [http://gcc.gnu.org/wiki/GFortranBinaries]. Our release was dated &#039;2009-04-21&#039;.&lt;br /&gt;
&lt;br /&gt;
With a right-click on the My Computer icon, then in the Advanced tab, add the following to your PATH environment variable (no quotes): &#039;;c:\Python26;c:\Python26\Scripts;c:\swigwin-1.3.36;c:\Program Files\GnuWin32\bin;C:\Program Files\gfortran\bin&#039;. For Windows VISTA system, right-click on the Computer icon, choose Properties. In Advance System Settings, you can configure PATH environment variable.&lt;br /&gt;
&lt;br /&gt;
Install NSIS 2.45.&lt;br /&gt;
&lt;br /&gt;
Download &#039;[[Media:Book.pdf|book.pdf]]&#039; and save it as &#039;book.pdf&#039; in ~/ascend/doc.&lt;br /&gt;
&lt;br /&gt;
In MSYS, run &amp;lt;tt&amp;gt;scons WITH_DOC_BUILD=0 installer&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The above will allow you to build ASCEND (and also to build the ASCEND installer using {{src|nsis/installer.nsi}}) but not to run it. For that, you additionally need to complete the following steps:&lt;br /&gt;
&lt;br /&gt;
* Download and install the GTK Glade3 windows installer [http://ftp.gnome.org/pub/GNOME/binaries/win32/glade3/3.6/glade3-3.6.7-with-GTK+.exe]&lt;br /&gt;
* Download and install PyGTK [http://ftp.gnome.org/pub/GNOME/binaries/win32/pygtk/2.12/pygtk-2.12.1-3.win32-py2.6.exe]&lt;br /&gt;
* Download and install PyCairo [http://ftp.gnome.org/pub/GNOME/binaries/win32/pycairo/1.4/pycairo-1.4.12-2.win32-py2.6.exe]&lt;br /&gt;
* Download and install PyGObject [http://ftp.gnome.org/pub/GNOME/binaries/win32/pygobject/2.14/pygobject-2.14.2-2.win32-py2.6.exe]&lt;br /&gt;
&lt;br /&gt;
The above Glade3 installer should have added &#039;c:\Program Files\Gtk+\bin&#039; to your PATH; you can check that if necessary.&lt;br /&gt;
&lt;br /&gt;
To test the installer, it is recommended you remove GTK Glade3, PyGTK, PyCairo, PyGObject, Tcl/Tk and Python. Then run the installer, and it should discover all those missing things and proceed to reinstall them for you.&lt;br /&gt;
&lt;br /&gt;
[[Image:mingw-1.png]]&lt;br /&gt;
[[Image:mingw-6.png]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SUNDIALS&#039;&#039;&#039;. If you want to use the [[IDA]] integrator (recommended) then you should download and install SUNDIALS. See [[building SUNDIALS on Windows]].&lt;br /&gt;
&lt;br /&gt;
Everything should build and you should end up with a file dist/ascend-{version}.exe which is your &#039;setup&#039; program. Run that then find ASCEND in your Start menu.&lt;br /&gt;
&lt;br /&gt;
=== MSVC ===&lt;br /&gt;
&lt;br /&gt;
We don&#039;t currently support the use of Microsoft compilers. They probably can be made to work, but we don&#039;t see any good reason to work on that.&lt;br /&gt;
&lt;br /&gt;
=== Windows / Borland C Builder ===&lt;br /&gt;
&lt;br /&gt;
Some very early efforts to support free Borland 5.5 were made; the core engine basically compiles but there is more work to be done.&lt;br /&gt;
&lt;br /&gt;
== Instructions for Mac ==&lt;br /&gt;
&lt;br /&gt;
=== Mac OS X 10.5 ===&lt;br /&gt;
&lt;br /&gt;
ASCEND runs fine on Mac OS X 10.5, and probably other versions. Currently we haven&#039;t completed the job of bundling ASCEND into a convenient distributable form, but the work is now well underway. See [[Porting to Mac]] for details.&lt;br /&gt;
&lt;br /&gt;
There has been no attempt to build or test the Tcl/Tk GUI on Mac at this stage.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Building a Debian package]]&lt;br /&gt;
* [[Building an RPM Package for ASCEND]]&lt;br /&gt;
* [[Windows Miscellany]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Dynamic_modelling&amp;diff=3318</id>
		<title>Dynamic modelling</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Dynamic_modelling&amp;diff=3318"/>
		<updated>2012-02-16T00:42:50Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: /* New syntax */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{solvers}}{{stub}}&lt;br /&gt;
Dynamic modelling in ASCEND is where you solve a system of [http://en.wikipedia.org/wiki/Ordinary_differential_equations ordinary differential equations (ODEs)] or [http://en.wikipedia.org/wiki/Differential_algebraic_equation differential/algebraic equations] for the time-varying values of variables in the model over a certain interval, given the initial conditions of the model. We also refer to this as &#039;&#039;integration&#039;&#039;. Dynamic modelling can be done within the ASCEND language providing the relationship between variables and their derivatives can be established.&lt;br /&gt;
&lt;br /&gt;
== About ODE/DAE solvers ==&lt;br /&gt;
&lt;br /&gt;
ODE solvers of the [[LSODE]] and Runge-Kutta class solve problems that can be written: &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\dot{\mathbf{y}} = \mathbf{F} \left(\mathbf{y},t \right)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
by projection schemes for &amp;lt;math&amp;gt;\mathbf{y}\left(t+dt\right)&amp;lt;/math&amp;gt; which require solving some set of equations based on Jacobian matrix of partial derivatives &amp;lt;math&amp;gt;\mathbf{J} = \partial \mathbf{F} / \partial \mathbf{y}&amp;lt;/math&amp;gt; (also referred to as &amp;lt;math&amp;gt;\partial \mathbf{\dot{y}}/\partial \mathbf{y}&amp;lt;/math&amp;gt;) being nonsingular. Variants of ODE solvers may allow convergence with limited singularity in &amp;lt;math&amp;gt;\mathbf{J}&amp;lt;/math&amp;gt; by using [[singular value decomposition]] (SVD) and assumptions about the properties of &amp;lt;math&amp;gt;\mathbf{F}&amp;lt;/math&amp;gt;, but this is not general or robust enough to be used in arbitrary models created with ASCEND.&lt;br /&gt;
&lt;br /&gt;
The ASCEND representation of differential equations allows the more general &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\mathbf{F}\left(\mathbf{y},\mathbf{\dot{y}},t,\mathbf{z}\right)=\mathbf{0}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;math&amp;gt;\mathbf{z}&amp;lt;/math&amp;gt; are apparently non-differential variables (variables that appear in the equations without a corresponding derivative). Considering all variables &amp;lt;math&amp;gt;\mathbf{y}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{\dot{y}}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{z}&amp;lt;/math&amp;gt; as algebraic, then the matrix &amp;lt;math&amp;gt;\mathbf{J}&amp;lt;/math&amp;gt; can be&lt;br /&gt;
calculated analytically (within some tolerance) if the following is true:&lt;br /&gt;
&lt;br /&gt;
:With y fixed, t fixed, and as many z fixed as necessary, a well posed (square, nonsingular) nonlinear problem is obtainable.&lt;br /&gt;
&lt;br /&gt;
This form is precisely the matrix needed at the initial condition, normally. So for each &amp;quot;function evaluation&amp;quot; of [[LSODE]], we solve the nonlinear problem &lt;br /&gt;
&lt;br /&gt;
:&amp;lt;math&amp;gt;\mathbf{F} \left( \mathbf{\dot{y}}, \mathbf{z}_\mathrm{free}\right)=\mathbf{0}&amp;lt;/math&amp;gt; such that st. &amp;lt;math&amp;gt;\mathbf{y}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;t&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{y}&amp;lt;/math&amp;gt;, &amp;lt;math&amp;gt;\mathbf{z}_\mathrm{fixed}&amp;lt;/math&amp;gt; are all fixed&lt;br /&gt;
&lt;br /&gt;
and for each &amp;lt;math&amp;gt;\mathbf{J}&amp;lt;/math&amp;gt; needed we take the Jacobian of &amp;lt;math&amp;gt;\mathbf{F}&amp;lt;/math&amp;gt; and solve to get a column of sensitivity data. (In&lt;br /&gt;
principle this can be accelerated by the method of Curtis, Powell, and Reid{{cite}}, but that so rarely applies we didn&#039;t bother).&lt;br /&gt;
&lt;br /&gt;
With the above technique, it may turn out that &amp;lt;math&amp;gt;\mathbf{J}&amp;lt;/math&amp;gt; is singular, even under [[SVD]]. This is the usual first indicator of a numerical index problem.&lt;br /&gt;
&lt;br /&gt;
It turns out that in many cases the index problem is even visible structurally in [[QRSlv]] -- meaning there is no feasible way to form &amp;lt;math&amp;gt;\mathbf{F}\left(\mathbf{\dot{y}}, \mathbf{z}_\mathrm{free}\right)&amp;lt;/math&amp;gt; by computing all the variables &amp;lt;math&amp;gt;\mathrm{\dot{y}}&amp;lt;/math&amp;gt; expected and fixing all the variables &amp;lt;math&amp;gt;\mathbf{y}&amp;lt;/math&amp;gt; expected. In this case either the problem is badly posed or a proper ODE problem can be recovered by moving some pair &amp;lt;math&amp;gt;\dot{y}_i, y_i&amp;lt;/math&amp;gt; into the set &amp;lt;math&amp;gt;\mathbf{z}&amp;lt;/math&amp;gt; and perhaps adding extra constraints obtainable by differentiation of a subset of &amp;lt;math&amp;gt;\mathbf{F}&amp;lt;/math&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
DASSL and IDA work around low index problems by solving all model and stepping simultaneously, but for problems typical in chemical engineering (setting pressure&lt;br /&gt;
specifications on multistage operations like distillation) DASSL&#039;s technique is not enough for reliable solution even if SVD is used under the covers.&lt;br /&gt;
&lt;br /&gt;
So basically, it&#039;s great to use DASSL for performance reasons over LSODE and the like. If the reason for using DASSL, IDA and the like is because LSODE &#039;&#039;&#039;fails&#039;&#039;&#039;,&lt;br /&gt;
then the modeling approach should be carefully reevaluated.&lt;br /&gt;
&lt;br /&gt;
If the reason for using DASSL/IDA is that they are better at finding initial conditions than LSODE (which has no such functionality), then again the main strength&lt;br /&gt;
of ASCEND&#039;s primary solvers (getting solutions to hard nonlinear problems) is being overlooked. Ben Allan has heard many times of people using dassl as simply a nonlinear solver and integrating nothing at all.&lt;br /&gt;
&lt;br /&gt;
Finally, now that memory is essentially free, boundary value problem (BVP) solution techniques should be of much greater interest than historically, and it just happens that ASCEND has a very nice BVP library: {{src|models/bvp.a4l}}&lt;br /&gt;
&lt;br /&gt;
== Syntax for dynamic modelling ==&lt;br /&gt;
&lt;br /&gt;
The current method for specifying derivatives is by including the &amp;lt;tt&amp;gt;ivpsystem.a4l&amp;lt;/tt&amp;gt; library. Full details are given in &#039;&#039;[http://ascend.cheme.cmu.edu/ftp/pdfPapersRptsSlides/AscendIVP.pdf Design and Use of Dynamic Modeling in ASCEND IV]&#039;&#039; (see our [[publications]] page).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;REQUIRE &amp;quot;ivpsystem.a4l&amp;quot;;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
at the start of your model, then creating a special method&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;METHOD ode_init;&lt;br /&gt;
    dx_dt.ode_id := 1;&lt;br /&gt;
    x.ode_id := 1; (* ie these variables are related with ID &#039;1&#039; *)&lt;br /&gt;
&lt;br /&gt;
    dx_dt.ode_type := 2; (* ie &#039;this is a derivative variable&#039; *)&lt;br /&gt;
    x.ode_type := 1; (* ie &#039;this is a differential variable *)&lt;br /&gt;
&lt;br /&gt;
    t.ode_type:= -1; (* &#039;tag&#039; the independent variable *)&lt;br /&gt;
END ode_init;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
which must be run before sending your model to either [[IDA]] or [[LSODE]] (or a future [[Solvers|solver]]...) for integration.&lt;br /&gt;
&lt;br /&gt;
== New syntax ==&lt;br /&gt;
&lt;br /&gt;
[[Dante Stroe]] recently added support for [[LINK semantics]] that allows this fairly painful syntax to be improved, however the new code is not yet incorporated into the ASCEND &#039;trunk&#039; (see [[VersionManagement|svn info]]). Based on the LINK structure the following syntax can now be used to define derivative chains, for example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;a4c&amp;quot;&amp;gt;INDEPENDENT t;&lt;br /&gt;
DER(dx_dt,x)&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This syntax can be used in either the declarative part of the model, either in the Methods section.&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;INDEPENDENT&#039;&#039;&#039; keyword adds an independent variable to the solver. While it is possible to store multiple independent variables in the solver data structures, the user is currently limited to only one independent variable, since there is no implementation of partial derivatives. (Implementation-wise, a LINK entry with the &#039;indepenendent&#039; key and the independent variable itself is created)&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;DER&#039;&#039;&#039; keyword is used to declare the derivative chains in terms of the declared independent variable. The parameters of DER  are the differential variables in decreasing order (ode_type in the previous syntax). The derivative chains declared in DER can be arbitrarily long, however the solver does not handle more than 2nd order derivatives. (Implementation-wise, a LINK entry with the &#039;ode&#039; key and the differential variable is created)&lt;br /&gt;
&lt;br /&gt;
The following models using the aforementioned syntax have been added:&lt;br /&gt;
&lt;br /&gt;
* {{srcbranch|dante|models/test/ida/singlederiv_wLINK.a4c}}&lt;br /&gt;
* {{srcbranch|dante|models/test/ida/twoderiv_wLINK.a4c}}&lt;br /&gt;
* {{srcbranch|dante|models/dyn_tank_wLINK.a4c}}&lt;br /&gt;
* {{srcbranch|dante|models/johnpye/pendulum_wLINK.a4c}}&lt;br /&gt;
* {{srcbranch|dante|models/test/dopri5/dopri5test_wLINK.a4c}}&lt;br /&gt;
&lt;br /&gt;
An inherent weakness of the syntax separating INDEPENDENT from der, as given above, is that in a hierarchically or peerwise composed model, multiple definitions of the same independent variable are possible and may conflict (or this may be by modeler choice, with multiple integrals within an overall model being computed by an IVP solver in different phases of the same simulation process). Several workarounds are possible. All rely on there being a community, or at least a library, standard way of doing things at the modeling level and an IVP solver understanding the convention.&lt;br /&gt;
* Syntactically: change the LINK-equivalent usage to be created from DER(dxdt,x,t) rather than DER(dxdt,x(*solver search for independent and insert here*)). Verbose but unambiguous. Solver pre-analysis still must verify that there is only one atom instance (t) that is the target of all DER definitions, even if that instance has multiple names and declarations that may have been merged. &lt;br /&gt;
* Typing an ATOM type to enforce that there exactly 1 independent: UNIVERSAL ATOM time_domain REFINES time; All instances of time_domain will automatically be the same. IVP Solvers can examine atom types and identify independent variables as those of type *_domain, eliminating the INDEPENDENT declaration. This solution actually allows multiple domains, and a parameter to an IVP analysis routines is &amp;quot;which domain type&amp;quot; is the independent variable. This would allow switching integrals over space(1-d) and integrals over time in the same model, an interesting capability in Low-Order PDEs. It might also allow interesting analyses in Fourier spaces.&lt;br /&gt;
&lt;br /&gt;
Current DER style doesn&#039;t scale to 2 simultaneous independent dimensions: INDEPENDENT x,y; DER(pdUxy,U). In a simultaneous 2-d world, the universal atom approach fails. One can (and probably JP has) argue that PDE models must explicitly represent the grid at the ascend language modeling level, as in the BVP library. We note, however, that NO current production PDE-oriented DSL actually works this way: they all make declarations based on sets and boundaries with arbitrary external definition whose consistency is checked by the solver.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See also&lt;br /&gt;
* [[External Integrators]] in the development section.&lt;br /&gt;
* [[Initial-value modelling]].&lt;br /&gt;
* [[Improved DAE syntax]]&lt;br /&gt;
* [[Integrator API]] (how ASCEND interfaces with solvers for dynamic modelling)&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Syntax]]&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Event_handling&amp;diff=3317</id>
		<title>Event handling</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Event_handling&amp;diff=3317"/>
		<updated>2012-02-15T23:08:43Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: /* Proposed solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{task}}&lt;br /&gt;
&#039;&#039;Please add discussion/feedback on the &#039;discussion&#039; page, restrict this page to description of the problem or a proposed solution/implementation.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To successfully implement [[integration of conditional models]] is quickly becomes apparent that simple [[boundary detection]] is only a small part of the whole problem. In general, we need to allow for &#039;events&#039; to occur when a boundary is encountered, for variables to be re-set using abitrary equations and/or expressions, and potentially for difficult &#039;&#039;initial condition problems&#039;&#039; to be solved before integration ([[DAE]]/[[ODE]]) simulation can proceed. &lt;br /&gt;
&lt;br /&gt;
== Use cases ==&lt;br /&gt;
&lt;br /&gt;
Some use cases that we would like to be able to support. These are all continuous-time simulations. We&#039;re not looking at adding pure discrete-event simulation at this stage.&lt;br /&gt;
&lt;br /&gt;
* a &#039;&#039;bouncing ball&#039;&#039; that *instantly* reverses its velocity (or v(+) = -v(-) * 0.9, perhaps) when hitting the ground. Note that Leon&#039;s approach uses a springy floor, instead of the instant velocity reversal approach. Sometimes we don&#039;t want to have to add this extra physics to our simulation.&lt;br /&gt;
* &#039;&#039;thermostat controller&#039;&#039;: a house has thermal losses, but a heat is attached. Heater turns on when temperature below 18 °C, and turns off when temperature rises above 20 °C. Plot the room temperature as a function of time.&lt;br /&gt;
* &#039;&#039;solar house&#039;&#039;: in extension to above, add solar energy gain to the thermostat model. on some days, less heating input will be required.&lt;br /&gt;
* a tank becoming full and starting to overflow&lt;br /&gt;
* a flow rate controller that increments flow in fixed steps when certain thresholds are passed.&lt;br /&gt;
* a vessel with an inlet in the side, and an outlet protruding into the pipe from above; if the level is above the outlet, liquid comes out; if the level is below, gas (or nothing) comes out. &#039;sliding mode&#039; is when a system like this gets stuck on the boundary or oscilates rapidly across it. how do we deal with that? [[User:Kannan]] is our expert on this kind of system. &lt;br /&gt;
* annual performance of a solar power plant, including rules like &amp;quot;wait half and hour after sunrise before starting the turbine&amp;quot; and &amp;quot;when storage is full, start dumping heat&amp;quot;, using external weather data and demand data to drive the control-system part of the simulation.&lt;br /&gt;
* reporting of model &#039;state&#039; (boolean variables) alongside real variable outputs.&lt;br /&gt;
&lt;br /&gt;
== Implementation issues ==&lt;br /&gt;
&lt;br /&gt;
ASCEND currently supports [[WHEN]] and [[CONDITIONAL]] statements, allowing for models with boundaries and boundary switching behaviour of a specific limited type. ASCEND lacks support for the following:&lt;br /&gt;
&lt;br /&gt;
* &#039;boundary equations&#039;, eg &amp;quot;when temperature = 20 °C, increase flowrate by 1 L/s&amp;quot;, or &amp;quot;Vdot(+) = Vdot(-) + 1 {L/s}&amp;quot;.&lt;br /&gt;
* &#039;events&#039;: things that are executed exactly once, when first arriving at or on a boundary.&lt;br /&gt;
* initial condition problems: there is no control over the equations used to reinitialise after a boundary. We just the the IDACalcIC built-in method.&lt;br /&gt;
* [[improved DAE syntax|convenient derivative syntax]], eg &amp;quot;der(x) = -x&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Instead, ASCEND allows only equations to be turned off and turned as the solver moves across the boundary. There is no way to trigger and special behaviour or action &#039;&#039;&#039;&#039;&#039;at&#039;&#039;&#039;&#039;&#039; the boundary. This means that currently, we can not implement a &#039;true&#039; bouncing ball model, nor a thermostat model.&lt;br /&gt;
&lt;br /&gt;
=== Modelica implementation ===&lt;br /&gt;
&lt;br /&gt;
The [http://www.modelica.org Modelica language] has some solutions in their syntax documentation&amp;lt;ref&amp;gt;Modelica 3.2 Language Specification, 2010, http://modelica.org/documents/ModelicaSpec32.pdf&amp;lt;/ref&amp;gt; to these problems that are worth consideration:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;when-equations&#039;&#039; are executed at a boundary&lt;br /&gt;
** when-equation are not free-form equations, they are only allowed to be &#039;&#039;x = expr&#039;&#039; assignment statements&lt;br /&gt;
** &amp;lt;tt&amp;gt;when..elsewhen&amp;lt;/tt&amp;gt; allows queuing/prioritisation of event handlers (queued cases are only allowed when the variables (x) being assigned match in all the nested when-equations&lt;br /&gt;
* &#039;&#039;initial equations&#039;&#039; are used to provide a initial condition problem to the solver (but we need to clarify if that only happens at the start of simulation, or at every boundary)&lt;br /&gt;
* &#039;&#039;pre(x)&#039;&#039; inside a when-clause returns the value of a simulation variable before the current boundary.&lt;br /&gt;
* &#039;&#039;reinit(x, expr)&#039;&#039; re-initialises a variable to a new value upon crossing a boundary&lt;br /&gt;
** using &#039;&#039;reinit&#039;&#039; forces Modelica to check that the variable &#039;x&#039; is a &#039;&#039;state variable&#039;&#039; in the DAE simulation. &lt;br /&gt;
** &#039;&#039;reinit&#039;&#039; has the effect of setting variable &#039;x&#039; to be unknown, and adding a new equation &#039;x = expr&#039;.&lt;br /&gt;
**  a standard &#039;&#039;when-equation&#039;&#039; has the effect of simply adding a new ewquation &#039;x = expr&#039;, but not setting &#039;x&#039; as unknown.&lt;br /&gt;
* various sub-expressions trigger boundaries to be &#039;emitted&#039; from a relation, and added the the solver&#039;s boundary list.&lt;br /&gt;
* &#039;&#039;noevent(...)&#039;&#039; allows suppression of triggered boundaries&lt;br /&gt;
* &#039;&#039;smooth(...)&#039;&#039; forces the solver to treat expressions as continuously differentiable. we assume this is related to boundary suppression.&lt;br /&gt;
&lt;br /&gt;
== gPROMS solution ==&lt;br /&gt;
&lt;br /&gt;
The thesis by Paul Barton&amp;lt;ref&amp;gt;P Barton, 1992. &#039;&#039;[http://yoric.mit.edu/sites/default/files/BartonThesis.pdf Modelling and simulation of combined discrete/continuous processes]&#039;&#039;, PhD thesis, MIT.&amp;lt;/ref&amp;gt; also has a solution for this problem.&lt;br /&gt;
&lt;br /&gt;
== Other implementations? ==&lt;br /&gt;
&lt;br /&gt;
Some other possible implementations/solutions worth researching:&lt;br /&gt;
&lt;br /&gt;
* MOSILAB webpage&amp;lt;ref&amp;gt;MOSILAB webpage, http://mosim.swt.tu-berlin.de/wiki/doku.php?id=projects:mosilab:home&amp;lt;/ref&amp;gt; and paper&amp;lt;ref&amp;gt;J Bastian, C Clauß, O Enge-Rosenblatt and P Schneider, 2010. [http://publica.fraunhofer.de/eprints/urn:nbn:de:0011-n-1355711.pdf MOSILAB - a Modelica solver for multiphysics problems with structural variability], Proceedings of 1st Conference on Multiphysics Simulation - Advanced Methods for Industrial Engineering 2010.&amp;lt;/ref&amp;gt;.&lt;br /&gt;
* A [http://en.wikipedia.org/wiki/List_of_discrete_event_simulation_software#Open_Source list of discrete event simulation software]&lt;br /&gt;
&lt;br /&gt;
== Proposed solution ==&lt;br /&gt;
&lt;br /&gt;
We don&#039;t know how we&#039;ll do it. Please give your thoughts on the &#039;&#039;&#039;discussion&#039;&#039;&#039; page.&lt;br /&gt;
&lt;br /&gt;
A decent explanation of the full design space is in Fishwick&amp;lt;ref&amp;gt;http://www.cee.mtu.edu/~amlan/ce5710/Readings/tax_sim.pdf&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are further references in [[integration of conditional models]]&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Talk:Event_handling&amp;diff=3308</id>
		<title>Talk:Event handling</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Talk:Event_handling&amp;diff=3308"/>
		<updated>2012-02-15T20:07:38Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: /* Initial condition problems */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;Please add new comments below with a &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;==heading==&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; and signed beneath using &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;~~~~&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. If responding to an earlier comment, prefix your comments with &amp;quot;:&amp;quot; so that they are indented, and sign as before.&lt;br /&gt;
&lt;br /&gt;
== REINIT and PRE ==&lt;br /&gt;
&lt;br /&gt;
One basic implementation of boundary events would be to allow a REINIT statement in addition to the USE statement to exist inside [[WHEN]]..CASE. REINIT statements would be associated with a particular CASE, and whenever a CASE change occurred, it would trigger an ICP to be created and solved.&lt;br /&gt;
&lt;br /&gt;
PRE could then be added to the language. PRE inside a &#039;normal&#039; relation would trigger an error. PRE inside a REINIT statement would result in a callback to the solver, which would have to keep a copy of variable values before the current boundary.&lt;br /&gt;
&lt;br /&gt;
 REINIT x TO -0.9*pre(x);&lt;br /&gt;
&lt;br /&gt;
This statement would set the new value of &#039;x&#039; and perhaps remove &#039;x&#039; from the initial value problem. The derivative of x would still need to be solved for, using the dynamic equations in the problem.&lt;br /&gt;
&lt;br /&gt;
[[User:Jpye|Jpye]] 10:55, 11 February 2012 (EST)&lt;br /&gt;
&lt;br /&gt;
== Initial condition problems ==&lt;br /&gt;
&lt;br /&gt;
The major issues we have with event handling currently are&lt;br /&gt;
# defining &#039;edge&#039; events as opposed to &#039;region conditions&#039;&lt;br /&gt;
# flexibly declaring initial condition problems (ICPs)&lt;br /&gt;
&lt;br /&gt;
Our current WHEN syntax defines region conditions pretty well. This means that a boundary is defined, and if the solver crosses that boundary, we have to change our equations, reinitialise the DAE system and then continue.&lt;br /&gt;
&lt;br /&gt;
For &#039;edge&#039; events, we don&#039;t necessarily want to change the equations in our system, we just want to be able to be able to reassign values to certain variables, such that instead of the default state-variable continuity being applied, we can create step changes and other effects.&lt;br /&gt;
&lt;br /&gt;
We are currently missing in ASCEND the idea of ICPs in general, which is a precursor to the above. In DAEs, we have &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; state variables (variables plus derivatives) plus &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; algebraic equations. Normal integration time-stepping requires &amp;lt;math&amp;lt;n+m&amp;lt;/math&amp;gt; equations. ICP solution requires &amp;lt;math&amp;gt;2n+m&amp;lt;/math&amp;gt; equations, because we need to solve the initial derivatives as well as the state variables, plus all the algebraics.&lt;br /&gt;
&lt;br /&gt;
In IDA, the ICP is currently solved by assuming the state variables are fixed, and using the DAE equations to solve the derivatives plus the algebraic variables.&lt;br /&gt;
&lt;br /&gt;
More generally, we should be able to set ICPs both for the truly initial conditions, as well as for each time boundaries are crossed. We could use a [[SWITCH]] statement inside a [[METHOD]] to turn on and off equations in this cases as a first hack. This would require lots of inactive equations to be declared in the model, and in a method &amp;lt;tt&amp;gt;initcond&amp;lt;/tt&amp;gt; we could prepare the initial condition problem, and in a method &amp;lt;tt&amp;gt;continue&amp;lt;/tt&amp;gt; we could restore the DAE problem. Somewhere inside IDA, then, we would detect a boundary and [[RUN]] &amp;lt;tt&amp;gt;initcond&amp;lt;/tt&amp;gt;, then run [[QRSlv]], then run &amp;lt;tt&amp;gt;continue&amp;lt;/tt&amp;gt;, the proceed with the integration.&lt;br /&gt;
&lt;br /&gt;
The better solution would allow sometime like the [[CONDITIONAL]] statement, as a way to declare ICP equations. That section would in general need to allow conditional syntax such as supported by [[CMSlv]].&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Syntactic/semantic background to inform our design process:&lt;br /&gt;
&lt;br /&gt;
An underused feature in ascend is that equations, boundaries, and I think even whens &lt;br /&gt;
all have *names* and *subatomic children(flags)*, which can be used.&lt;br /&gt;
&lt;br /&gt;
The current declarative language is focused entirely on declaring an algebraic mathematical description with no time or space dependence. All handling of these variations requires discretization over the *domain* of the independent variable by either the model statement itself (a boundary value formulation) or by the solver (initial value formulation). &lt;br /&gt;
&lt;br /&gt;
The ascend language cannot even *name* the state of all the variables in the model at a given value of the independent variable. I&#039;m not particularly aware of *any* small modeling language which allows you to name the solution of the model at arbitrary times. Several quick-hack languages like gproms/modelica allow you to handle implicitly defined values near &#039;events&#039;. A more general solution is highly desirable and with the cost of computer memory being essentially zero at this point, there is no reason (any longer) to exclude naming states in the modeling language.&lt;br /&gt;
&lt;br /&gt;
Ben&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Proposal 1: a quick hack ==&lt;br /&gt;
&lt;br /&gt;
1. Modify the [[WHEN]] statement so that a single [[RUN]] statement is allow in each CASE:&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
WHEN var&lt;br /&gt;
  CASE TRUE:&lt;br /&gt;
    RUN mymethod1;&lt;br /&gt;
    USE eq1;&lt;br /&gt;
  CASE FALSE:&lt;br /&gt;
    RUN mymethod2;&lt;br /&gt;
    USE eq2;&lt;br /&gt;
END WHEN;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Modify [[IDA]] such that, after running methods named as above, run a general &amp;lt;tt&amp;gt;initcond&amp;lt;/tt&amp;gt; method that would prepare the model for solving the initial condition problem (ICP). &lt;br /&gt;
&lt;br /&gt;
3. Solve the initial problem using [[QRSlv]] or [[CMSlv]] (switchable as an IDA option).&lt;br /&gt;
&lt;br /&gt;
4. Run a general &amp;lt;tt&amp;gt;continue&amp;lt;/tt&amp;gt; method to restore the DAE problem, the proceed with IDA integration until the next boundary.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This approach is flawed because regions are really not the same as events; we should put the &#039;RUN&#039; statement in the above inside some other kind of statement -- Proposal 4 below.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Proposal 2: a better approach ==&lt;br /&gt;
&lt;br /&gt;
1. Modify the declarative syntax to support an INITIAL statement within the declarative section:&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
INITIAL&lt;br /&gt;
  (* here the missing &#039;n&#039; equations can be added. if omitted, fall back to default IDA behaviour *)&lt;br /&gt;
  der(x) = 0;&lt;br /&gt;
  y = 5;&lt;br /&gt;
  (* also allow SWITCH statements here and maybe even WHEN and CONDITIONAL *)&lt;br /&gt;
END INITIAL;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Add an ICP API to the the existing integrator API.&lt;br /&gt;
&lt;br /&gt;
3. Modify the WHEN statement to support &#039;event&#039; actions as well as &#039;region&#039; behaviour. We would need to work out if the current WHEN statement is overly flexible; perhaps we need to split it somehow, c.f. Modelica &#039;if...then&#039; as well as &#039;when&#039; behaviour. Also note Modelica &#039;when...elsewhen&#039; prioritisation.&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
WHEN y_is_zero&lt;br /&gt;
  CASE TRUE:&lt;br /&gt;
    (*...*)&lt;br /&gt;
END WHEN;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Modify WHEN statement to support reinitialisation of state variables before the ICP is solved. The problem here is in making sure we can generate consistent ICPs. Do these reinitialisations replace INITIAL equations, or simple reassign values, independently of the ICP solution?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
WHEN y_is_zero&lt;br /&gt;
  CASE TRUE:&lt;br /&gt;
    REINIT vel :== -pre(vel);&lt;br /&gt;
END WHEN;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Need to understand whether we need equivalents of Modelica&#039;s &#039;when-equation&#039; as well as this &#039;reinit&#039; thing.&lt;br /&gt;
&lt;br /&gt;
4. Add the &#039;pre&#039; so that REINIT statemnts can access previous values of other variables. This would be some kind of callback to the Integrator.&lt;br /&gt;
&lt;br /&gt;
== Proposal 3: EVENT statement ==&lt;br /&gt;
&lt;br /&gt;
We need to put the event handling separate to the WHEN statements. So for a bouncing ball model,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
EVENT x == 0&lt;br /&gt;
  REINIT xvel :== -pre(xvel);&lt;br /&gt;
END EVENT;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;EVENT&#039; statement needs to fire any time that the boolean expression &#039;&#039;was&#039;&#039; previously false, and &#039;&#039;now becomes&#039;&#039; true, i.e. a rising edge. So, what is the difference between the above and the following?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
EVENT x &amp;gt;= 0&lt;br /&gt;
  REINIT xvel :== -pre(xvel);&lt;br /&gt;
END EVENT;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not sure if there is a difference? Need to clarify.&lt;br /&gt;
&lt;br /&gt;
== Proposal 4: EVENT statement with RUN ==&lt;br /&gt;
&lt;br /&gt;
This is a modification of Proposal 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
EVENT x == 0&lt;br /&gt;
  RUN mybouncemethod;&lt;br /&gt;
END EVENT;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We could implement this without having to first add support for definition of ICPs, which Proposal 3 definitely requires. Hence this is a quick hack that would let us keep working on the solver algorithms, and let the language features catch up afterwards.&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Talk:Event_handling&amp;diff=3307</id>
		<title>Talk:Event handling</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Talk:Event_handling&amp;diff=3307"/>
		<updated>2012-02-15T20:04:36Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: /* Initial condition problems */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;Please add new comments below with a &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;==heading==&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; and signed beneath using &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;~~~~&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. If responding to an earlier comment, prefix your comments with &amp;quot;:&amp;quot; so that they are indented, and sign as before.&lt;br /&gt;
&lt;br /&gt;
== REINIT and PRE ==&lt;br /&gt;
&lt;br /&gt;
One basic implementation of boundary events would be to allow a REINIT statement in addition to the USE statement to exist inside [[WHEN]]..CASE. REINIT statements would be associated with a particular CASE, and whenever a CASE change occurred, it would trigger an ICP to be created and solved.&lt;br /&gt;
&lt;br /&gt;
PRE could then be added to the language. PRE inside a &#039;normal&#039; relation would trigger an error. PRE inside a REINIT statement would result in a callback to the solver, which would have to keep a copy of variable values before the current boundary.&lt;br /&gt;
&lt;br /&gt;
 REINIT x TO -0.9*pre(x);&lt;br /&gt;
&lt;br /&gt;
This statement would set the new value of &#039;x&#039; and perhaps remove &#039;x&#039; from the initial value problem. The derivative of x would still need to be solved for, using the dynamic equations in the problem.&lt;br /&gt;
&lt;br /&gt;
[[User:Jpye|Jpye]] 10:55, 11 February 2012 (EST)&lt;br /&gt;
&lt;br /&gt;
== Initial condition problems ==&lt;br /&gt;
&lt;br /&gt;
The major issues we have with event handling currently are&lt;br /&gt;
# defining &#039;edge&#039; events as opposed to &#039;region conditions&#039;&lt;br /&gt;
# flexibly declaring initial condition problems (ICPs)&lt;br /&gt;
&lt;br /&gt;
Our current WHEN syntax defines region conditions pretty well. This means that a boundary is defined, and if the solver crosses that boundary, we have to change our equations, reinitialise the DAE system and then continue.&lt;br /&gt;
&lt;br /&gt;
For &#039;edge&#039; events, we don&#039;t necessarily want to change the equations in our system, we just want to be able to be able to reassign values to certain variables, such that instead of the default state-variable continuity being applied, we can create step changes and other effects.&lt;br /&gt;
&lt;br /&gt;
We are currently missing in ASCEND the idea of ICPs in general, which is a precursor to the above. In DAEs, we have &amp;lt;math&amp;gt;n&amp;lt;/math&amp;gt; state variables (variables plus derivatives) plus &amp;lt;math&amp;gt;m&amp;lt;/math&amp;gt; algebraic equations. Normal integration time-stepping requires &amp;lt;math&amp;lt;n+m&amp;lt;/math&amp;gt; equations. ICP solution requires &amp;lt;math&amp;gt;2n+m&amp;lt;/math&amp;gt; equations, because we need to solve the initial derivatives as well as the state variables, plus all the algebraics.&lt;br /&gt;
&lt;br /&gt;
In IDA, the ICP is currently solved by assuming the state variables are fixed, and using the DAE equations to solve the derivatives plus the algebraic variables.&lt;br /&gt;
&lt;br /&gt;
More generally, we should be able to set ICPs both for the truly initial conditions, as well as for each time boundaries are crossed. We could use a [[SWITCH]] statement inside a [[METHOD]] to turn on and off equations in this cases as a first hack. This would require lots of inactive equations to be declared in the model, and in a method &amp;lt;tt&amp;gt;initcond&amp;lt;/tt&amp;gt; we could prepare the initial condition problem, and in a method &amp;lt;tt&amp;gt;continue&amp;lt;/tt&amp;gt; we could restore the DAE problem. Somewhere inside IDA, then, we would detect a boundary and [[RUN]] &amp;lt;tt&amp;gt;initcond&amp;lt;/tt&amp;gt;, then run [[QRSlv]], then run &amp;lt;tt&amp;gt;continue&amp;lt;/tt&amp;gt;, the proceed with the integration.&lt;br /&gt;
&lt;br /&gt;
The better solution would allow sometime like the [[CONDITIONAL]] statement, as a way to declare ICP equations. That section would in general need to allow conditional syntax such as supported by [[CMSlv]].&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
Syntactic/semantic background to inform our design process:&lt;br /&gt;
&lt;br /&gt;
An underused feature in ascend is that equations, boundaries, and I think even whens &lt;br /&gt;
all have *names* and *subatomic children(flags)*, which can be used.&lt;br /&gt;
&lt;br /&gt;
The current declarative language is focused entirely on declaring an algebraic mathematical description with no time or space dependence. All handling of these variations requires discretization over the *domain* of the independent variable by either the model statement itself (a boundary value formulation) or by the solver (initial value formulation). &lt;br /&gt;
&lt;br /&gt;
The ascend language cannot even *name* the state of all the variables in the model at a given value of the independent variable. I&#039;m not particularly aware of *any* small modeling language which allows you to name the solution of the model at arbitrary times. Several quick-hack languages like gproms/modelica allow you to handle implicitly defined values near &#039;events&#039;. A more general solution is highly desirable and with the cost of computer memory being essentially zero at this point, there is no reason (any longer) to exclude naming states in the modeling language.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
== Proposal 1: a quick hack ==&lt;br /&gt;
&lt;br /&gt;
1. Modify the [[WHEN]] statement so that a single [[RUN]] statement is allow in each CASE:&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
WHEN var&lt;br /&gt;
  CASE TRUE:&lt;br /&gt;
    RUN mymethod1;&lt;br /&gt;
    USE eq1;&lt;br /&gt;
  CASE FALSE:&lt;br /&gt;
    RUN mymethod2;&lt;br /&gt;
    USE eq2;&lt;br /&gt;
END WHEN;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Modify [[IDA]] such that, after running methods named as above, run a general &amp;lt;tt&amp;gt;initcond&amp;lt;/tt&amp;gt; method that would prepare the model for solving the initial condition problem (ICP). &lt;br /&gt;
&lt;br /&gt;
3. Solve the initial problem using [[QRSlv]] or [[CMSlv]] (switchable as an IDA option).&lt;br /&gt;
&lt;br /&gt;
4. Run a general &amp;lt;tt&amp;gt;continue&amp;lt;/tt&amp;gt; method to restore the DAE problem, the proceed with IDA integration until the next boundary.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This approach is flawed because regions are really not the same as events; we should put the &#039;RUN&#039; statement in the above inside some other kind of statement -- Proposal 4 below.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Proposal 2: a better approach ==&lt;br /&gt;
&lt;br /&gt;
1. Modify the declarative syntax to support an INITIAL statement within the declarative section:&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
INITIAL&lt;br /&gt;
  (* here the missing &#039;n&#039; equations can be added. if omitted, fall back to default IDA behaviour *)&lt;br /&gt;
  der(x) = 0;&lt;br /&gt;
  y = 5;&lt;br /&gt;
  (* also allow SWITCH statements here and maybe even WHEN and CONDITIONAL *)&lt;br /&gt;
END INITIAL;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
2. Add an ICP API to the the existing integrator API.&lt;br /&gt;
&lt;br /&gt;
3. Modify the WHEN statement to support &#039;event&#039; actions as well as &#039;region&#039; behaviour. We would need to work out if the current WHEN statement is overly flexible; perhaps we need to split it somehow, c.f. Modelica &#039;if...then&#039; as well as &#039;when&#039; behaviour. Also note Modelica &#039;when...elsewhen&#039; prioritisation.&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
WHEN y_is_zero&lt;br /&gt;
  CASE TRUE:&lt;br /&gt;
    (*...*)&lt;br /&gt;
END WHEN;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
3. Modify WHEN statement to support reinitialisation of state variables before the ICP is solved. The problem here is in making sure we can generate consistent ICPs. Do these reinitialisations replace INITIAL equations, or simple reassign values, independently of the ICP solution?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
WHEN y_is_zero&lt;br /&gt;
  CASE TRUE:&lt;br /&gt;
    REINIT vel :== -pre(vel);&lt;br /&gt;
END WHEN;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Need to understand whether we need equivalents of Modelica&#039;s &#039;when-equation&#039; as well as this &#039;reinit&#039; thing.&lt;br /&gt;
&lt;br /&gt;
4. Add the &#039;pre&#039; so that REINIT statemnts can access previous values of other variables. This would be some kind of callback to the Integrator.&lt;br /&gt;
&lt;br /&gt;
== Proposal 3: EVENT statement ==&lt;br /&gt;
&lt;br /&gt;
We need to put the event handling separate to the WHEN statements. So for a bouncing ball model,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
EVENT x == 0&lt;br /&gt;
  REINIT xvel :== -pre(xvel);&lt;br /&gt;
END EVENT;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &#039;EVENT&#039; statement needs to fire any time that the boolean expression &#039;&#039;was&#039;&#039; previously false, and &#039;&#039;now becomes&#039;&#039; true, i.e. a rising edge. So, what is the difference between the above and the following?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
EVENT x &amp;gt;= 0&lt;br /&gt;
  REINIT xvel :== -pre(xvel);&lt;br /&gt;
END EVENT;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Not sure if there is a difference? Need to clarify.&lt;br /&gt;
&lt;br /&gt;
== Proposal 4: EVENT statement with RUN ==&lt;br /&gt;
&lt;br /&gt;
This is a modification of Proposal 1.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=a4c&amp;gt;&lt;br /&gt;
EVENT x == 0&lt;br /&gt;
  RUN mybouncemethod;&lt;br /&gt;
END EVENT;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We could implement this without having to first add support for definition of ICPs, which Proposal 3 definitely requires. Hence this is a quick hack that would let us keep working on the solver algorithms, and let the language features catch up afterwards.&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Event_handling&amp;diff=3306</id>
		<title>Event handling</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Event_handling&amp;diff=3306"/>
		<updated>2012-02-15T19:49:18Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: /* Proposed solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{task}}&lt;br /&gt;
&#039;&#039;Please add discussion/feedback on the &#039;discussion&#039; page, restrict this page to description of the problem or a proposed solution/implementation.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
To successfully implement [[integration of conditional models]] is quickly becomes apparent that simple [[boundary detection]] is only a small part of the whole problem. In general, we need to allow for &#039;events&#039; to occur when a boundary is encountered, for variables to be re-set using abitrary equations and/or expressions, and potentially for difficult &#039;&#039;initial condition problems&#039;&#039; to be solved before integration ([[DAE]]/[[ODE]]) simulation can proceed. &lt;br /&gt;
&lt;br /&gt;
== Use cases ==&lt;br /&gt;
&lt;br /&gt;
Some use cases that we would like to be able to support. These are all continuous-time simulations. We&#039;re not looking at adding pure discrete-event simulation at this stage.&lt;br /&gt;
&lt;br /&gt;
* a &#039;&#039;bouncing ball&#039;&#039; that *instantly* reverses its velocity (or v(+) = -v(-) * 0.9, perhaps) when hitting the ground. Note that Leon&#039;s approach uses a springy floor, instead of the instant velocity reversal approach. Sometimes we don&#039;t want to have to add this extra physics to our simulation.&lt;br /&gt;
* &#039;&#039;thermostat controller&#039;&#039;: a house has thermal losses, but a heat is attached. Heater turns on when temperature below 18 °C, and turns off when temperature rises above 20 °C. Plot the room temperature as a function of time.&lt;br /&gt;
* &#039;&#039;solar house&#039;&#039;: in extension to above, add solar energy gain to the thermostat model. on some days, less heating input will be required.&lt;br /&gt;
* a tank becoming full and starting to overflow&lt;br /&gt;
* a flow rate controller that increments flow in fixed steps when certain thresholds are passed.&lt;br /&gt;
* a vessel with an inlet in the side, and an outlet protruding into the pipe from above; if the level is above the outlet, liquid comes out; if the level is below, gas (or nothing) comes out. &#039;sliding mode&#039; is when a system like this gets stuck on the boundary or oscilates rapidly across it. how do we deal with that? [[User:Kannan]] is our expert on this kind of system. &lt;br /&gt;
* annual performance of a solar power plant, including rules like &amp;quot;wait half and hour after sunrise before starting the turbine&amp;quot; and &amp;quot;when storage is full, start dumping heat&amp;quot;, using external weather data and demand data to drive the control-system part of the simulation.&lt;br /&gt;
* reporting of model &#039;state&#039; (boolean variables) alongside real variable outputs.&lt;br /&gt;
&lt;br /&gt;
== Implementation issues ==&lt;br /&gt;
&lt;br /&gt;
ASCEND currently supports [[WHEN]] and [[CONDITIONAL]] statements, allowing for models with boundaries and boundary switching behaviour of a specific limited type. ASCEND lacks support for the following:&lt;br /&gt;
&lt;br /&gt;
* &#039;boundary equations&#039;, eg &amp;quot;when temperature = 20 °C, increase flowrate by 1 L/s&amp;quot;, or &amp;quot;Vdot(+) = Vdot(-) + 1 {L/s}&amp;quot;.&lt;br /&gt;
* &#039;events&#039;: things that are executed exactly once, when first arriving at or on a boundary.&lt;br /&gt;
* initial condition problems: there is no control over the equations used to reinitialise after a boundary. We just the the IDACalcIC built-in method.&lt;br /&gt;
* [[improved DAE syntax|convenient derivative syntax]], eg &amp;quot;der(x) = -x&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Instead, ASCEND allows only equations to be turned off and turned as the solver moves across the boundary. There is no way to trigger and special behaviour or action &#039;&#039;&#039;&#039;&#039;at&#039;&#039;&#039;&#039;&#039; the boundary. This means that currently, we can not implement a &#039;true&#039; bouncing ball model, nor a thermostat model.&lt;br /&gt;
&lt;br /&gt;
=== Modelica implementation ===&lt;br /&gt;
&lt;br /&gt;
The [http://www.modelica.org Modelica language] has some solutions to these problems that are worth consideration:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;when-equations&#039;&#039; are executed at a boundary&lt;br /&gt;
** when-equation are not free-form equations, they are only allowed to be &#039;&#039;x = expr&#039;&#039; assignment statements&lt;br /&gt;
** &amp;lt;tt&amp;gt;when..elsewhen&amp;lt;/tt&amp;gt; allows queuing/prioritisation of event handlers (queued cases are only allowed when the variables (x) being assigned match in all the nested when-equations&lt;br /&gt;
* &#039;&#039;initial equations&#039;&#039; are used to provide a initial condition problem to the solver (but we need to clarify if that only happens at the start of simulation, or at every boundary)&lt;br /&gt;
* &#039;&#039;pre(x)&#039;&#039; inside a when-clause returns the value of a simulation variable before the current boundary.&lt;br /&gt;
* &#039;&#039;reinit(x, expr)&#039;&#039; re-initialises a variable to a new value upon crossing a boundary&lt;br /&gt;
** using &#039;&#039;reinit&#039;&#039; forces Modelica to check that the variable &#039;x&#039; is a &#039;&#039;state variable&#039;&#039; in the DAE simulation. &lt;br /&gt;
** &#039;&#039;reinit&#039;&#039; has the effect of setting variable &#039;x&#039; to be unknown, and adding a new equation &#039;x = expr&#039;.&lt;br /&gt;
**  a standard &#039;&#039;when-equation&#039;&#039; has the effect of simply adding a new ewquation &#039;x = expr&#039;, but not setting &#039;x&#039; as unknown.&lt;br /&gt;
* various sub-expressions trigger boundaries to be &#039;emitted&#039; from a relation, and added the the solver&#039;s boundary list.&lt;br /&gt;
* &#039;&#039;noevent(...)&#039;&#039; allows suppression of triggered boundaries&lt;br /&gt;
* &#039;&#039;smooth(...)&#039;&#039; forces the solver to treat expressions as continuously differentiable. we assume this is related to boundary suppression.&lt;br /&gt;
&lt;br /&gt;
== Proposed solution ==&lt;br /&gt;
&lt;br /&gt;
We don&#039;t know how we&#039;ll do it. Please give your thoughts on the &#039;&#039;&#039;discussion&#039;&#039;&#039; page.&lt;br /&gt;
We need some external references here &lt;br /&gt;
&lt;br /&gt;
(link to modelica standard)&lt;br /&gt;
&lt;br /&gt;
(link to Barton thesis (gproms) which had event syntax)&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Building_ASCEND_for_64-bit_Windows&amp;diff=3264</id>
		<title>Building ASCEND for 64-bit Windows</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Building_ASCEND_for_64-bit_Windows&amp;diff=3264"/>
		<updated>2012-02-09T22:55:36Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are a number of barriers to building ASCEND on 64-bit Windows:&lt;br /&gt;
&lt;br /&gt;
* &#039;Standard&#039; MinGW does not build 64-bit executables, so we need to use the MinGW-w64 compiler, which is a bit new.&lt;br /&gt;
* We need to switch to a true 64-bit Python in order to run 64-bit ASCEND.&lt;br /&gt;
* PyGTK for 64-bit may have some bugs (http://www.daa.com.au/pipermail/pygtk/2009-July/017278.html)&lt;br /&gt;
* Windows 64 uses 8-byte pointers (long long) which our code hasn&#039;t had to deal with up to now. {not true: we did it routinely in the 1990s-- but there were no WIN 64 bit ports in the 90s. The DEC machines actually supported both 4 and 8 byte pointers and we built both ways (appropriately autoconf&#039;d) without issues. Ben&#039;s default Linux is always 64 bit; he really should set up a buildbot for it.}&lt;br /&gt;
&lt;br /&gt;
This page records our progress on getting up and running.&lt;br /&gt;
&lt;br /&gt;
== Steps to date ==&lt;br /&gt;
&lt;br /&gt;
* install MSYS bundle to c:\msys as instructed [http://sourceforge.net/apps/trac/mingw-w64/wiki/MSYS here] (I chose &#039;MSYS-20111123.zip&#039;)&lt;br /&gt;
* install MinGW-64 bundle to c:\mingw64 as instructed (we used [http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Automated%20Builds/mingw-w64-bin_i686-mingw_20111220.zip/download mingw-w64-bin_i686-mingw_20111220.zip]&lt;br /&gt;
* From the MSYS prompt, edit /etc/fstab so that &#039;c:/MinGW64&#039; is mapped to &#039;/mingw&#039;&lt;br /&gt;
* install 64-bit Python 2.7.2&lt;br /&gt;
* download and install the [http://www.sliksvn.com/en/download SlikSvn 64-bit client].&lt;br /&gt;
* append /c/Python27 and /c/Python27/Scripts and SlikSvn to the PATH in MSYS. Also, set an environment variable HOST_PREFIX for the MinGW-w64 compiler (to be used by our SCons script). A good way is by creating the file &amp;lt;tt&amp;gt;~/.profile&amp;lt;/tt&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;export PATH=&amp;quot;$PATH:/c/Python27:/c/Python27/Scripts:/c/Program Files/SlikSvn/bin&amp;quot;&lt;br /&gt;
export HOST_PREFIX=x86_64-w64-mingw32&amp;lt;/pre&amp;gt;&lt;br /&gt;
* download and extract source tarball for SCons 2.1.0. Build via &amp;lt;tt&amp;gt;python setup.py bdist_wininst&amp;lt;/tt&amp;gt; then install resulting .exe in dist subfolder.&lt;br /&gt;
* install &#039;findutils&#039; by unpacking [http://sourceforge.net/projects/mingw/files/MSYS/Base/findutils/findutils-4.4.2-2/findutils-4.4.2-2-msys-1.0.13-bin.tar.lzma/download findutils-4.4.2-2-msys-1.0.13-bin.tar.lzma] and unpacking into c:\msys&lt;br /&gt;
&lt;br /&gt;
Things we need to work on:&lt;br /&gt;
&lt;br /&gt;
* can we set up a MinGW/MinGW-w64 combined build environment and build both 32- and 64-bit versions on that same machine? Can Python 32-bit and 64-bit coexist? Can we install 32- and 64-bit versions of all the Python modules, and GTK as well?&lt;br /&gt;
* rather than using the big bundle MSYS that is provided by the MinGW-w64 project, we should try to use &#039;standard&#039; MinGW-get-inst for the MSYS portion, and load MinGW-w64 on top of that. Makes obtaining minor utilities like &#039;find&#039; and &#039;autoconf&#039; much easier.&lt;br /&gt;
* our build tools can be 32-bit, even if the build target is 64-bit.&lt;br /&gt;
&lt;br /&gt;
== Test suite ==&lt;br /&gt;
&lt;br /&gt;
* The CUnit test suites seem to be basically working. We have made changes to CUnit and currently require that you access the svn trunk version of CUnit for ASCEND testing. A new CUnit release is planned.&lt;br /&gt;
* Failing test cases:&lt;br /&gt;
** compiler_autodiff (issue with a non-null pointer in line 198)&lt;br /&gt;
** compiler_bintok (program hangs! possibly just a configuration issue? looks like the parser is waiting for input from stdin)&lt;br /&gt;
** compiler_blackbox (lacking error code in return from parse. not Win64 specific)&lt;br /&gt;
&lt;br /&gt;
Check the current build status on our [[buildbot]].&lt;br /&gt;
&lt;br /&gt;
== Python bindings ==&lt;br /&gt;
&lt;br /&gt;
Before MinGW-w64 can link to Python27.dll, you need to download, build, and install a utility called &#039;gendef&#039; which builds library *.def files that MinGW-w64 can use. The python27.lib file distributed with Python doesn&#039;t work with MinGW-w64 (or maybe even for MinGW32?). To build gendef, we used revision r4724 from [http://mingw-w64.svn.sourceforge.net/viewvc/mingw-w64/trunk/mingw-w64-tools/gendef/ here] (click &#039;download GNU tarball&#039;).&lt;br /&gt;
&lt;br /&gt;
* ./configure --host=x86_64-w64-mingw32 --prefix=/mingw&lt;br /&gt;
* make -j4&lt;br /&gt;
* make install&lt;br /&gt;
&lt;br /&gt;
Next, run gendef as follows. Using Windows Explorer, copy the file c:\Windows\System32\Python27.dll into c:\Python27\Libs. Then, in MSYS,&lt;br /&gt;
&lt;br /&gt;
* cd /c/Python27/Libs&lt;br /&gt;
* gendef Python27.dll&lt;br /&gt;
* mv Python27.lib OLD-Python27.lib &#039;&#039;(just in case?)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Firstly, as per [http://bugs.python.org/issue4709 python bug 4709], in &amp;lt;tt&amp;gt;c:\Python26\include\pyconfig.h&amp;lt;/tt&amp;gt;, you need to move the following lines,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=c&amp;gt;&lt;br /&gt;
#ifdef _WIN64&lt;br /&gt;
#define MS_WIN64&lt;br /&gt;
#endif&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
further up the file, to just before the &amp;lt;tt&amp;gt;#ifdef _MSC_VER&amp;lt;/tt&amp;gt; in line 107.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Earlier, we thought that you also needed to patch the Python include file &#039;modsupport.h&#039;. We don&#039;t think that&#039;s necessary now, if the above patch is made.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Install SWIGWIN 1.3.40 to c:\MinGW\swigwin-1.3.40 and add it to your MSYS PATH. Note that ({{bug|494}}) there is currently a bug in SWIG 2.x that prevents us from using it. It looks like that SWIG bug is fixed in their code, but we have to wait for the SWIG 2.0.5 release.&lt;br /&gt;
&lt;br /&gt;
You can now build the ASCEND Python module, &amp;lt;tt&amp;gt;ascpy&amp;lt;/tt&amp;gt;. It seems to work, but as of writing, there is a crash in the GUI when instantiating a model. It might be that there are still some errors in relation with 64-bit data types, possibly in the {{srcdir|ascxx}} code. With the above, &amp;lt;tt&amp;gt;./test.py TestSolver.testsunpos6&amp;lt;/tt&amp;gt; loads and solves a model correctly! Python bindings at least partly operational! Also, &amp;lt;tt&amp;gt;pygtk/ascdev models/test/ipopt/test6.a4c&amp;lt;/tt&amp;gt; seems to work too, if the runtime dependencies listed below are first installed.&lt;br /&gt;
&lt;br /&gt;
=== Notes about Python with MinGW-w64 ===&lt;br /&gt;
&lt;br /&gt;
There seem to be warnings on the net about MinGW and MinGW-w64 used with SWIG. It has always worked fine for us on Win32, but maybe there are new issues arising. To test this, here is a simple &#039;hello world&#039; example SWIG module. It works on Ubuntu 11.10 32-bit, and builds fine on Win7 64-bit, but fails with a segfault when exiting.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[[Media:swigtest.tar.gz|swigtest.tar.gz]]&#039;&#039;&#039; (900 byte tarball)&lt;br /&gt;
&lt;br /&gt;
MinGW-w64 can build (without SWIG) against Python 2.7 for at least trivial bindings... we can prove it. A simple example that takes a string, prints it, and calculates its length, seems to work fine:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;[[Media:pytest.tar.gz|pytest.tar.gz]]&#039;&#039;&#039; (1.1k tarball)&lt;br /&gt;
&lt;br /&gt;
Both of the above tests work fine if the patch from [http://bugs.python.org/issue4709 python bug 4709] is applied to your installed Python pyconfig.h header file.&lt;br /&gt;
&lt;br /&gt;
Other pages on MinGW with Python:&lt;br /&gt;
* http://sebsauvage.net/python/mingw.html (32-bit version)&lt;br /&gt;
* http://boodebr.org/main/python/build-windows-extensions&lt;br /&gt;
&lt;br /&gt;
== Cunit ==&lt;br /&gt;
&lt;br /&gt;
* use SVN code from the branch &#039;mingw64&#039;:&lt;br /&gt;
** cd&lt;br /&gt;
** svn co https://cunit.svn.sourceforge.net/svnroot/cunit/branches/mingw64 cunit &lt;br /&gt;
** cd cunit&lt;br /&gt;
* &amp;lt;tt&amp;gt;./configure --prefix=/mingw --host=x86_64-w64-mingw32 --build=mingw32&amp;lt;/tt&amp;gt;&lt;br /&gt;
* make install&lt;br /&gt;
&lt;br /&gt;
== SUNDIALS ==&lt;br /&gt;
&lt;br /&gt;
SUNDIALS is used by the [[IDA]] solver in ASCEND.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;tt&amp;gt;./configure --host=x86_64-w64-mingw32 --prefix=/mingw&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make -j4&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make install&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== IPOPT ==&lt;br /&gt;
&lt;br /&gt;
* download and extract the &#039;findutils&#039; lzma tarball from [http://sourceforge.net/projects/mingw/files/MSYS/Base/findutils/findutils-4.4.2-2/findutils-4.4.2-2-msys-1.0.13-bin.tar.lzma/download here]; put the extract &#039;find.exe&#039; and &#039;xargs.exe&#039; into c:/msys/bin.&lt;br /&gt;
* download the source tarball for IPOPT 3.10.1&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd ThirdParty/Blas &amp;amp;&amp;amp; ./get.Blas &amp;lt;/tt&amp;gt; (note that on my system I had to edit the URL in the &amp;lt;tt&amp;gt;get.Blas&amp;lt;/tt&amp;gt; script to use &amp;quot;http:&amp;quot; instead of &amp;quot;ftp:&amp;quot;)&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd ThirdParty/Metis &amp;amp;&amp;amp; ./get.Metis&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd ThirdParty/Mumps &amp;amp;&amp;amp; ./get.Mumps&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;cd ThirdParty/Lapack &amp;amp;&amp;amp; ./get.Lapack&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;./configure --host=x86_64-w64-mingw32 --prefix=/mingw&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make -j4&amp;lt;/tt&amp;gt;&lt;br /&gt;
* &amp;lt;tt&amp;gt;make install&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the install works OK you should have some /mingw/libcoin* and /mingw/libipopt.a files.&lt;br /&gt;
&lt;br /&gt;
This will build you a static IPOPT solver. There isn&#039;t a way to build a DLL of IPOPT with MinGW yet, apparently.&lt;br /&gt;
&lt;br /&gt;
To get &amp;lt;tt&amp;gt;scons&amp;lt;/tt&amp;gt; to detect this build of IPOPT, use&lt;br /&gt;
&lt;br /&gt;
 scons --config=force -j4 IPOPT_LIBPATH=/mingw/lib IPOPT_PREFIX=/mingw IPOPT_LIBS=ipopt,coinmumps,coinmetis,coinlapack,coinblas,gfortran,stdc++&lt;br /&gt;
&lt;br /&gt;
The above seems to work fine, except that it results in a dynamic link to &amp;lt;tt&amp;gt;libgfortran-3.dll&amp;lt;/tt&amp;gt; that must be satisfied at runtime in order for IPOPT to work. Possibly a solution will be&lt;br /&gt;
&lt;br /&gt;
 F77FLAGS=&amp;quot;-static&amp;quot; ./configure --host=x86_64-w64-mingw32 --prefix=/mingw&lt;br /&gt;
&lt;br /&gt;
Wait and see if that works...&lt;br /&gt;
&lt;br /&gt;
== GDB ==&lt;br /&gt;
&lt;br /&gt;
* Download the GDB package from the MinGW-64 site [https://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/gdb/ here] (we chose [http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/gdb/x86_64-w64-mingw32-gdb-7.1.90.20100730.zip/download x86_64-w64-mingw32-gdb-7.1.90.20100730.zip])&lt;br /&gt;
* Building GDB from source tarball version 7.3.1 worked OK but the resulting GDB didn&#039;t recognise/load symbols from the running executable. So download the MinGW-64 pre-compiled version instead.&lt;br /&gt;
&lt;br /&gt;
== Runtime requirements ==&lt;br /&gt;
&lt;br /&gt;
To actually run the GUI resulting from the above build, you still need to install GTK+, PyGTK, PyCairo, PyGObject. Get the amd64 py2.7 packages from this page:&lt;br /&gt;
&lt;br /&gt;
* http://ftp.gnome.org/pub/GNOME/binaries/win64/gtk+/2.22/&lt;br /&gt;
** get the GTK+ 2.22 runtime &#039;&#039;&#039;&#039;bundle&#039;&#039;&#039;&#039;&lt;br /&gt;
** extract to c:\GTK&lt;br /&gt;
** make sure you don&#039;t have any other GTK installations on your path&lt;br /&gt;
&lt;br /&gt;
* http://www.lfd.uci.edu/~gohlke/pythonlibs&lt;br /&gt;
** &amp;lt;tt&amp;gt;py2cairo-1.10.0.win-amd64-py2.7.‌exe&amp;lt;/tt&amp;gt;&lt;br /&gt;
** &amp;lt;tt&amp;gt;pygobject-2.28.6.win-amd64-py2.7.‌exe&amp;lt;/tt&amp;gt;&lt;br /&gt;
** &amp;lt;tt&amp;gt;pygtk-2.22.0.win-amd64-py2.7.‌exe&amp;lt;/tt&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To test the above:&lt;br /&gt;
* c:\GTK\bin must be in your PATH when attempting to run anything that uses GTK.&lt;br /&gt;
* gtk-demo.exe should work and pop up a window with some GUI demos&lt;br /&gt;
* start up Python and try&lt;br /&gt;
&amp;lt;source lang=py&amp;gt;import gtk&lt;br /&gt;
w = gtk.Window()&lt;br /&gt;
w.add(gtk.Label(&amp;quot;hello&amp;quot;))&lt;br /&gt;
w.show_all()&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Some helpful diagnostics for finding out why &#039;import gtk&#039; gives errors in some cases: (in my case, I needed to add c:/GTK/bin to the START of my PATH because of a conflicting ZLIB1.DLL earlier in my PATH.&lt;br /&gt;
* http://gramps-project.org/wiki/index.php?title=ImportError:_DLL_load_failed&lt;br /&gt;
&lt;br /&gt;
Some optional components that will allow the ASCEND GUI to do more:&lt;br /&gt;
* http://www.lfd.uci.edu/~gohlke/pythonlibs/&lt;br /&gt;
** IPython&lt;br /&gt;
** NumPy&lt;br /&gt;
** Matplotlib&lt;br /&gt;
&lt;br /&gt;
== Creating the installer ==&lt;br /&gt;
&lt;br /&gt;
A number of changes are required to produce an installer for the 64-bit version of ASCEND:&lt;br /&gt;
* make sure no WoW3264Node confusions arise when trying to install 64-bit ASCEND on 64-bit Windows.&lt;br /&gt;
* it should still be possible to install 32-bit ASCEND on 64-bit Windows.&lt;br /&gt;
* ensure package works without gfortran, libstdc++, libgcc being present on the system&lt;br /&gt;
* make sure that installed versions of GTK/Python etc are 64 bit and not 32-bit.&lt;br /&gt;
* are there any issues with MSVCR90.DLL not being present? PyGTK seems to depend on it.&lt;br /&gt;
* what happens when you try to install on Windows 32?&lt;br /&gt;
* include all required dependencies in the package: total size would be +~45MB (minus compression savings, minus optimisations from removing unneeded bits of GTK+?&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Ben_Allan&amp;diff=1960</id>
		<title>Ben Allan</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Ben_Allan&amp;diff=1960"/>
		<updated>2011-03-28T20:02:50Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Ben Allan is a former ASCEND GSOC mentor and is still episodically involved in development as his personal time allows.&lt;br /&gt;
&lt;br /&gt;
His particular primary interests are in:&lt;br /&gt;
&lt;br /&gt;
* refactoring the globals out of ascend C code.&lt;br /&gt;
* to make it thread-safe and embeddable.&lt;br /&gt;
* to make it easily integrated with other languages, and vice versa.&lt;br /&gt;
* to make it easier to liberate models from ascend once they are developed.&lt;br /&gt;
&lt;br /&gt;
[[Category:ASCEND Contributors]]&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
	<entry>
		<id>https://ascend4.org/index.php?title=Student_projects&amp;diff=1959</id>
		<title>Student projects</title>
		<link rel="alternate" type="text/html" href="https://ascend4.org/index.php?title=Student_projects&amp;diff=1959"/>
		<updated>2011-03-28T19:57:54Z</updated>

		<summary type="html">&lt;p&gt;BenAllan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Here are some possible projects for students wanting to participate in the ASCEND project. These could be suitable for [http://code.google.com/soc GSOC] projects, final-year theses in Engineering studies, research projects, etc. For contact details, see the [[Support]] page. &lt;br /&gt;
&lt;br /&gt;
The following exercises are no longer part of the application process but may be interesting reading [[OpenMP Exercise]], [[ANTLR exercise]].&lt;br /&gt;
Submitting patches to fix bugs in the tracker or working on a new feature ahead of GSOC11 are the best ways to support an application.&lt;br /&gt;
&lt;br /&gt;
Please contact John Pye instead of Ben Allan for any item below listing Ben Allan as contact. Ben is not mentoring for 2011, though he may be helpful by email after GSOC starts.&lt;br /&gt;
&lt;br /&gt;
See also [[Development Activities]]. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;GSOC applicants, please also read our suggestions for [[GSOC2011]].&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Active projects =&lt;br /&gt;
&lt;br /&gt;
== [[Integration of conditional models]] ==&lt;br /&gt;
&lt;br /&gt;
Dynamic models with switching behaviour are a common need in much engineering work. Examples from mechanical engineering include non-return valves, on/off valves, laminar/turbulent transitions, user demand for hot water, sunlight dropping while clouds pass, etc.&lt;br /&gt;
The [[IDA]] solver provides support for detection of boundaries during the solution of the [[DAE]] system. These boundaries can be used to stop the solver, and to implement switching conditions, for example to switch from laminar flow to turbulent flow once the speed gets to a certain threshold. This problem requires digging deeply into the [[conditional modelling]] data structures in ASCEND and re-wiring them for use with dynamic simulations.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Languages: C&lt;br /&gt;
&lt;br /&gt;
Current activity: [[Leon Kwek]] is working on this project as a final-year engineering honours project [http://cecs.anu.edu.au at ANU].&lt;br /&gt;
&lt;br /&gt;
== ABsolver integration ==&lt;br /&gt;
&lt;br /&gt;
[[ABsolver]] is an interesting new kind of solver that uses a [http://en.wikipedia.org/wiki/Boolean_satisfiability_problem SAT] solver to drive the solution to a [[conditional modelling]] problem. We would like to work together with the authors of ABsolver to connect that solver to our modelling environment, and then test it on a range of engineering problems. It&#039;s not sure yet if some tricks will be required to make the SAT problem formulation compatible with ASCEND&#039;s modelling language, so there&#039;s a bit of architecture/design required as part of this problem.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]], Andreas Bauer (one of the ABsolver developers)&lt;br /&gt;
* Level of difficulty: not sure yet&lt;br /&gt;
* Languages: C, C++&lt;br /&gt;
* Priority: Low/Medium&lt;br /&gt;
&lt;br /&gt;
Current activity: [[Franc Ivankovic]] is working on this an a final-year engineering honours project [http://cecs.anu.edu.au/ at ANU].&lt;br /&gt;
&lt;br /&gt;
== QRCUDA ==&lt;br /&gt;
&lt;br /&gt;
This project involves writing a parallelised version of [[QRSlv]] that works with CUDA GPGPUs.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye&lt;br /&gt;
* Level of difficulty: high&lt;br /&gt;
&lt;br /&gt;
Current activity: [[User:Arash]] from Murdoch University, Western Australia, is working on this project.&lt;br /&gt;
&lt;br /&gt;
== RADAU5 ==&lt;br /&gt;
&lt;br /&gt;
ASCEND currently has a good supply of multi-step solvers for [[ODE]]/[[DAE]] systems, namely [[LSODE]] and [[IDA]], but for single-step solvers, only [[DOPRI5]] (explicit solver for non-stiff problems) is present. This project involves the addition of the [[RADAU5]], an implicit solvers for stiff problems. RADAU5 is a mature solver, and connecting it is not expected to be overly difficult, but it will be a useful addition for a certain class of dynamic problems, and also useful for benchmarking.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye, Kannan Moudgalya&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
&lt;br /&gt;
Current activity: [[Shrikanth Ranganadham]] from IIT-Bombay is working on this project as part of a Masters degree in the Chemical Engineering Department.&lt;br /&gt;
&lt;br /&gt;
= New projects =&lt;br /&gt;
&lt;br /&gt;
== Dynamic modelling improvements ==&lt;br /&gt;
&lt;br /&gt;
This project would build on the progress with [[dynamic modelling]] by [[User:DanteStroe|Dante]] in GSOC2009. This year, we&#039;d like to thoroughly incorporate the new [[LINK syntax]] into the integrator API, and and make further changes to the ASCEND language to make dynamic modelling more &#039;natural&#039;, hopefully getting as far as simple &amp;lt;tt&amp;gt;der(x) = x + y&amp;lt;/tt&amp;gt; expressions being possible. The changes to the integrator API would need to be incorporated into all the current [[ODE]]/[[DAE]] solvers, too, as part of this work. Some reusable elements would be identified, and may be incorporated into libascend.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: High&lt;br /&gt;
* Priority: High&lt;br /&gt;
* Must know: numerical methods&lt;br /&gt;
* Languages: C, plus ideally some experience of lex/yacc&lt;br /&gt;
&lt;br /&gt;
== Debugging tools for DAE modelling ==&lt;br /&gt;
&lt;br /&gt;
We would like to implement tools that make it easier to determine degrees-of-freedom problems for inital value problems, and possibly implement index reduction into ASCEND. This project is probably contingent on completion of the [[#Dynamic modelling improvements]] project above, so we list this idea here as a future placeholder.&lt;br /&gt;
&lt;br /&gt;
* Contact person [[John Pye]]&lt;br /&gt;
* Level of difficulty: High&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
* Must know: numerical methods, differential equations, graph theory&lt;br /&gt;
* Languages: C&lt;br /&gt;
&lt;br /&gt;
== Renewable energy system modelling ==&lt;br /&gt;
&lt;br /&gt;
A student with strong engineering thermodynamics skills is needed to work on expanding support for energy systems modelling in ASCEND (see [[Renewable_energy_systems_modelling|here]] and [[Energy_system_modelling_with_ASCEND|here]]). We would like as a minimum to be able to perform annual simulations of domestic solar hot water systems of a variety of types. If time permits, we would like to move on to dynamic simulations of large-scale solar thermal power stations, including trough, dish, and tower systems. Initially, models based on correlations and equations from published journal papers are the goal. Good textbooks containing the necessary background theory would be Çengel &#039;&#039;Thermodynamics&#039;&#039; (Rankine cycles, etc) and Duffie &amp;amp;amp; Beckman &#039;&#039;Solar Engineering of Thermal Processes&#039;&#039; (solar collectors, solar radiation, etc).&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: Medium&lt;br /&gt;
* Priority: High&lt;br /&gt;
* Must know: Thermodynamics, Heat transfer&lt;br /&gt;
* Languages: C, ASCEND&lt;br /&gt;
&lt;br /&gt;
== GUI improvements ==&lt;br /&gt;
&lt;br /&gt;
Our PyGTK-based GUI for ASCEND now implements are fairly usable subset of the functionality originally provided by the Tcl/Tk GUI. But there are some rusty bits and some buggy bits, and some functionality that still remains to be implemented. This project would require a student with a bit of a flair and/or interest in human interface design (eg see the [http://library.gnome.org/devel/hig-book/stable/ GNOME HIG]), as well as hopefully a little bit of experience using [[Other_modelling_tools|other comparable software packages]], to go in and look at the old Tcl/Tk GUI, look at the new PyGTK GUI and then go ahead and add or fix up the missing pieces, while also fixing some of the [http://tinyurl.com/ascbugs1 various bugs in the currently-implemented stuff].&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: Medium/Low&lt;br /&gt;
* Priority: High&lt;br /&gt;
* Must know: usability principles&lt;br /&gt;
* Languages: Python, C (and learn to read Tcl/Tk code)&lt;br /&gt;
&lt;br /&gt;
== [[Canvas-based_modeller_for_ASCEND|Canvas-based modelling]], continued ==&lt;br /&gt;
&lt;br /&gt;
Our recent GSOC project on this topic made excellent progress, and it is now possible to construct and solve simple models uby &#039;wiring up&#039; blocks and setting the parameters therein. However, more work is needed before this tool becomes generally usable. This includes adding support for customised block appearance (so that the canvas looks more like a process flow diagram), and consideration of some nitty-gritty issues relating to debugging of models with closed circulation loops, which naturally involve redundant equations. We&#039;d really like someone from an engineering background to take this one on, if possible, because we also need to develop a library of suitable canvas components, such as turbines, pumps, etc. Another area of work is specification of flow streams. When dealing with fully generic models of things like turbines, etc, we need to be able to specify the fluids in the system in some way that is independent of the blocks being sketched out. Suitable architecture for that needs to be discussed and designed.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
* Must know: computer graphics, human-computer interface design, graph theory&lt;br /&gt;
* Priority: High&lt;br /&gt;
* Languages: Python, C/C++.&lt;br /&gt;
&lt;br /&gt;
== Improvements to the Conditional Modelling syntax ==&lt;br /&gt;
&lt;br /&gt;
ASCEND provides support for [[Conditional modelling]] in the form of language constructs and a solver called [[CMSlv]]. Unfortunately the syntax available for conditional modelling is unintuitive. It could be improved by a student willing to delve into the dark corners of the ASCEND compiler and willing to learn about the Flex and Bison parser/compiler tools. Further work on this project could include a rigorous test-suite to demonstrate that all aspects of the conditional model parser and corresponding solver are working OK. Additional further might include enhancements to the graphical interface to make it more obvious to the user when parts of the model are switched on and off as a result of changes in IF or WHEN statements, or alternatively completion of the conditional modelling support for the dynamic modelling solver [[IDA]]. This is another item that would benefit from a [[New Compiler]] effort.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]], [[Art Westerberg]]&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
* Priority: High&lt;br /&gt;
* Languages: Flex/Bison, C&lt;br /&gt;
&lt;br /&gt;
== BonMin integration ==&lt;br /&gt;
&lt;br /&gt;
For [[conditional modelling]] problems, ASCEND currently offers [[CMSlv]] solver, developed by Vicente Rico-Ramirez. To diversify our offerings for solving these kinds of problems, we would like to also add support for [https://projects.coin-or.org/Bonmin BonMin], the MINLP solver offered by the COIN-OR project. The BonMin API seems to have some notable differences from the API provided by ASCEND, so we anticipate that providing the suitable adapter routines will be a significant part of the project&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: hard&lt;br /&gt;
* Must know: numerical methods, operations research&lt;br /&gt;
* Languages: C.&lt;br /&gt;
* Priority: Medium/High&lt;br /&gt;
&lt;br /&gt;
== Bug Squashing ==&lt;br /&gt;
&lt;br /&gt;
We&#039;ve got a [http://ascendbugs.cheme.cmu.edu/ big long list] of bugs and feature requests (as well as [http://ascendbugs.cheme.cmu.edu/roadmap_page.php a shortlist]) that a student could certainly work on with success. Many of the bugs we fairly easily fixed and just need a little time. Someone with the right C/C++/Python programming background plus understanding on numerical methods and hopefully some understanding of compiler design and/or GUI design could really make a difference to ASCEND. (see also [[#Packaging for Mac]])&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: variable, depends on the bugs you choose to fix&lt;br /&gt;
* Must know: numerical methods&lt;br /&gt;
* Languages: C, and then possibly Python, C++, Flex/Bison, SWIG, Tcl/Tk, PyGTK,...&lt;br /&gt;
* Priority: Medium/High&lt;br /&gt;
&lt;br /&gt;
== Model Export Engine Experiments (meee!) ==&lt;br /&gt;
&lt;br /&gt;
A number of the other projects on this page are concerned with converting a model into some format appropriate for use with another tool.  There are actually 2 kinds of objects both ambiguously known as ASCEND models:&lt;br /&gt;
&lt;br /&gt;
* an ascend TypeDescription: a lit of statements that must be interpreted somehow to derive a data tree (Instance) in memory.&lt;br /&gt;
* an Instance data tree (which, in principle, may contain references to unexecuted statements from the TypeDescription or may be &#039;completed&#039;).&lt;br /&gt;
&lt;br /&gt;
Potential approaches&lt;br /&gt;
&lt;br /&gt;
* Conversion of C TypeDescriptions to equivalent classes in some other language is the most general form of model reuse, but requires careful implementation of the conversion operation. A general solution would be to create, or expose in a convenient form, visitor functionality over a self-consistent list of related TypeDescriptions for type-translation plugins to convert to other languages. In the compiler science world, the ascend TD is most related to an AST.&lt;br /&gt;
&lt;br /&gt;
* Conversion of ascend model source via an independent parser to another language. This approach &#039;reinvents&#039; the ASCEND AST and grammar, but may then be much more translator friendly-- e.g. Java or other tools could be used for implementation with no direct reference to the existing C code base.&lt;br /&gt;
&lt;br /&gt;
* Define a visitor API for conversion of instance data structures to classes in other languages. These classes may or may not look anything like the original object-oriented models. Note that conversions of this sort to flat-file data storage formats (for reloading in ascend later) and to object-free (flat) modeling languages are in the ascend code base already.&lt;br /&gt;
&lt;br /&gt;
See also: Persistence, Openoffice below.&lt;br /&gt;
&lt;br /&gt;
Contact person: [[Ben Allan]]&lt;br /&gt;
Level of difficulty: medium&lt;br /&gt;
Language: C / ANTLR /&amp;amp;nbsp;?&lt;br /&gt;
Priority: Medium&lt;br /&gt;
&lt;br /&gt;
== Persistence of modelling results ==&lt;br /&gt;
&lt;br /&gt;
Currently, ASCEND models are loaded and solved afresh each time. But sometimes, it can take a bit of fiddling to acheive solution of a model. In these cases, it would be useful to be able to save the model state and load it again into ASCEND. A coherent proposal for how to do this needs to be prepared, in discussion with the ASCEND team, by a student who would like to work in this area. Because this task involved loading and saving model state, it is proposed that it could also incorporate more general data export functionality, eg to export whole/partial model results to a CSV or tab-delimited file, for use with other tools. How this system would work with &#039;observers&#039; and &#039;integrator&#039; output is an open question. See also [[Saving and restoring model state]].&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: Low-medium&lt;br /&gt;
* Languages: C, Python, possibly some Tcl.&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
&lt;br /&gt;
== GAMS/AMPL interface ==&lt;br /&gt;
&lt;br /&gt;
The optimisation programs GAMS and AMPL provide well-defined (&#039;server&#039;) interfaces with which their solvers interact (as &#039;clients&#039;). It should be possible for ASCEND to reproduce the GAMS and/or AMPL server interfaces, and hence to allow ASCEND immediate access to re-using all of the solvers implemented for those programs. The same could possibly also be said of the CUTEr solver/problem suite.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: Medium&lt;br /&gt;
* Must know: numerical methods, operations research&lt;br /&gt;
* Languages: C&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
&lt;br /&gt;
== CMSlv with IPOPT, improvements to solver API ==&lt;br /&gt;
&lt;br /&gt;
In GSOC2009, Mahesh completed the tie-in of the [[IPOPT]] solver into ASCEND. Next, we would like to modify our current CMSlv solver to be able to use IPOPT or CONOPT interchangeably, so that we have a completely open-source way of doing [[conditional modelling]]. An important part of this project would be reviewing of current solver APIs and making changes to allow solvers to work well in &#039;nested&#039; ways, for example, for CMSlv to make calls to IPOPT. Down the track, we might also want other combinations, such as a dynamic optimiser, in which [[IPOPT]] makes calls to [[IDA]], for example.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
* Languages: C.&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
&lt;br /&gt;
== Export/Import ASCEND models to OpenOffice spreadsheet ==&lt;br /&gt;
&lt;br /&gt;
We would like to be able to export models and data sets to spreadsheets,&lt;br /&gt;
as the spreadsheet is the most common interface used by energy systems modelers&lt;br /&gt;
today. Export will give advanced modelers using ascend more ways to communicate&lt;br /&gt;
their results to others. Import from spreadsheets and data exchange will give spreadsheet modelers&lt;br /&gt;
access to all ASCEND solvers without loss of their preferred user interface. &lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
* Languages: most likely C, python, XML.&lt;br /&gt;
* Priority: Low&lt;br /&gt;
&lt;br /&gt;
== Parameter estimation ==&lt;br /&gt;
&lt;br /&gt;
We would like to be able to process a dynamic ASCEND model with experimental data, and use the experimental data to give us estimates of the key operating parameters of the system. This would be useful for fitting models to experimental data in situations where simple steady-state measurements can not provide those parameters. It is anticipated that this would make use of similar code to the [[IPOPT]] solver, but would probably require a new Estimation API to be set up; defining a suitable API would be part of this project.&lt;br /&gt;
&lt;br /&gt;
One application of this type of modelling would be to use inside and outside temperature measurements for a house, taken over a few days, to predict its thermal characteristics (insulation effectiveness, thermal mass, etc), as a simple way of evaluating whether a house meets current standards of energy efficiency.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
* Must know: numerical methods, modern control theory&lt;br /&gt;
* Languages: C&lt;br /&gt;
* Priority: Low (until someone has an itch!)&lt;br /&gt;
&lt;br /&gt;
== Parallelising ASCEND computations ==&lt;br /&gt;
&lt;br /&gt;
There is the potential for large speedups in ASCEND by implementing parallel evaluation of equation residuals. For systems with a large number of equations in a single block, this could give very large improvements. This project would involve writing a new [[Solvers|Solver]] based on [[QRSlv]] that incorporated message passing using [http://en.wikipedia.org/wiki/OpenMP OpenMP] or similar.&lt;br /&gt;
More detailed ideas on [[Parallelizing ASCEND]]. GSOC applicants interested in this area should consider working the [[OpenMP Exercise]] (our apologies to anyone who may have tried for 2010 the [[Differentiation Exercise]] that has expired.&lt;br /&gt;
&lt;br /&gt;
* Contact person: Ben Allan&lt;br /&gt;
* Level of difficulty: medium-high&lt;br /&gt;
* Priority: Medium/Low&lt;br /&gt;
* Languages: C/C++ (with MPI, OpenMP, etc)&lt;br /&gt;
&lt;br /&gt;
== [[Reaction kinetics data]] support ==&lt;br /&gt;
&lt;br /&gt;
Currently, reaction rate models in ASCEND are done on an ad hoc basis. Assorted tools, notably [http://en.wikipedia.org/wiki/CHEMKIN CHEMKIN], define and support a widely used [http://www.frad.t.u-tokyo.ac.jp/public/chemkin/CKm_man.html.en text input format] for describing chemical reaction rate equations. This project would include:&lt;br /&gt;
* creating or adapting an open-source parser of the CHEMKIN data format to generate a data representation suitable for machine transformations.&lt;br /&gt;
* defining a transformation instance that maps the equations into ASCEND equation code.&lt;br /&gt;
* defining a transformation instance that maps the equations into python, C or C++ code for performance comparisons.&lt;br /&gt;
* demonstrating the use of the tool on test problems related to renewable energy systems: H&amp;lt;sub&amp;gt;2&amp;lt;/sub&amp;gt;-air or methane-water.&lt;br /&gt;
* [https://github.com/OpenCFD/OpenFOAM-1.7.x/tree/master/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader this code] may be of some help, possibly.&lt;br /&gt;
&lt;br /&gt;
* Contact person: Ben Allan, Krishnan Chittur&lt;br /&gt;
* Level of difficulty: low-medium&lt;br /&gt;
* Must know: physical chemistry, chemical engineering, numerical methods&lt;br /&gt;
* Languages: C (but other compiled languages may be possible)&lt;br /&gt;
* Priority: Low&lt;br /&gt;
&lt;br /&gt;
== Thermophysical properties database ==&lt;br /&gt;
&lt;br /&gt;
ASCEND includes a set of native ASCEND models that provide support for thermodynamic property correlations of a number of types. The current system is fully open and extensible, but its use of native ASCEND syntax makes it difficult to maintain, and difficult to browse the list of available chemical species. It also makes it difficult for users to work out how to add support for new substances. This project would involve migrating the chemical property data to a separate data file (perhaps via an [http://www.sqlite.org SQLite] and then implementing a suitable interface between ASCEND and that database so that chemical property formulations could be loaded from the database by a suitable statement in the ASCEND model file. A range of tests would need to be developed to prove that the property formulations worked as expected. It might be possible to investigate other freely-available sources of chemical property data, and import that data if suitable. In performing this work, it would be desirable to consider the edicts of the [http://co-lan.org CAPE-OPEN] project, which specifies a possible API for accessing chemical property data in a platform-agnostic way. Some partial efforts have been made to implement a suitable system, see [[FPROPS]], although currently this consists only of pure C code, with no mechanism for loading material properties from a database, and no support for mixtures of fluids.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[Krishnan Chittur]]&lt;br /&gt;
* Level of difficulty: low-medium&lt;br /&gt;
* Must know: chemical engineering, physical chemistry&lt;br /&gt;
* Languages: C&lt;br /&gt;
* See also &amp;lt;a href=&amp;quot;#FPROPS&amp;quot; title=&amp;quot;&amp;quot;&amp;gt;#FPROPS&amp;lt;/a&amp;gt;&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
&lt;br /&gt;
== Packaging for Mac ==&lt;br /&gt;
&lt;br /&gt;
ASCEND has now been [[Porting_to_Mac|ported to Mac OS X]]. What remains to be done, however, is to create an application bundle that runs in the way users expect. This project will require the user to create a suitable set of &#039;frameworks&#039; and &#039;packages&#039; that allow ASCEND to run in a Mac-ish way, but without too much disruption to the overall codebase. One key challenge is to provide suitable Apple Event bindings so that models can be opened using the ASCEND GUI.&lt;br /&gt;
&lt;br /&gt;
This project seems as thought it may be a bit small so we&#039;d be looking for a candidate who&#039;s already demonstrated their willingness to tackle a range of other tasks relating to the overall improvement of the program.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye, Art Westerberg&lt;br /&gt;
* Level of difficulty: low-medium&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
* Languages: C, Python, plus maybe some need for Apple-specific languages like Objective C.&lt;br /&gt;
&lt;br /&gt;
== New Compiler ==&lt;br /&gt;
&lt;br /&gt;
The ASCEND compiler is currently highly efficient, but it has a large and complicated body of code based around the Flex/Bison toolset. Using more modern compiler-generators such as ANTLR we believe it will be possible to rewrite the ASCEND compiler to be more modular, more maintainable and hopefully faster. This task would be very challenging and require fairly extensive experience with compiler-compilers and small-language implementation. More detailed ideas on a [[New Compiler]]&lt;br /&gt;
&lt;br /&gt;
* Contact person: Ben Allan&lt;br /&gt;
* Level of difficulty: very high&lt;br /&gt;
* Languages: flexible, would need to interface with current instance hierarchy C code&lt;br /&gt;
&lt;br /&gt;
== [[FPROPS]] ==&lt;br /&gt;
&lt;br /&gt;
[[FPROPS]] is a module of code developed by John Pye to support thermodynamic property evaluations using Helmholtz correlation equations. This has the potential to be a very powerful and flexible solution to the problem of high-accuracy thermodynamic property evaluation, but it is still missing some crucial code relating to the location of the saturation line. A student with a strong understanding of thermodynamics would be able to complete this project. The real difficulty is in the thermo, the coding would be pretty straight-forward.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye&lt;br /&gt;
* Level of difficulty: low (programming), medium (thermodynamics), medium (numerical methods)&lt;br /&gt;
* Languages: C, ASCEND.&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
&lt;br /&gt;
Current activity: [[User:Ankitml|Ankit Mittal]] from IIT Bombay is working on some aspects of this task, but more work is also required in other areas.&lt;br /&gt;
&lt;br /&gt;
== Your Own Ideas ==&lt;br /&gt;
&lt;br /&gt;
There are many other areas of possible work on ASCEND, including those from our long list of current and future [[Development Activities]]. Feel free to discuss other possible ideas with us, see [[Support]] for contact details.&lt;br /&gt;
&lt;br /&gt;
* Contact person: send email to the &#039;users&#039; mailing list (see [[Support]])&lt;br /&gt;
&lt;br /&gt;
= Completed projects =&lt;br /&gt;
&lt;br /&gt;
These are the summaries of the projects that were undertaken during [[:Category:GSOC2009|our participation]] in [http://socghop.appspot.com/org/home/google/gsoc2009/ascend GSOC 2009].&lt;br /&gt;
&lt;br /&gt;
== [[Real-time ASCEND]] (more work is possible) ==&lt;br /&gt;
&lt;br /&gt;
The core engine of ASCEND is a low-level C code compiler and set of solvers. It is conceivable that ASCEND could be incorporated into a real-time control and/or parameter estimate engine, using live data feeds for its modelling calculations. This is an open-ended project, with the hope that basic use of ASCEND for this application could be demonstrated. With such a capability it would be possible to contemplate using ASCEND to control systems that change over time, by allowing the values of system parameters to be adjusted in response to changing system behaviour.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
* Lanaguages: C&lt;br /&gt;
&lt;br /&gt;
== [[Non-proprietary Optimisation]] (completed) ==&lt;br /&gt;
&lt;br /&gt;
ASCEND is a free/open source software package licensed under the GPL. We have a number of [[Solvers]] in our software, including a wrapper for the excellent optimisation solver [[CONOPT]]. Unfortunately, however, this solver is expensive commercial software and can not be distributed freely as part of ASCEND. The lack of a good (free) optimisation solver limits the utility of ASCEND for many users.&lt;br /&gt;
&lt;br /&gt;
This project would involve linking the [[IPOPT]] solver (or possibly some other suitable alternative, if any exists) to ASCEND, allowing us to run complex optimisation problems in ASCEND. Some work would be required to give ASCEND the ability to evaluate Hessian matrices (second derivatives of object functions), then tying it all together so that ASCEND can pass values and parameters etc through to the IPOPT solver.&lt;br /&gt;
&lt;br /&gt;
Further work on this project could include development of a benchmarking suite using various standard sets of optimisation problems such as [http://hsl.rl.ac.uk/cuter-www/ CUTEr].&lt;br /&gt;
&lt;br /&gt;
Note that there is a fairly new repository of open-source optimisation code now available from https://software.sandia.gov/trac/acro/wiki/Overview.&lt;br /&gt;
&lt;br /&gt;
* Contact person: Ben Allan&lt;br /&gt;
* Level of difficulty: medium-high.&lt;br /&gt;
* Language(s): C&lt;br /&gt;
&lt;br /&gt;
== Adding Exact Numerical Differentiation for Second Partial Derivatives (completed) ==&lt;br /&gt;
&lt;br /&gt;
(combined with &#039;Non-proprietary Optimisation&#039;)&lt;br /&gt;
&lt;br /&gt;
When solving nonlinear equations, the ASCEND solver creates exact numerical derivatives to create needed jacobian matrices.  This task would be to extend these capabilities to generate exact numerical second derivatives, which could then support optimization solvers.  The approach one can use is &amp;lt;a href=&amp;quot;/images/c/c3/PhDthesisChungExactNumDiffChapt6.pdf&amp;quot; class=&amp;quot;internal&amp;quot; title=&amp;quot;PhDthesisChungExactNumDiffChapt6.pdf&amp;quot;&amp;gt; in Chapter 6 (596 kB pdf)&amp;lt;/a&amp;gt; of  Yonsoo Chung, &amp;lt;u&amp;gt;Solving Index and Near Index Problems in Dynamic Simulation&amp;lt;/u&amp;gt;, PhD Thesis, Dept. of Chemical Engineering, Carnegie Mellon University (1991).&lt;br /&gt;
&lt;br /&gt;
Please consider submitting a response to the [[Differentiation Exercise]] if applying for this topic under GSOC.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye and Art Westerberg&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
* Languages: C&lt;br /&gt;
&lt;br /&gt;
== Renewable energy system modelling (more work is possible) ==&lt;br /&gt;
&lt;br /&gt;
ASCEND has all the built-in capabilities needed to solve systems of equations, and historically has been used to solve some difficult modelling problems in chemical and process engineering. We would like to improve its usefulness in the field of [[renewable energy systems modelling]], through the development of some reusable modelling &#039;blocks&#039; for common system components. These would include flat-plate solar hot water collectors, [[Calculation_of_sun_position|sun position]], [[Data_reader|weather data]], photovoltaic panels, pumps, turbines, storage tanks, and so on. The goal would be to allow typical engineers to quickly produce accurate models of renewable energy systems for various locations, hopefully including prediction of their economic performance.&lt;br /&gt;
&lt;br /&gt;
Much information on modelling these types of systems is available in books like Duffie and Beckman ([[Special:BookSources/0471698679|ISBN 0471698679]]), Flynne ([[Special:BookSources/0852964196|ISBN 0852964196]]) and elsewhere. This project would involve pulling together a coherent set of models for this task, and testing them carefully and making sure they are reusable and well-documented so that they can be of maximum use to the community.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye&lt;br /&gt;
* Level of difficulty: low-medium&lt;br /&gt;
* Languages: ASCEND, possibly some C for &#039;hard to converge&#039; models if necessary.&lt;br /&gt;
&lt;br /&gt;
== Improved ODE/DAE support (completed) ==&lt;br /&gt;
&lt;br /&gt;
ASCEND currently has a system for allowing users to model [[Dynamic_modelling|dynamic systems]]. You can specify variables that are the derivatives of other variables, and then use a special [[External_Integrators|Integrator]] to solve for time-varying behaviour of your model. We support a number of Integrators, including [[IDA]], [[LSODE]] and [[DOPRI5]].&lt;br /&gt;
&lt;br /&gt;
Unfortunately, however, the ASCEND syntax for dynamic models is very clumsy, and this makes it hard to write compact, readable models for such systems.&lt;br /&gt;
&lt;br /&gt;
This project would involve implementing proposed [[LINK semantics]] for ASCEND (in itself a value enhancement to the ASCEND language), then, upon that, building a new ODE/DAE syntax so that dynamic models could be succinctly expressed with the ASCEND modelling language. This would require you to become familiar with the [http://flex.sourceforge.net/ Flex] and [http://www.gnu.org/software/bison/ Bison] tools, which are used to implement the ASCEND language parser, so that you could then extend out language grammar with the necessary additional language constructs.&lt;br /&gt;
&lt;br /&gt;
Further work on this project could include enhancing the reporting from [[External Integrators]] including perhaps a live graphical plot of progress or improvements to the [[Data reader]] to allow arbitrary input data to be fed into a simulation.&lt;br /&gt;
&lt;br /&gt;
* Contact person: Ben Allan&lt;br /&gt;
* Level of difficulty: high&lt;br /&gt;
* Languages: C, Flex/Bison&lt;br /&gt;
&lt;br /&gt;
== [[Canvas-based modeller for ASCEND]] (more work is possible) ==&lt;br /&gt;
&lt;br /&gt;
Power stations are large and systems of many interacting components, including turbines, boilers, pumps and controllers. Their complexity arises as optimisations are applied, to extract the maximum possible energy from the available resource. The preferred way of modelling these systems is through the use of (very expensive) canvas-based GUI software in which &#039;blocks&#039; are shown connected by lines, and parameters can be adjusted by editing the data behind the various blocks in the model. Some work has [[Canvas-based_modeller_for_ASCEND|already taken place]] within the ASCEND project to implement a GUI, using [http://gaphor.devjavu.com/wiki/Subprojects/Gaphas Gaphas], allowing these kinds of energy systems to be modelling using a GUI, but further work is required. It is anticipated that great progress could be made on this if someone were able to dedicate a few months to the job, and the result would be an open energy modelling system that would be much more user-friendly for those people who don&#039;t like writing text-based models.&lt;br /&gt;
&lt;br /&gt;
* Contact person: John Pye&lt;br /&gt;
* Level of difficulty: low-medium&lt;br /&gt;
* Languages: Python (GTK, Cairo)&lt;br /&gt;
&lt;br /&gt;
== [[Automatic recursive initialisation]] (completed by the ASCEND developers) == &lt;br /&gt;
&lt;br /&gt;
Extend ASCEND&#039;s [[METHODS]] code so that certain methods are run recursively one instantiated [[MODEL|MODELs]]. This would allow simpler code for setting initial values of solver variables, and make constructing robust models easier, especially in the context of canvas-based modelling tools. Making this stuff work is probably an prerequisite for an efficient [[canvas-based modeller for ASCEND]], because it allows &#039;blocks&#039; to be initialised without the user having to explicitly request it.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: Medium&lt;br /&gt;
* Languages: C&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
&lt;br /&gt;
== Embedded solver settings (completed by the ASCEND developers) ==&lt;br /&gt;
&lt;br /&gt;
Difficult-to-solve models often require a bit of tweaking of the solver parameters, tolerances, etc, before a model will solve as intended. Currently, this must be done either manually via the GUI(s), or else through a script that exists separately from the model. We would like a way to embed solver parameter settings directly within the model. One approach that partly does the job (although not very nicely) is [[solver NOTES]]. We have also discussed the idea of a couple of new &#039;solver request&#039; keywords, such as &amp;lt;tt&amp;gt;SET&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;SOLVER&amp;lt;/tt&amp;gt; (see [[Controlling the solvers from within METHODS]]). This project would involve leading a design discussion to work out the best possible solution to this problem, and then implementing the agreed solution, as well as thorough testing.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[John Pye]]&lt;br /&gt;
* Level of difficulty: medium&lt;br /&gt;
* Languages: C, Python, Tcl/Tk (if both GUIs are to be supported)&lt;br /&gt;
* Priority: Medium/High&lt;br /&gt;
&lt;br /&gt;
== Prototype compiler ==&lt;br /&gt;
&lt;br /&gt;
Building a whole new compiler implementation and hooking it to the existing C system is very difficult (very high quality code and testing required), and is generally unsuitable for a 3 month project. A solid contribution possible in 3 months, however, is to create the basis for a new parser infrastructure and ascend4 language migration tool. The particulars are open to negotiation, but may include development of parsers and walkers from scratch in ANTLR or the extension of an existing language (e.g. [http://chapel.cray.com/ Chapel]?) to support equation based programming. See also chapel.cray.com and elsewhere in this site for Ben&#039;s scribblings on new compiler design.&lt;br /&gt;
&lt;br /&gt;
* Contact person: [[Ben Allan]]&lt;br /&gt;
* Level of difficulty: Low-Medium&lt;br /&gt;
* Priority: Medium&lt;br /&gt;
* Must know: ANTLR or other compiler development tools&lt;br /&gt;
* Languages: ASCEND, probably java, optionally C, Fortran&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>BenAllan</name></author>
	</entry>
</feed>