Применение технологий Java и JavaFX для разработки виртуальных лабораторий математического моделирования

Курсовой проект - Компьютеры, программирование

Другие курсовые по предмету Компьютеры, программирование

dydx;

}

public void setKvalues(float k1_1, float k1_2, float k1_3, float k2_1,float k2_2,float k2_3){.k1_1 = k1_1;.k1_2 = k1_2;.k1_3 = k1_3;.k2_1 = k2_1;.k2_2 = k2_2;.k2_3 = k2_3;

}

}

 

ПРИЛОЖЕНИЕ 2

 

Класс инициализации значений , и в виде массивов данных имеет следующий вид:

.java

package model;class coordinates {[] X=new float[1000];[] Y=new float[1000];

float[] T=new float[1000];

}

 

ПРИЛОЖЕНИЕ 3

 

Класс численного решения дифференциального уравнения, а также системы дифференциальных уравнений первого порядка методом Рунге-Кутта 4 порядка точности имеет следующий вид:

 

RungeKutta_method.java

/*

* Class RungeKutta

* requires interfaces DerivFunction and DerivnFunction

*

* Contains the methods for the Runge-Kutta procedures for solving

* single or solving sets of ordinary differential equations (ODEs)

* [draws heavily on the approach adopted in Numerical Recipes

* (C language version)

*

* A single ODE is supplied by means of an interface,

* DerivFunction

* A set of ODEs is supplied by means of an interface,

* DerivnFunction

*

* WRITTEN BY: Dr Michael Thomas Flanagan

*

* DATE: February 2002

* UPDATES: 22 June 2003, April 2004,

* 15 September 2006 (to incorporate improvements suggested by Klaus Benary [Klaus.Benary@gede.de])

* 11 April 2007, 25 April 2007, 4 July 2008, 26-31 January 2010

*

* DOCUMENTATION:

* See Michael Thomas Flanagans Java library on-line web page:

*

*

*

* Copyright (c) 2002 - 2010

*

* PERMISSION TO COPY:

* Permission to use, copy and modify this software and its documentation for

* NON-COMMERCIAL purposes is granted, without fee, provided that an acknowledgement

* to the author, Michael Thomas Flanagan at www.ee.ucl.ac.uk/~mflanaga, appears in all copies.

*

* Dr Michael Thomas Flanagan makes no representations about the suitability

* or fitness of the software for any or for a particular purpose.

* Michael Thomas Flanagan shall not be liable for any damages suffered

* as a result of using, modifying or distributing this software or its derivatives.

*

*************************************************************/model;class RungeKutta_method{float x0; float xn; float y0; float[] yy0; int nODE = 0; float step; RungeKutta_method(){

}void setInitialValueOfX(float x0){.x0 = x0;

}void setFinalValueOfX(float xn){.xn = xn;

}void setInitialValuesOfY(float[] yy0){.yy0 = yy0;.nODE = yy0.length;(this.nODE==1)this.y0 = yy0[0];

}void setStepSize(float step){.step = step;

}void fourthOrderMass(InitSystem g,coordinates XY){(Double.isNaN(this.x0))throw new IllegalArgumentException("No initial x value has been entered");(Double.isNaN(this.xn))throw new IllegalArgumentException("No final x value has been entered");(this.yy0==null)throw new IllegalArgumentException("No initial y values have been entered");(Double.isNaN(this.step))throw new IllegalArgumentException("No step size has been entered");[] k1 =new float[this.nODE];[] k2 =new float[this.nODE];[] k3 =new float[this.nODE];[] k4 =new float[this.nODE];[] y =new float[this.nODE];[] yd =new float[this.nODE];[] dydx =new float[this.nODE];x = 0.0f;ns = (this.xn - this.x0)/this.step;= (float) Math.rint(ns);nsteps = (int) ns;.nIter = nsteps;stepUsed = (this.xn - this.x0)/ns;[][] Y=new float[this.nODE][nsteps];(int i=0; i<this.nODE; i++)y[i] = this.yy0[i];.X[0]=yy0[0];.Y[0]=yy0[1];(int j=0; j<nsteps; j++){= this.x0 + j*stepUsed;= g.derivn(x, y);(int i=0; i<this.nODE; i++)k1[i] = stepUsed*dydx[i];(int i=0; i<this.nODE; i++)yd[i] = y[i] + k1[i]/2;= g.derivn(x + stepUsed/2, yd);(int i=0; i<this.nODE; i++)k2[i] = stepUsed*dydx[i];(int i=0; i<this.nODE; i++)yd[i] = y[i] + k2[i]/2;= g.derivn(x + stepUsed/2, yd);(int i=0; i<this.nODE; i++)k3[i] = stepUsed*dydx[i];(int i=0; i<this.nODE; i++)yd[i] = y[i] + k3[i];= g.derivn(x + stepUsed, yd);(int i=0; i<this.nODE; i++)k4[i] = stepUsed*dydx[i];(int i=0; i<this.nODE; i++)y[i] += k1[i]/6 + k2[i]/3 + k3[i]/3 + k4[i]/6;.X[j]=y[0];.Y[j]=y[1];.T[j]=this.x0+j*this.step;

}

}

}

 

ПРИЛОЖЕНИЕ 4

 

Главный файл апплета Main.fx модели межвидовой конкуренции с пользовательским интерфейсом:

 

