 |
Bsoft
2.1.0
Bernard's software package
|
Go to the documentation of this file.
25 unsigned long i, n2 = num*num, n3 = num*n2;
31 mp->
llen =
new float[n2];
32 mp->
dist =
new float[n2];
33 mp->
Kl =
new float[n2];
34 mp->
Kd =
new float[n2];
35 mp->
pot =
new int[n2];
36 mp->
angle =
new float[n3];
37 mp->
Ka =
new float[n3];
39 for ( i=0; i<n2; i++ ) mp->
llen[i] = mp->
dist[i] = mp->
Kl[i] = mp->
Kd[i] = mp->
pot[i] = 0;
40 for ( i=0; i<n3; i++ ) mp->
angle[i] = mp->
Ka[i] = 0;
81 int err(0), i, j, k, l, nd, na, num(0);
93 cout <<
"Reading model parameters from " << filename << endl << endl;
113 for ( ; dct1 && dct2; dct1=dct1->
next, dct2=dct2->
next ) {
114 for ( i=0, type = typelist; type && *type != *dct1; type = type->
next, i++ ) ;
116 for ( i=0, type = typelist; type && *type != *dct2; type = type->
next, i++ ) ;
125 for ( ; dct1 && dct2 && dct3; dct1=dct1->
next, dct2=dct2->
next, dct3=dct3->
next ) {
126 for ( i=0, type = typelist; i<num && type && *type != *dct1; type = type->
next, i++ ) ;
128 for ( j=0, type = typelist; j<num && type && *type != *dct2; type = type->
next, j++ ) ;
130 for ( k=0, type = typelist; k<num && type && *type != *dct3; type = type->
next, k++ ) ;
134 for ( num=0, type = typelist; type; type = type->
next ) num++;
141 cout <<
"DEBUG model_param_read: number of component types = " << num << endl;
152 for ( nd=0; dct1 && dct2; dct1=dct1->
next, dct2=dct2->
next ) {
153 for ( i=0, type = mp->
type; i<num && type && *type != *dct1; type = type->next, i++ ) ;
154 for ( j=0, type = mp->
type; j<num && type && *type != *dct2; type = type->next, j++ ) ;
166 mp->
Kl[k] = mp->
Kl[l] = dkl->
real();
170 mp->
Kd[k] = mp->
Kd[l] = dkd->
real();
180 <<
tab << mp->
pot[k] << endl;
184 dct1 = dct2 = dct3 = NULL;
193 for ( na=0; dct1 && dct2 && dct3; dct1=dct1->
next, dct2=dct2->
next, dct3=dct3->
next ) {
194 for ( i=0, type = mp->
type; i<num && type && *type != *dct1; type = type->next, i++ ) ;
195 for ( j=0, type = mp->
type; j<num && type && *type != *dct2; type = type->next, j++ ) ;
196 for ( k=0, type = mp->
type; k<num && type && *type != *dct3; type = type->next, k++ ) ;
197 l = (i*num+j)*num + k;
198 k = (i*num+k)*num + j;
204 mp->
Ka[k] = mp->
Ka[l] = dka->
real();
208 cout << *dct1 <<
tab << *dct2 <<
tab << *dct3 <<
tab
217 cout <<
"Number of distance parameters read: " << nd << endl;
218 cout <<
"Number of angle parameters read: " << na << endl << endl;
235 int i, j, k, l, nd, na, err(0);
243 cout <<
"Writing model parameters to " << filename << endl << endl;
249 for ( i=nd=0, type1 = mp->
type; i<mp->ntype && type1; type1 = type1->
next, i++ ) {
250 for ( j=i, k=i*mp->
ntype+j, type2 = type1; j<mp->ntype && type2; type2 = type2->
next, j++, k++ )
251 if ( mp->
dist[k] > 0 ) {
268 for ( i=na=0, type1 = mp->
type; i<mp->ntype && type1; type1 = type1->
next, i++ ) {
269 for ( j=i, type2 = type1; j<mp->
ntype && type2; type2 = type2->
next, j++ )
270 for ( k=j, l=(i*mp->
ntype+j)*mp->
ntype+k, type3 = type2; k<mp->ntype && type3; type3 = type3->
next, k++, l++ )
271 if ( mp->
angle[l] > 0 ) {
289 if ( err < 0 )
return err;
292 cout <<
"Number of distance parameters written: " << nd << endl;
293 cout <<
"Number of angle parameters written: " << na << endl << endl;
309 cout <<
"Model parameters:" << endl << endl;
311 cout <<
"Link parameter matrix:" << endl << endl;
314 for ( type = mp->
type; type; type = type->
next )
315 cout <<
tab << *type;
317 for ( i=k=0, type = mp->
type; i<mp->ntype && type; type = type->
next, i++ ) {
319 for ( j=0; j<mp->
ntype; j++, k++ ) {
320 cout <<
tab << mp->
llen[k] <<
"," << mp->
Kl[k];
326 cout <<
"Distance parameter matrix:" << endl << endl;
329 for ( type = mp->
type; type; type = type->
next )
330 cout <<
tab << *type;
332 for ( i=k=0, type = mp->
type; i<mp->ntype && type; type = type->
next, i++ ) {
334 for ( j=0; j<mp->
ntype; j++, k++ ) {
335 cout <<
tab << mp->
dist[k] <<
"," << mp->
Kd[k] <<
"(" << mp->
pot[k] <<
")";
341 cout <<
"Angle parameter matrix:" << endl << endl;
343 for ( i=l=0, type1 = mp->
type; i<mp->ntype && type1; type1 = type1->
next, i++ ) {
344 cout <<
"Central component type: " << *type1 << endl <<
"Type";
345 for ( type = mp->
type; type; type = type->
next )
346 cout <<
tab << *type;
348 for ( j=0, type = mp->
type; j<mp->ntype && type; type = type->
next, j++ ) {
350 for ( k=0; k<mp->
ntype; k++, l++ ) {
390 cout <<
"Generating a distance parameter matrix from " <<
model->
id << endl << endl;
392 for ( num=0, m =
model; m; m = m->
next ) {
393 for ( ct = m->
type; ct; ct = ct->
next ) {
394 for ( type = list; type && *type != ct->
id; type = type->
next ) ;
404 cout <<
"Number of component types found: " << num << endl << endl;
412 cout <<
"DEBUG model_param_generate: Setting up link parameters" << endl;
414 for ( link = m->
link; link; link = link->
next ) {
415 comp1 = link->
comp[0];
416 comp2 = link->
comp[1];
419 if ( mp->
llen[i] < 0.1 || mp->
llen[i] > d ) {
431 cout <<
"DEBUG model_param_generate: Setting up distance parameters" << endl;
433 for ( comp1 = m->
comp; comp1->
next; comp1 = comp1->
next ) {
434 for ( comp2 = comp1->
next; comp2; comp2 = comp2->
next ) {
437 if ( mp->
dist[i] < 0.1 || mp->
dist[i] > d ) {
452 cout <<
"DEBUG model_param_generate: Setting up angle parameters" << endl;
454 for ( comp1 = m->
comp; comp1->
next; comp1 = comp1->
next ) {
456 comp2 = comp1->
link[j];
457 v1 = comp2->
loc - comp1->
loc;
458 for ( k=0; k<j && comp1->
link[k]; k++ ) {
459 comp3 = comp1->
link[k];
460 v2 = comp3->
loc - comp1->
loc;
463 if ( mp->
angle[i] < 0.001 || mp->
angle[i] > a ) {
499 cout <<
"Setting type indices for a distance parameter matrix" << endl << endl;
503 for ( i=0, cts = mp->
type; cts && *cts != ct->
id; cts = cts->
next, i++ ) ;
504 if ( cts ) ct->
index = i;
507 cout <<
"DEBUG model_param_set_type_indices: " << *cts <<
" " << ct->
id <<
" " << ct->
index << endl;
int model_param_kill(Bmodparam *mp)
Deallocates memory for a model parameter structure.
int string_kill(Bstring *list)
Kills a string linked list.
int item_index(Bstar_block *block, const char *tag)
Gets the STAR item associated with a tag in a STAR data block.
char * add_item(char **list, unsigned long size)
Adds an item to a linked list.
Bmodparam * model_param_read(Bstring &filename)
Reads a model parameter file.
#define ANGLEMAT_COMPTYPE2
int loop_set_identifier(Bstar_block *block, int loop, int n,...)
Assigns a loop identification number to items.
#define ANGLEMAT_COMPTYPE1
double distance(const Vector3 &v)
int item_put_float(Bstar_block *block, const char *tag, float value, const char *format)
Writes a floating point value into a data item associated with a specific data block and tag in a STA...
int model_param_display(Bmodparam *mp)
Displays a model parameter in the shell.
int model_param_write(Bstring &filename, Bmodparam *mp)
Writes a model parameter file.
Bstring command_line_time()
Returns the command line and time in a string.
int item_put_integer(Bstar_block *block, const char *tag, int value, const char *format)
Writes a integer into a data item associated with a specific data block and tag in a STAR data base.
int write_star(const char *filename, Bstar *star)
Writes a STAR data base to one or more STAR format files.
#define DISTMAT_COMPTYPE2
Bmodparam * model_param_generate(Bmodel *model)
Generates a model parameter file from a model.
int model_kill(Bmodel *model)
Deallocates all memory in the list.
#define ANGLEMAT_COMPTYPE3
Header file for general utilities.
ostream & tab(ostream &out)
int read_star(const char *filename, Bstar *star)
Reads paramaters and data into a STAR data base from a list of files.
int kill_star(Bstar *star)
Destroys a STAR data base.
double angle(Vector3< T2 > &v)
Header file for generalized linked list functions.
int model_param_set_type_indices(Bmodel *model, Bmodparam *mp)
Sets the component type indices from the model parameters.
Bstar_item * item_find(Bstar_block *block, const char *tag)
Gets the STAR item associated with a tag in a STAR data block.
A header file for STAR format files.
int item_put_string(Bstar_block *block, const char *tag, char *string)
Writes a string into a data item associated with a specific data block and tag in a STAR data base.
#define DISTMAT_COMPTYPE1
Bcomponent * link[MAXLINK]
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Bstar * init_star()
Creates a STAR data base.
Header to read and write model dynamics parameters in STAR format.
Bmodparam * model_param_init(int num)
Initializes a model parameter structure and allocates memory.