Software: FEM - Tutorial - Magnetfeld - Kennfeld-Export als C-Code: Unterschied zwischen den Versionen

Aus OptiYummy
Zur Navigation springenZur Suche springen
KKeine Bearbeitungszusammenfassung
KKeine Bearbeitungszusammenfassung
Zeile 1: Zeile 1:
[[Software:_FEM_-_Tutorial_-_Magnetfeld|&uarr;]] <div align="center"> [[Software:_FEM_-_Tutorial_-_Magnetfeld_-_Probabilistik_-_Kennfeld-Identifikation|&larr;]] [[Software:_FEM_-_Tutorial_-_Magnetfeld_-_Kennfeld-Import_in_Systemmodelle|&rarr;]] </div>
[[Software:_FEM_-_Tutorial_-_Magnetfeld|&uarr;]] <div align="center"> [[Software:_FEM_-_Tutorial_-_Magnetfeld_-_Probabilistik_-_Kennfeld-Identifikation|&larr;]] [[Software:_FEM_-_Tutorial_-_Magnetfeld_-_Kennfeld-Import_in_Systemmodelle|&rarr;]] </div>
<div align="center">''' Kennfeld-Export als C-Code '''</div>
<div align="center">''' Kennfeld-Export als C-Code '''</div>
Unabhängig davon, nach welchem Verfahren die Antwortflächen des Modells approximiert wurden, kann man die identifizierten mathematischen Funktionen als Programm-Code exportieren ('''''Analyse - Antwortflächen - Modell Export'''''):
* Zur Zeit kann in OptiY ein Quelltext als ''C-Code'', ''Modelica-Code'' oder als ''m-Matlab'' erzeugt werden.
* Wir speichern unser Ersatzmodell als '''C-Code''' in die Datei '''Magnet_xx.c'''. ('''xx'''=Teilnehmer-Nummer in der Lehrveranstaltung).
* Dieser Quelltext enthält unter Benutzung der gewählten Covariance-Funktion die identifizierten Gauss-Ketten für alle Kriterien/Restriktionen (im Folgenden gekürzt):
       
double Covar_F(double x1[],double x2[],double p[])
{
double Co, W;
W = 0;
for(int i = 0; i<2; i++) {
    W = W + fabs((x1[i]-x2[i])*p[i]);
}
Co = exp(-W);
return Co;
}
double F(double #i, double #s)
{
double p[2];
double x1[2];
double x2[2];
double y = 29.6033584;
p[0] = 0.0953874971;
p[1] = 0.639066599;
x1[0] = #i;
x1[1] = #s;
x2[0] = 5.01;
x2[1] = 2.03;
y = y-3.56544484*Covar_F(x1,x2,p);
x2[0] = 0.01;
x2[1] = 0.03;
y = y-234.552394*Covar_F(x1,x2,p);
x2[0] = 2.01;
x2[1] = 0.03;
y = y+232.803719*Covar_F(x1,x2,p);
    :
    :
x2[0] = 10.01;
x2[1] = 4.03;
y = y-1.36321395*Covar_F(x1,x2,p);
return y;
}
double Covar_Psi(double x1[],double x2[],double p[])
{
double Co, W;
W = 0;
for(int i = 0; i<2; i++) {
  W = W + fabs((x1[i]-x2[i])*p[i]);
}
Co = exp(-W);
return Co;
}
double Psi(double #i, double #s)
{
double p[2];
double x1[2];
double x2[2];
double y = 0.0426131121;
p[0] = 0.332335577;
p[1] = 0.640793101;
x1[0] = #i;
x1[1] = #s;
x2[0] = 5.01;
x2[1] = 2.03;
y = y+0.0020486711*Covar_Psi(x1,x2,p);
x2[0] = 0.01;
x2[1] = 0.03;
y = y-0.0457279401*Covar_Psi(x1,x2,p);
x2[0] = 2.01;
x2[1] = 0.03;
y = y+0.0346149278*Covar_Psi(x1,x2,p);
    :
    :
x2[0] = 10.01;
x2[1] = 4.03;
y = y+0.0100595855*Covar_Psi(x1,x2,p);
return y;
}





Version vom 17. September 2010, 12:52 Uhr

Kennfeld-Export als C-Code


Unabhängig davon, nach welchem Verfahren die Antwortflächen des Modells approximiert wurden, kann man die identifizierten mathematischen Funktionen als Programm-Code exportieren (Analyse - Antwortflächen - Modell Export):

  • Zur Zeit kann in OptiY ein Quelltext als C-Code, Modelica-Code oder als m-Matlab erzeugt werden.
  • Wir speichern unser Ersatzmodell als C-Code in die Datei Magnet_xx.c. (xx=Teilnehmer-Nummer in der Lehrveranstaltung).
  • Dieser Quelltext enthält unter Benutzung der gewählten Covariance-Funktion die identifizierten Gauss-Ketten für alle Kriterien/Restriktionen (im Folgenden gekürzt):
double Covar_F(double x1[],double x2[],double p[])
{
double Co, W;
W = 0;
for(int i = 0; i<2; i++) {
   W = W + fabs((x1[i]-x2[i])*p[i]);
}
Co = exp(-W);
return Co;
}
double F(double #i, double #s)
{
double p[2];
double x1[2];
double x2[2];
double y = 29.6033584;
p[0] = 0.0953874971;
p[1] = 0.639066599;
x1[0] = #i;
x1[1] = #s;
x2[0] = 5.01;
x2[1] = 2.03;
y = y-3.56544484*Covar_F(x1,x2,p);
x2[0] = 0.01;
x2[1] = 0.03;
y = y-234.552394*Covar_F(x1,x2,p);
x2[0] = 2.01;
x2[1] = 0.03;
y = y+232.803719*Covar_F(x1,x2,p);
   :
   :
x2[0] = 10.01;
x2[1] = 4.03;
y = y-1.36321395*Covar_F(x1,x2,p);
return y;
}
double Covar_Psi(double x1[],double x2[],double p[])
{
double Co, W;
W = 0;
for(int i = 0; i<2; i++) {
  W = W + fabs((x1[i]-x2[i])*p[i]);
}
Co = exp(-W);
return Co;
}
double Psi(double #i, double #s)
{
double p[2];
double x1[2];
double x2[2];
double y = 0.0426131121;
p[0] = 0.332335577;
p[1] = 0.640793101;
x1[0] = #i;
x1[1] = #s;
x2[0] = 5.01;
x2[1] = 2.03;
y = y+0.0020486711*Covar_Psi(x1,x2,p);
x2[0] = 0.01;
x2[1] = 0.03;
y = y-0.0457279401*Covar_Psi(x1,x2,p);
x2[0] = 2.01;
x2[1] = 0.03;
y = y+0.0346149278*Covar_Psi(x1,x2,p);
   :
   :
x2[0] = 10.01;
x2[1] = 4.03;
y = y+0.0100595855*Covar_Psi(x1,x2,p);
return y;
}



===>>> Hier geht es bald weiter !!!