Test

Aus Wiki1

(Unterschied zwischen Versionen)
Wechseln zu: Navigation, Suche
 
(Der Versionsvergleich bezieht 23 dazwischenliegende Versionen mit ein.)
Zeile 1: Zeile 1:
 +
<jsxgraph box="jxgbox" width="500" height="500">
 +
        var board = JXG.JSXGraph.initBoard('jxgbox', {boundingbox: [-5,5,5,-5], axis:true});
 +
 +
        // Define the metal plate as a polygon
 +
        var polygon = board.create('polygon', [[-4,-4], [-4,4], [4,4], [4,-4]], {fillcolor:'#ddd', hasInnerPoints:true});
 +
 +
        // Define the initial temperature distribution as a function of x and y
 +
        function initialTemp(x,y) {
 +
            return 20 + 10*Math.sin(Math.PI*x/4)*Math.sin(Math.PI*y/4);
 +
        }
 +
 +
        // Define the temperature function as a function of x and y and time
 +
        function temp(x,y,t) {
 +
            var k = 1;
 +
            var c = 1;
 +
            var rho = 1;
 +
            var alpha = k/(rho*c);
 +
            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);
 +
        }
 +
 +
        // Create a grid of points to sample the temperature function
 +
        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 box="jxgbox" width="500" height="500">
 
-
var board = JXG.JSXGraph.initBoard("jxgbox", {boundingbox: [-2, 8, 12, -2], axis:true});
 
-
   
 
-
// Erstelle den linken Wärmetauscher
 
-
var heatexchanger1 = board.create('curve', [[0,0], [3,3], [6,3], [6,6], [3,6], [0,9], [-3,6], [-3,3], [0,0]], {strokeColor:'#00f', fillColor:'#00f', fillOpacity:0.5});
 
-
</jsxgraph>
 
-
 
 
-
    // Erstelle den rechten Wärmetauscher
 
-
    var heatexchanger2 = board.create('curve', [[8,0], [11,3], [14,3], [14,6], [11,6], [8,9], [5,6], [5,3], [8,0]], {strokeColor:'#f00', fillColor:'#f00', fillOpacity:0.5});
 
-
   
 
-
    // Erstelle die Trennwand
 
-
    var wall = board.create('line', [[6,0], [6,9]], {strokeColor:'#000', strokeWidth:4});
 
-
   
 
-
    // Erstelle die Temperaturmesspunkte
 
-
    var temp1 = board.create('glider', [2,2,heatexchanger1], {strokeColor:'#00f', fillColor:'#00f', size:10, name:'T1'});
 
-
    var temp2 = board.create('glider', [10,2,heatexchanger2], {strokeColor:'#f00', fillColor:'#f00', size:10, name:'T2'});
 
-
   
 
-
    // Berechne die Temperaturdifferenz
 
-
    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});
 
-
   
 
-
//board.update();
 
-
 
 
</jsxgraph>
</jsxgraph>

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

Persönliche Werkzeuge