1 |
/* ASCEND modelling environment |
2 |
Copyright (C) 2007 Carnegie Mellon University |
3 |
|
4 |
This program is free software; you can redistribute it and/or modify |
5 |
it under the terms of the GNU General Public License as published by |
6 |
the Free Software Foundation; either version 2, or (at your option) |
7 |
any later version. |
8 |
|
9 |
This program is distributed in the hope that it will be useful, |
10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 |
GNU General Public License for more details. |
13 |
|
14 |
You should have received a copy of the GNU General Public License |
15 |
along with this program; if not, write to the Free Software |
16 |
Foundation, Inc., 59 Temple Place - Suite 330, |
17 |
Boston, MA 02111-1307, USA. |
18 |
*//** @file |
19 |
General-purpose jacobian routines that should hopefully be shareable |
20 |
but at this stage are only going to be used by IDA. |
21 |
*/ |
22 |
#ifndef ASC_SYS_JACOBIAN_H |
23 |
#define ASC_SYS_JACOBIAN_H |
24 |
|
25 |
#include "var.h" |
26 |
#include "rel.h" |
27 |
|
28 |
#include <linear/mtx.h> |
29 |
|
30 |
#include <general/mathmacros.h> |
31 |
#include <utilities/ascPanic.h> |
32 |
|
33 |
extern const rel_filter_t system_rfilter_algeb; |
34 |
extern const rel_filter_t system_rfilter_diff; |
35 |
extern const rel_filter_t system_rfilter_all; |
36 |
|
37 |
extern const var_filter_t system_vfilter_algeb; |
38 |
extern const var_filter_t system_vfilter_diff; |
39 |
extern const var_filter_t system_vfilter_deriv; |
40 |
extern const var_filter_t system_vfilter_nonderiv; |
41 |
|
42 |
struct SystemJacobianStruct{ |
43 |
mtx_matrix_t M; |
44 |
struct rel_relation **rels; |
45 |
struct var_variable **vars; |
46 |
int n_rels, n_vars; |
47 |
}; |
48 |
|
49 |
/** |
50 |
Create a new matrix and put into it the the derivatives for the rels |
51 |
and vars matching the filter. Return the list of rels and vars. |
52 |
|
53 |
This routine uses relman_diff2 to calculate derivatives and |
54 |
mtx_set_value to insert them into the matrix. |
55 |
|
56 |
It's not in any way optimised for fast evaluation / mtx updates etc. |
57 |
*/ |
58 |
int system_jacobian(slv_system_t sys |
59 |
, const rel_filter_t *rfilter, const var_filter_t *vfilter, const int safe |
60 |
, struct SystemJacobianStruct *sysjac |
61 |
); |
62 |
|
63 |
#endif |