Main.fx

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/model;javafx.stage.Stage;javafx.scene.Scene;javafx.scene.layout.LayoutInfo;javafx.scene.layout.Tile;javafx.scene.chart.LineChart;javafx.scene.chart.part.NumberAxis;javafx.scene.control.Label;javafx.scene.control.TextBox;javafx.scene.control.ScrollBar;javafx.scene.control.Button;javafx.scene.chart.part.Side;java.lang.*;javafx.scene.image.*;javafx.scene.layout.Flow;javafx.scene.control.CheckBox;

/**

* @author Admin

*/

//var X0= 0;numberGraf=-1;

//var numOfEquat: Integer;numOfEquat=2;stepSize=0.1;t0=0;tn=100;numSteps=1000;

//var beginValue=[X0,Y0];coordinat=coordinates{};tempX0=bind Float.valueOf(textX0.text);J=123.456789;Imagesystem=ImageView{image:Image{url:"{__DIR__}system.jpg" width: 200: 100}

}modelNAME=Label { layoutInfo: LayoutInfo { width: 300}text: " Модель межвидовая конуренция"}

//var CoordinateOfXY = LineChart. Series {};CoordinatesOfXY:LineChart. Series[]=[.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {},.Series {}

];CoordinateOfXT = LineChart. Series {name: "X(t)"};CoordinateOfYT = LineChart. Series {name: "Y(t)"};grafikXY = LineChart {: false: false: "Фазовый портрет": LayoutInfo { width: 400 height: 400}: NumberAxis {: 0: 10: "x"

}: NumberAxis {: 0: 10: "y"

}

data: CoordinatesOfXY

} //инициализация графика X от Y

var grafikXYT = LineChart {: "График": Side.RIGHT: false: LayoutInfo { width: 600 height: 200}: NumberAxis {:10: 10: 0: 100: "t"

}: NumberAxis {: 0: 10: "x y"

}: [CoordinateOfXT,CoordinateOfYT]

} //инициализация графика Y от TlabelX0=Label { width: 20 text: "Xo"}textX0=TextBox {layoutInfo: LayoutInfo {: 100} text: bind String.valueOf(valX0) columns: 10 selectOnFocus: false:true

}scrollX0 = ScrollBar { layoutInfo: LayoutInfo { width: 140 height: 15}: 0 max: 10 vertical: false value: 10 unitIncrement: 0.1 visibleAmount :0.01

}

//scrollX0.onMouseDragged

//textX0.onKeyReleasedlabelY0=Label {width: 20 text: "Yo:"}textY0=TextBox { layoutInfo: LayoutInfo { width: 100} text: bind String.valueOf(valY0) columns: 10:true

}scrollY0 = ScrollBar {layoutInfo: LayoutInfo { width: 140 height: 15}: 0 max: 10 vertical: false value: 10 unitIncrement:0.1 visibleAmount :0.01}labela1=Label {width: 20 text: "a1:"}texta1=TextBox { layoutInfo: LayoutInfo { width: 100} text: bind String.valueOf(vala1) columns: 10selectOnFocus: false:true

}scrolla1 = ScrollBar {layoutInfo: LayoutInfo { width: 140 height: 15}: 0.01 max: 1 vertical: false value: 0.1 unitIncrement:0.01 visibleAmount :0.01}labela2=Label {width: 20 text: "a2:"}texta2=TextBox {layoutInfo: LayoutInfo { width: 100} text: bind String.valueOf(vala2) columns: 10selectOnFocus: true:true

}scrolla2 = ScrollBar {layoutInfo: LayoutInfo { width: 140 height: 15}: 0.01 max: 1 vertical: false value: 0.2 unitIncrement:0.0099 visibleAmount :0.01}labelb1=Label {width: 20 text: "b1:"}textb1=TextBox {layoutInfo: LayoutInfo { width: 100} text: bind String.valueOf(valb1) columns: 10selectOnFocus: true:true

}scrollb1 = ScrollBar {layoutInfo: LayoutInfo { width: 140 height: 15}: 0.01 max: 1 vertical: false value: 0.05 unitIncrement:0.0099 visibleAmount :0.01}labelb2=Label {width: 20 text: "b2:"}textb2=TextBox {layoutInfo: LayoutInfo { width: 100} text: bind String.valueOf(valb2) columns: 10selectOnFocus: true:true

}scrollb2 = ScrollBar {layoutInfo: LayoutInfo { width: 140 height: 15}: 0.01 max: 0.15 vertical: false value: 0.1 unitIncrement:0.0014 visibleAmount :0.01}labelg1=Label {width: 20 text: "g1:"}textg1=TextBox {layoutInfo: LayoutInfo { width: 100} text: bind String.valueOf(valg1) columns: 10selectOnFocus: true:true

}scrollg1 = ScrollBar {layoutInfo: LayoutInfo { width: 140 height: 15}: 0.01 max: 1 vertical: false value: 0.03 unitIncrement:0.0099 visibleAmount :0.01}labelg2=Label {width: 20 text: "g2:"}textg2=TextBox {layoutInfo: LayoutInfo { width: 100} text: bind String.valueOf(valg2) columns: 10selectOnFocus: true:true

}scrollg2 = ScrollBar {layoutInfo: LayoutInfo { width: 140 height: 15}: 0.01 max: 0.15 vertical: false value: 0.15 unitIncrement:0.0014 v