JaRMoS  1.1
Java Reduced Model Simulations
 All Classes Namespaces Files Functions Variables Enumerator Groups Pages
AffineFunctions.java
Go to the documentation of this file.
1 package models.rbm_advec_cheatbase;
2 
6 
15 
24  private double dirichletBoundCoeffs(int i, double[] p, double t) {
25  // double Q = 3.0;
26  // double h = 1. / (Q - 1);
27  double h = 0.5;
28  double x0 = h * i;
29 
30  // Spline coefficients
31  double h3 = h * h * h;
32  double a1 = 2 / -h3;
33  double b1 = (6 * x0 - 3 * h) / h3;
34  double c1 = (6 * x0 * x0 - 6 * x0 * h) / -h3;
35  double d1 = 1 + (-2 * x0 * x0 * x0 + 3 * x0 * x0 * h) / -h3;
36  double a2 = 2 / h3;
37  double b2 = (6 * x0 + 3 * h) / -h3;
38  double c2 = (6 * x0 * x0 + 6 * x0 * h) / h3;
39  double d2 = (2 * x0 * x0 * x0 + 3 * x0 * x0 * h - h3) / -h3;
40 
41  double x = p[0];
42  double S1 = a1 * x * x * x + b1 * x * x + c1 * x + d1;
43  double S2 = a2 * x * x * x + b2 * x * x + c2 * x + d2;
44  double res = 0;
45  if ((x0 - h <= x) && (x < x0))
46  res += S1 * (1 - t);
47  if ((x0 <= x) && (x <= x0 + h))
48  res += S2 * (1 - t);
49  return res;
50  }
51 
56  public double get_SCM_LB(double[] p) {
57  double p_min = p[0];
58 
59  for (int i = 1; i < p.length; i++) {
60  if (p[i] < p_min) {
61  p_min = p[i];
62  }
63  }
64 
65  return 1.;// p_min;
66  }
67 
71  @Override
72  public int getNumOutputs() {
73  return 1;
74  }
75 
79  public int getQa() {
80  return 2;
81  }
82 
86  public int getQf() {
87  return 6;
88  }
89 
93  public int[] getQl() {
94  return new int[] { 1 };
95  }
96 
100  public int getQm() {
101  return 1;
102  }
103 
107  @Override
108  public int getQu0() {
109  return 3;
110  }
111 
115  @Override
116  public boolean isTimeDependentA() {
117  return true;
118  }
119 
123  @Override
124  public boolean isTimeDependentL() {
125  return false;
126  }
127 
131  @Override
132  public boolean isTimeDependentM() {
133  return false;
134  }
135 
139  @Override
140  public double thetaQa(int i, double[] p, double t) {
141  if ((i < 0) || (i > getQa() - 1)) {
142  throw new RuntimeException("Input parameter is invalid in thetaQa()," + " i = " + i + " but getQa() = "
143  + getQa());
144  }
145  return p[i + 1] * (1 - t);
146  }
147 
151  @Override
152  public double thetaQf(int i, double[] p, double t) {
153  if ((i < 0) || (i > getQf() - 1)) {
154  throw new RuntimeException("Input parameter is invalid in evaluateF()," + " i = " + i
155  + " but get_n_F_functions() = " + getQf());
156  }
157 
158  // flux_mat entspricht Theta_a
159  // Udir sind identisch mit den Theta_u0 (zu finden in
160  // my_dirichlet_values_coefficients)
161  //
162  // -------------------------------------------------
163  // Q_v = length(flux_mat);
164  // Udir = model.dirichlet_values_ptr([],model);
165  // Q_Udir = length(Udir);
166  // bdir_E_conv = zeros(Q_Udir * Q_v,1);
167  // for q1 = 1:Q_Udir
168  // for q2 = 1:Q_v
169  // bdir_E_conv((q1-1)*Q_v+ q2) = Udir(q1)*flux_mat(q2);
170  // end;
171  // end;
172  // ---------------------------------------------
173  //
174  // bdir_E_conv liefert dann die endg�ltigen Theta_f
175 
176  int didx = (int) Math.floor(i / getQa());
177  int Qaidx = i - getQa() * didx;
178  return thetaQa(Qaidx, p, t) * dirichletBoundCoeffs(didx, p, t);
179  }
180 
184  @Override
185  public double thetaQl(int k, int i, double[] p, double t) {
186  if ((k < 0) || (k > getQl().length - 1)) {
187  throw new RuntimeException("Input parameter is invalid in evaluateL()," + " k = " + k
188  + " but get_n_outputs() = " + getQl());
189  }
190 
191  if ((i < 0) || (i > getQl()[i] - 1)) {
192  throw new RuntimeException("Input parameter is invalid in evaluateL()," + " q_l = " + i
193  + " but get_Q_l(i) = " + getQl()[i]);
194  }
195 
196  return 1;
197  }
198 
202  @Override
203  public double thetaQm(int i, double[] p, double t) {
204  return 1.;
205  }
206 
210  @Override
211  public double thetaQu0(int i, double[] p) {
212  return dirichletBoundCoeffs(i, p, 0);
213  }
214 }
double thetaQl(int k, int i, double[] p, double t)
Interface for AffineFunctions in unsteady rb systems.
Definition: ITransient.java:12
double thetaQf(int i, double[] p, double t)
double thetaQa(int i, double[] p, double t)
Base interface for any affine functions used as an externally loaded class.
Interface for affinely decomposed initial value conditions.
double thetaQm(int i, double[] p, double t)
Affine coefficient functions for time-dependent advection/diffusion problem.