Hi Akash
Thanks very much for your contributions. When I open firstly your 'eos'
model, I get a window showing that there are errors in that file. ASCEND
doesn't crash, but it is apparent to me that there is some glitch/bug
being revealed, since there are multiple entries in the
'errors/warnings' pane at the bottom of the window, but no text is
visible. This suggests some issues with our 'error reporter' module,
which we have seen before but which I thought had been resolved.
A rather unsatisfying way to see some diagnostic output, to work around
this GUI issue for your immediate needs, is through use of the attached
mini-driver for ASCEND, which will output your parser errors to the
console. I place this file in the top-level folder in ASCEND, and
compile it using
gcc -orunqrslv runqrslv.c -lascend
then run it using
./runqrslv ~/ascend-steam-reformation/akash_eos.a4c
I have added this "runqrslv.c" file to the trunk of our repository, for
easy access. If I see any bugs in it, I'll fix them there.
After making some fixes to your syntax, I'm afraid I'm still getting a
segfault using the above method however. It will require a little more
looking to figure out what the problem is there.
Cheers
JP
On 26/03/15 11:11, Akash Deep Singhal wrote:
> Hello John,
>
> As you asked for the modeling of process of steam methane reformation
> in ASCEND, I have done that and the complete model can be seen found
> at https://github.com/akigupta131/ascend-steam-reformation
> Also the documentation for the same can be seen
> at
> https://docs.google.com/document/d/1XMvgZq-kiQaB27iSpOvbnnO875I_VII0BvBUnPTLNls/edit?usp=sharing
>
> I have some doubts though:-
> a. I can't run any of eos files. On running any of them, ascend window
> suddenly crashes and the command line gives segmentation fault (which
> got to know occurs when the program access some segment which it is
> not supposed to do.)
>
> b. I have included /akash_eos.a4c/ file in the /steam_reformation.a4c/
> file. But the error log states that it could not find the file (tried
> changing permissions of file. still the same)
>
> Please help and comment if you find something wrong.
>
> Thank you,
> Akash
> ᐧ
>
> On Wed, Mar 18, 2015 at 1:15 AM, Akash Deep Singhal
> <[email protected] <mailto:[email protected]>> wrote:
>
> Hello John,
>
> Thank you for the detailed reply. I also think that
> introducing/developing some ChemE based models would be great
> idea. For now, I am working on Ammonia synthesis flowsheet. I will
> post it soon.
>
> About my MTech research:-
> For the initial stage, there is not much of support available for
> openmodelica on ARM devices so we are trying to fix the repos to
> get it working on it. After that, the work is to get the core
> thermodynamics libraries of DWSIM+Cape Open and integrate them
> with openmodelica.
> More about the topic can be seen here
> :-
> http://www.che.iitb.ac.in/online/ddproject/integrating-openmodelica-and-dwsimcape-open-low-cost-netbook-computers
>
> Anyways, is there some IRC channel for the discussion. I couldn't
> find one.
>
>
> Thanks,
> Akash
> ᐧ
>
> On Mon, Mar 16, 2015 at 6:21 AM, John Pye <[email protected]
> <mailto:[email protected]>> wrote:
>
> Hi Akash
>
> Pleased to hear from you. Indeed, we have done a lot with Prof
> Kannan Moudgalya in the past. Depending on your interests
> there are quite a few areas that you could make good
> contributions. With your background, I would definitely
> suggest that you consider areas where your chemical
> engineering knowledge helps us out. For example, improving our
> thermodynamics routines (FPROPS etc), or in undertaking some
> development of missing component/unit models that allow ASCEND
> modelling of complex flowsheets of interest. For example, I
> would really like to see a comprehensive model of a eg ammonia
> synthesis or steam methane reforming processes in ASCEND, with
> at least cubic equations of state thermo. Building this up
> carefully and systematically, with good quality documentation,
> would be a very useful contribution.
>
> Let me know a bit more about your MTech research. Are you
> basically introducing equation-based components into the
> sequential-modular DWSIM framework?
>
> Cheers
> JP
>
>
> On 15/03/15 00:54, Akash Deep Singhal wrote:
>> Hello John and team,
>>
>> I am a 4th year student, pursuing a *Dual Degree* Course
>> (B.Tech + M.Tech) in the *Department of Chemical
>> Engineering* and minor in *Department of Computer
>> Science* at *IIT Bombay.
>> *
>> I have deep interest and some experience in Artificial
>> Intelligence, IoT and Data Structures. I am currently working
>> on my MTech Thesis '*Integration of Openmodelica and
>> DWSIM-CapeOpen on ARM based devices*' under the guidance of
>> Prof. Kannan M Moudgalya.
>>
>> Having ChE knowledge with programming interests, I would love
>> to work with Ascend. I have checked out svn, built it and now
>> I am playing around with set of models. Please give me some
>> area/bug to work at.
>>
>> Thank you,
>> photo <http://www.azeotropy.com/akash>
>> *Akash Deep Singhal*
>> 4th Year Undergraduate | IIT Bombay
>> | Mobile: 7738983120 | Email: [email protected]
>> <mailto:[email protected]>
>> | Web: http://www.akashsinghal.in
>>
>>
>>
>>
>> ------------------------------------------------------------------------------
>> Dive into the World of Parallel Programming The Go Parallel Website,
>> sponsored
>> by Intel and developed in partnership with Slashdot Media, is your
>> hub for all
>> things parallel software development, from weekly thought leadership
>> blogs to
>> news, videos, case studies, tutorials and more. Take a look and join
>> the
>> conversation now. http://goparallel.sourceforge.net/
>>
>>
>> _______________________________________________
>> Ascend-sim-users mailing list
>> [email protected]
>> <mailto:[email protected]>
>> https://lists.sourceforge.net/lists/listinfo/ascend-sim-users
>
>
>
>
> --
> photo <http://akashsinghal.in>
> *Akash Deep Singhal*
> 4th Year Undergraduate | IIT Bombay
> | Mobile: 7738983120 | Email: [email protected]
> <mailto:[email protected]>
> | Web: http://www.akashsinghal.in
>
>
>
>
> --
> photo <http://akashsinghal.in>
> *Akash Deep Singhal*
> 4th Year Undergraduate | IIT Bombay
> | Mobile: 7738983120 | Email: [email protected]
> <mailto:[email protected]>
> | Web: http://www.akashsinghal.in
>
REQUIRE "thermodynamics.a4l";
MODEL srk(P WILL_BE pressure;
T WILL_BE temperature;
V WILL_BE molar_volume;
Z WILL_BE factor;
f WILL_BE factor;
data WILL_BE td_component_constants;
);
R IS_A molar_gas_constant;
Pc IS_A pressure;
Tc IS_A temperature;
T_degC IS_A factor;
alpha, beta, q, A, Tr, Pr, omega IS_A factor;
PSI, OMEGA, sigma, eps IS_A real_constant;
PSI :== 0.42748;
OMEGA :== 0.08664;
sigma :== 1.0;
eps :== 0.0;
Pc = data.Pc;
Tc = data.Tc;
omega = data.omega;
eq1: Tr = T/Tc;
eq2: Pr = P/Pc;
eq3: T_degC = T/1{K} - 273.15;
eq4: alpha = (1.0 + (0.480+1.574*omega-0.176*omega^2)*(1.0-Tr^(0.5)))^2;
eq5: q = PSI*alpha/(OMEGA*Tr);
eq6: beta = OMEGA*Pr/Tr;
eq7: Z = 1.0 + beta - q*beta*(Z - beta)/((Z + eps*beta)*(Z + sigma*beta));
eq8: P*V = Z*R*T;
eq9: A = q*beta;
eqA: f = exp((Z-1)-ln(Z-beta)-q*ln((Z+beta)/Z)); (*fugacity coefficient*)
METHODS
METHOD default_self;
RUN ClearAll;
RUN specify;
RUN values;
END default_self;
METHOD specify;
P.fixed := TRUE;
T.fixed := TRUE;
T_degC.fixed := FALSE;
END specify;
METHOD values;
P := 12.0 {bar};
T := 298.15 {K};
Z.lower_bound := 0.0;
Z.upper_bound := 10.0;
Z.nominal := 1.0;
END values;
END srk;
MODEL testsrk;
c1 IS_A symbol_constant;
c1 :== 'ethylene';
cd IS_A components_data([c1],c1);
Tr, Pr IS_A factor;
P IS_A pressure;
T IS_A temperature;
V IS_A molar_volume;
Z IS_A factor;
f IS_A factor;
tsrk IS_A srk(P,T,V,f,Z,cd.data[c1]);
eqTr: Tr = T/cd.data[c1].Tc;
eqPr: Pr = P/cd.data[c1].Pc;
METHODS
METHOD default_self;
RUN ClearAll;
RUN specify;
RUN values;
END default_self;
METHOD specify;
P.fixed := TRUE;
V.fixed := FALSE;
Z.fixed := FALSE;
T.fixed := TRUE;
RUN tsrk.specify;
END specify;
METHOD values;
P := 12.0 {bar};
T := 298.15 {K};
RUN tsrk.values;
END values;
METHOD on_load;
RUN default_self;
END on_load;
END testsrk;
MODEL srk_comp(
c1 WILL_BE symbol_constant;
);
cd IS_A components_data([c1],c1);
Tr, Pr IS_A factor;
P IS_A pressure;
T IS_A temperature;
V IS_A molar_volume;
Z IS_A factor;
f IS_A factor;
tsrk IS_A srk(P,T,V,f,Z,cd.data[c1]);
eqTr: Tr = T/cd.data[c1].Tc;
eqPr: Pr = P/cd.data[c1].Pc;
METHODS
METHOD default_self;
RUN ClearAll;
RUN specify;
RUN values;
END default_self;
METHOD specify;
P.fixed := TRUE;
V.fixed := FALSE;
Z.fixed := FALSE;
T.fixed := TRUE;
RUN tsrk.specify;
END specify;
METHOD values;
P := 20.0 {bar};
T := 1173.15 {K}; (*900 degree Celcius*)
RUN tsrk.values;
END values;
METHOD on_load;
RUN default_self;
END on_load;
END srk_comp;
(* for easy use with 'runqrslv' *)
MODEL akash_eos REFINES testsrk;
END akash_eos;
/**
A minimal driver for ASCEND, using QRSlv. Console-based; no GUI. This can
be useful for checking low-level features in ASCEND, or working around
problems with reporting of errors/messages etc from the GUI.
See also our CUnit test suites eg in the directory ascend/solver/test.
See also some C++ driver code in directory ascxx. See also
ascend/solver/slv_interface.c for another 'lite' command-line interface, no
longer maintained but possibly of interest/useful.
Starting in the directory where this file is located, it can be compiled
using
gcc -orunqrslv runqrslv.c -lascend
providing ASCEND itself has already been compiled
(see http://ascend4.org/Building_ASCEND for details on how to do that)
*/
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <assert.h>
#include <ascend/utilities/config.h>
#include <ascend/general/env.h>
#include <ascend/general/ospath.h>
#include <ascend/general/list.h>
#include <ascend/general/ltmatrix.h>
#include <ascend/general/platform.h>
#include <ascend/utilities/ascEnvVar.h>
#include <ascend/utilities/error.h>
/* FIXME check whether we need all these includes? */
#include <ascend/compiler/module.h>
#include <ascend/compiler/parser.h>
#include <ascend/compiler/instquery.h>
#include <ascend/compiler/parentchild.h>
#include <ascend/compiler/atomvalue.h>
#include <ascend/compiler/relation_io.h>
//#include <ascend/compiler/reverse_ad.h>
//#include <ascend/compiler/relation_util.h>
//#include <ascend/compiler/mathinst.h>
//#include <ascend/compiler/watchpt.h>
#include <ascend/compiler/name.h>
#include <ascend/compiler/visitinst.h>
#include <ascend/compiler/functype.h>
#include <ascend/compiler/safe.h>
#include <ascend/compiler/qlfdid.h>
#include <ascend/compiler/instance_io.h>
#include <ascend/compiler/initialize.h>
#include <ascend/compiler/symtab.h>
#include <ascend/compiler/library.h>
#include <ascend/compiler/simlist.h>
#include <ascend/compiler/ascCompiler.h>
#include <ascend/compiler/packages.h>
#include <ascend/compiler/slvreq.h>
#include <ascend/system/system.h>
#include <ascend/system/slv_client.h>
#include <ascend/solver/solver.h>
#include <ascend/system/slv_server.h>
void usage(char *n){
fprintf(stderr,"%s FILENAME\n",n);
fprintf(stderr,
" Simple ascend driver\n"
" Loads and parses the model file FILENAME (eg path/to/myfile.a4c)\n"
" then attempts to instantiate the model with the name 'myfile'.\n"
" If the model file loads, it runs the 'on_load' method, then attempts\n"
" to solve the model using the default QRSlv solver. If it solves,\n"
" then the method 'self_test' will be run, which can be used to check\n"
" whether the expected results were found via ASSERT statements in that\n"
" method.\n");
}
int main(int argc, char *argv[]){
char env1[2*PATH_MAX];
int status;
int qrslv_index;
int simplify = 1;
/* get the filename from the commandline */
if(argc<2){
usage(argv[0]);
return 1;
}
const char *modelfile = argv[1];
const char *librarypath = ".:models";
/* get the file stem as the model name we'll look for */
struct FilePath *fp = ospath_new(modelfile);
char *modelname = ospath_getfilestem(fp);
/* initialise the compiler from scratch */
Asc_CompilerInit(simplify);
/* set the needed environment variables so that models, solvers can be found */
snprintf(env1,2*PATH_MAX,ASC_ENV_LIBRARY "=%s",librarypath);
assert(0 == Asc_PutEnv(env1));
assert(0 == Asc_PutEnv(ASC_ENV_SOLVERS "=solvers/qrslv"));
/* read back and display the ASCENDLIBRARY setting */
char *lib = Asc_GetEnv(ASC_ENV_LIBRARY);
CONSOLE_DEBUG("%s = %s",ASC_ENV_LIBRARY,lib);
ASC_FREE(lib);
/* load the QRSlv solver, presumably from the ASCENDSOLVERS path */
package_load("qrslv",NULL);
qrslv_index = slv_lookup_client("QRSlv");
assert(qrslv_index != -1);
/* load the model file */
Asc_OpenModule(modelfile,&status);
assert(status == 0);
/* parse it */
assert(0 == zz_parse());
/* FIXME, somehow this is failing to detect parser errors; we need to review
this assertion */
/* find the model */
assert(NULL != FindType(AddSymbol(modelname)));
/* instantiate it */
struct Instance *siminst = SimsCreateInstance(AddSymbol(modelname), AddSymbol("sim1"), e_normal, NULL);
assert(siminst!=NULL);
/* call the on_load method */
CONSOLE_DEBUG("RUNNING METHOD 'on_load'");
struct Name *name = CreateIdName(AddSymbol("on_load"));
/* TODO do we check that the method exists first? */
/* TODO, note that we have not hooked 'slvreq', here, so any calls to SOLVE, OPTION, SOLVER will fail */
enum Proc_enum pe = Initialize(GetSimulationRoot(siminst),name,"sim1", ASCERR, WP_STOPONERR, NULL, NULL);
assert(pe==Proc_all_ok);
/* 'build' the 'system' -- the flattened system of equations */
slv_system_t sys = system_build(GetSimulationRoot(siminst));
assert(sys != NULL);
/* assign the solver to the system */
CONSOLE_DEBUG("Assigning solver");
assert(slv_select_solver(sys,qrslv_index));
CONSOLE_DEBUG("Assigned solver '%s'...",slv_solver_name(slv_get_selected_solver(sys)));
/* presolve, check it's ready, then solve */
CONSOLE_DEBUG("Presolve...");
assert(0 == slv_presolve(sys));
slv_status_t status1;
slv_get_status(sys, &status1);
assert(status1.ready_to_solve);
CONSOLE_DEBUG("Solve...");
slv_solve(sys);
/* check that solver status was 'ok' */
slv_get_status(sys, &status1);
assert(status1.ok);
/* clean up the 'system' -- we don't need that any more */
CONSOLE_DEBUG("Destroying system...");
if(sys)system_destroy(sys);
system_free_reused_mem();
/* run 'self_test' method -- we can check there that the results are as expected */
CONSOLE_DEBUG("Running self-tests");
name = CreateIdName(AddSymbol("self_test"));
pe = Initialize(GetSimulationRoot(siminst),name,"sim1", ASCERR, WP_STOPONERR, NULL, NULL);
assert(pe==Proc_all_ok);
/* destroy the compiler data structures, hopefully all dynamically allocated memory */
CONSOLE_DEBUG("Destroying instance tree");
assert(siminst != NULL);
solver_destroy_engines();
sim_destroy(siminst);
Asc_CompilerDestroy();
/* clean up some locally declared vars */
ASC_FREE(modelname);
}
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ascend-sim-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ascend-sim-users