Test

Aus Wiki1

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
 
(Der Versionsvergleich bezieht 14 dazwischenliegende Versionen mit ein.)
Zeile 1: Zeile 1:
<jsxgraph box="jxgbox" width="500" height="500">
<jsxgraph box="jxgbox" width="500" height="500">
-
var brd = JXG.JSXGraph.initBoard("jxgbox", {boundingbox: [-5, 8, 12, -5], axis:true});
+
        var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5,5,5,-5], axis:true});
-
   
+
 
-
// Erstelle den linken Wärmetauscher
+
        // Define the metal plate as a polygon
-
var he=brd.create('curve', [[0,0], [3,3], [6,3], [6,6], [3,6], [0,9], [-3,6], [-3,3] ]);
+
        var polygon = board.create('polygon', [[-4,-4], [-4,4], [4,4], [4,-4]], {fillcolor:'#ddd', hasInnerPoints:true});
-
</jsxgraph>
+
 
-
 
+
        // Define the initial temperature distribution as a function of x and y
-
    // Erstelle den rechten Wärmetauscher
+
        function initialTemp(x,y) {
-
    var heatexchanger2 = board.create('curve', [[8,0], [11,3], [14,3], [14,6], [11,6], [8,9], [5,6], [5,3], [8,0]], {strokeColor:'black', fillColor:'green', fillOpacity:0.5});
+
            return 20 + 10*Math.sin(Math.PI*x/4)*Math.sin(Math.PI*y/4);
-
   
+
        }
-
    // Erstelle die Trennwand
+
 
-
    var wall = board.create('line', [[6,0], [6,9]], {strokeColor:'#000', strokeWidth:4});
+
        // Define the temperature function as a function of x and y and time
-
   
+
        function temp(x,y,t) {
-
    // Erstelle die Temperaturmesspunkte
+
            var k = 1;
-
    var temp1 = board.create('glider', [2,2,heatexchanger1], {strokeColor:'#00f', fillColor:'#00f', size:10, name:'T1'});
+
            var c = 1;
-
    var temp2 = board.create('glider', [10,2,heatexchanger2], {strokeColor:'#f00', fillColor:'#f00', size:10, name:'T2'});
+
            var rho = 1;
-
   
+
            var alpha = k/(rho*c);
-
    // Berechne die Temperaturdifferenz
+
            return initialTemp(x,y) + 10*Math.exp(-alpha*Math.PI*Math.PI*t/16)*Math.sin(Math.PI*x/4)*Math.sin(Math.PI*y/4);
-
    var deltaT = board.create('segment', [temp1, temp2], {strokeColor:'#000', strokeWidth:2});
+
        }
-
    var label = board.create('text', [8, 7, function(){return 'ΔT = ' + Math.abs(temp1.Y() - temp2.Y()).toFixed(1) + ' K';}], {fontSize:18});
+
 
-
   
+
        // Create a grid of points to sample the temperature function
-
//board.update();
+
        var points = [];
-
 
+
        for (var i=-4; i<=4; i+=0.5) {
 +
            for (var j=-4; j<=4; j+=0.5) {
 +
                points.push([i,j]);
 +
            }
 +
        }
 +
 
 +
        // Plot the temperature distribution at time t=0
 +
        var heatmap = board.create('polygon', [points, initialTemp], {colorscheme:'greyscale', minopacity:0.5});
 +
 
 +
        // Animate the temperature distribution over time
 +
        var time = 0;
 +
        var dt = 0.1;
 +
        var interval = setInterval(function() {
 +
            time += dt;
 +
            var values = [];
 +
            for (var i=0; i<points.length; i++) {
 +
values.push(temp(points[i][0], points[i][1], time));
 +
    }
 +
heatmap.updateData(values);
 +
            if (time >= 2) clearInterval(interval);
 +
        }, 100);
 +
 
 +
 
</jsxgraph>
</jsxgraph>

Aktuelle Version vom 10:28, 7. Apr. 2023

Persönliche Werkzeuge