summaryrefslogtreecommitdiff
path: root/src/main/Simulator/Flowsheet_05evt.c
blob: 2fa6002274807620c963c797ba89b89c48f2ad81 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* Events: Sample, Zero Crossings, Relations, Discrete Changes */
#include "Flowsheet_model.h"
#if defined(__cplusplus)
extern "C" {
#endif

/* Initializes the raw time events of the simulation using the now
   calcualted parameters. */
void Flowsheet_function_initSample(DATA *data, threadData_t *threadData)
{
  long i=0;
}

const char *Flowsheet_zeroCrossingDescription(int i, int **out_EquationIndexes)
{
  static const char *res[] = {"101325.0 >= MaterialStream3.Pbubl",
  "101325.0 >= MaterialStream3.Pdew"};
  static const int occurEqs0[] = {1,-1};
  static const int occurEqs1[] = {1,-1};
  static const int *occurEqs[] = {occurEqs0,occurEqs1};
  *out_EquationIndexes = (int*) occurEqs[i];
  return res[i];
}

/* forwarded equations */
extern void Flowsheet_eqFunction_718(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_721(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_723(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_746(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_768(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_770(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_775(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_796(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_799(DATA* data, threadData_t *threadData);
extern void Flowsheet_eqFunction_826(DATA* data, threadData_t *threadData);

int Flowsheet_function_ZeroCrossingsEquations(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH

  data->simulationInfo->callStatistics.functionZeroCrossingsEquations++;

  Flowsheet_eqFunction_718(data, threadData);

  Flowsheet_eqFunction_721(data, threadData);

  Flowsheet_eqFunction_723(data, threadData);

  Flowsheet_eqFunction_746(data, threadData);

  Flowsheet_eqFunction_768(data, threadData);

  Flowsheet_eqFunction_770(data, threadData);

  Flowsheet_eqFunction_775(data, threadData);

  Flowsheet_eqFunction_796(data, threadData);

  Flowsheet_eqFunction_799(data, threadData);

  Flowsheet_eqFunction_826(data, threadData);
  
  TRACE_POP
  return 0;
}

int Flowsheet_function_ZeroCrossings(DATA *data, threadData_t *threadData, double *gout)
{
  TRACE_PUSH
  modelica_boolean tmp438;
  modelica_boolean tmp439;
  
  data->simulationInfo->callStatistics.functionZeroCrossings++;
  
  tmp438 = GreaterEqZC(101325.0, data->localData[0]->realVars[233] /* MaterialStream3._Pbubl variable */, data->simulationInfo->storedRelations[0]);
  gout[0] = (tmp438) ? 1 : -1;
  tmp439 = GreaterEqZC(101325.0, data->localData[0]->realVars[234] /* MaterialStream3._Pdew variable */, data->simulationInfo->storedRelations[1]);
  gout[1] = (tmp439) ? 1 : -1;
  
  TRACE_POP
  return 0;
}

const char *Flowsheet_relationDescription(int i)
{
  const char *res[] = {"101325.0 >= MaterialStream3.Pbubl",
  "101325.0 >= MaterialStream3.Pdew"};
  return res[i];
}

int Flowsheet_function_updateRelations(DATA *data, threadData_t *threadData, int evalforZeroCross)
{
  TRACE_PUSH
  modelica_boolean tmp440;
  modelica_boolean tmp441;
  
  if(evalforZeroCross) {
    tmp440 = GreaterEqZC(101325.0, data->localData[0]->realVars[233] /* MaterialStream3._Pbubl variable */, data->simulationInfo->storedRelations[0]);
    data->simulationInfo->relations[0] = tmp440;
    tmp441 = GreaterEqZC(101325.0, data->localData[0]->realVars[234] /* MaterialStream3._Pdew variable */, data->simulationInfo->storedRelations[1]);
    data->simulationInfo->relations[1] = tmp441;
  } else {
    data->simulationInfo->relations[0] = (101325.0 >= data->localData[0]->realVars[233] /* MaterialStream3._Pbubl variable */);
    data->simulationInfo->relations[1] = (101325.0 >= data->localData[0]->realVars[234] /* MaterialStream3._Pdew variable */);
  }
  
  TRACE_POP
  return 0;
}

int Flowsheet_checkForDiscreteChanges(DATA *data, threadData_t *threadData)
{
  TRACE_PUSH
  int needToIterate = 0;

  infoStreamPrint(LOG_EVENTS_V, 1, "check for discrete changes at time=%.12g", data->localData[0]->timeValue);
  if (ACTIVE_STREAM(LOG_EVENTS_V)) messageClose(LOG_EVENTS_V);
  
  TRACE_POP
  return needToIterate;
}

#if defined(__cplusplus)
}
#endif