test: added large scale test
This commit is contained in:
parent
957f73bb83
commit
4ba02e30de
45
julia/tests/cpp_bench/BTCS_1024_1000_100.cpp
Normal file
45
julia/tests/cpp_bench/BTCS_1024_1000_100.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
#include <Eigen/Eigen>
|
||||
#include <tug/Simulation.hpp>
|
||||
|
||||
using namespace Eigen;
|
||||
using namespace tug;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// **** GRID ****
|
||||
int rows = 1024;
|
||||
int cols = 1000;
|
||||
Grid64 grid(rows, cols);
|
||||
|
||||
MatrixXd concentrations = MatrixXd::Constant(rows, cols, 0.5);
|
||||
concentrations(10, 10) = 15000;
|
||||
concentrations(1014, 990) = 7500;
|
||||
concentrations(10, 990) = 7500;
|
||||
concentrations(1014, 10) = 7500;
|
||||
grid.setConcentrations(concentrations);
|
||||
|
||||
MatrixXd alphax = MatrixXd::Constant(rows, cols, 1.25);
|
||||
MatrixXd alphay = MatrixXd::Constant(rows, cols, 1.1);
|
||||
alphax.block(0, 0, 100, cols) = MatrixXd::Constant(100, cols, 0.5);
|
||||
alphax.block(100, 0, 100, cols) = MatrixXd::Constant(100, cols, 0.8);
|
||||
alphay.block(0, 0, rows, 200) = MatrixXd::Constant(rows, 200, 0.6);
|
||||
alphay.block(0, 200, rows, 200) = MatrixXd::Constant(rows, 200, 0.9);
|
||||
grid.setAlpha(alphax, alphay);
|
||||
|
||||
// **** BOUNDARY ****
|
||||
Boundary bc = Boundary(grid);
|
||||
bc.setBoundarySideClosed(BC_SIDE_LEFT);
|
||||
bc.setBoundarySideClosed(BC_SIDE_RIGHT);
|
||||
bc.setBoundarySideClosed(BC_SIDE_TOP);
|
||||
bc.setBoundarySideClosed(BC_SIDE_BOTTOM);
|
||||
|
||||
// **** SIMULATION ****
|
||||
Simulation simulation = Simulation(grid, bc);
|
||||
simulation.setTimestep(0.01);
|
||||
simulation.setIterations(100);
|
||||
simulation.setOutputCSV(CSV_OUTPUT_VERBOSE);
|
||||
simulation.setOutputConsole(CONSOLE_OUTPUT_OFF);
|
||||
|
||||
// **** RUN SIMULATION ****
|
||||
simulation.run();
|
||||
}
|
||||
@ -37,7 +37,7 @@ int main(int argc, char *argv[])
|
||||
// **** SIMULATION ****
|
||||
Simulation simulation = Simulation(grid, bc);
|
||||
simulation.setTimestep(0.2);
|
||||
simulation.setIterations(100);
|
||||
simulation.setIterations(750);
|
||||
simulation.setOutputCSV(CSV_OUTPUT_VERBOSE);
|
||||
simulation.setOutputConsole(CONSOLE_OUTPUT_OFF);
|
||||
|
||||
41
julia/tests/julia_bench/BTCS_1024_1000_100.jl
Normal file
41
julia/tests/julia_bench/BTCS_1024_1000_100.jl
Normal file
@ -0,0 +1,41 @@
|
||||
include("../../tug/Simulation.jl")
|
||||
|
||||
function main()
|
||||
# **** GRID ****
|
||||
rows::Int = 1024
|
||||
cols::Int = 1000
|
||||
|
||||
alphaX = fill(1.25, rows, cols)
|
||||
alphaY = fill(1.1, rows, cols)
|
||||
alphaX[1:100, :] .= 0.5
|
||||
alphaX[101:200, :] .= 0.8
|
||||
alphaY[:, 1:200] .= 0.6
|
||||
alphaY[:, 201:400] .= 0.9
|
||||
grid::Grid = Grid{Float64}(rows, cols, alphaX, alphaY)
|
||||
|
||||
concentrations = fill(0.5, rows, cols)
|
||||
concentrations[11, 11] = 15000
|
||||
concentrations[1015, 991] = 7500
|
||||
concentrations[11, 991] = 7500
|
||||
concentrations[1015, 11] = 7500
|
||||
setConcentrations!(grid, concentrations)
|
||||
|
||||
# **** BOUNDARY ****
|
||||
bc::Boundary = Boundary(grid)
|
||||
setBoundarySideClosed!(bc, LEFT)
|
||||
setBoundarySideClosed!(bc, RIGHT)
|
||||
setBoundarySideClosed!(bc, TOP)
|
||||
setBoundarySideClosed!(bc, BOTTOM)
|
||||
|
||||
# **** SIMULATION ****
|
||||
simulation::Simulation = Simulation(grid, bc)
|
||||
simulation = setTimestep(simulation, 0.01)
|
||||
simulation = setIterations(simulation, 100)
|
||||
simulation = setOutputConsole(simulation, CONSOLE_OUTPUT_OFF)
|
||||
simulation = setOutputCSV(simulation, CSV_OUPUT_VERBOSE)
|
||||
|
||||
# **** RUN SIMULATION ****
|
||||
run(simulation)
|
||||
end
|
||||
|
||||
main()
|
||||
@ -31,7 +31,7 @@ function main()
|
||||
# **** SIMULATION ****
|
||||
simulation::Simulation = Simulation(grid, bc)
|
||||
simulation = setTimestep(simulation, 0.2)
|
||||
simulation = setIterations(simulation, 100)
|
||||
simulation = setIterations(simulation, 750)
|
||||
simulation = setOutputConsole(simulation, CONSOLE_OUTPUT_OFF)
|
||||
simulation = setOutputCSV(simulation, CSV_OUPUT_VERBOSE)
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
import os
|
||||
import subprocess
|
||||
import argparse
|
||||
from compare_csv import compare_csv_files
|
||||
import os
|
||||
import statistics
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
from compare_csv import compare_csv_files
|
||||
|
||||
# ANSI color codes
|
||||
RED = '\033[0;31m'
|
||||
GREEN = '\033[0;32m'
|
||||
@ -38,12 +40,19 @@ def format_difference(diff):
|
||||
return '0'.rjust(9)
|
||||
|
||||
def run_benchmark(command, runs):
|
||||
total_time = 0
|
||||
times = []
|
||||
for _ in range(runs):
|
||||
start_time = time.time()
|
||||
start_time = time.perf_counter()
|
||||
subprocess.run(command)
|
||||
total_time += time.time() - start_time
|
||||
return total_time / runs
|
||||
elapsed = time.perf_counter() - start_time
|
||||
times.append(elapsed)
|
||||
|
||||
avg_time = sum(times) / len(times)
|
||||
min_time = min(times)
|
||||
max_time = max(times)
|
||||
std_dev = statistics.stdev(times) if len(times) > 1 else 0
|
||||
|
||||
return avg_time, min_time, max_time, std_dev
|
||||
|
||||
def main(tolerance, runs, silent, no_clean):
|
||||
BENCHMARK_DIR = "./cpp_bench"
|
||||
@ -96,8 +105,8 @@ def main(tolerance, runs, silent, no_clean):
|
||||
if os.path.exists(f"./{name}.csv"):
|
||||
are_equal, _, _, _, max_diff = compare_csv_files(f"./{name}.csv", f"{OUTPUT_DIR}/{csv_file}", tolerance)
|
||||
formatted_diff = format_difference(max_diff)
|
||||
cpp_time = '{:.4f}s'.format(cpp_times[name]).rjust(8)
|
||||
julia_time = '{:.4f}s'.format(julia_times[name]).rjust(8)
|
||||
cpp_time = '{:.4f}s'.format(cpp_times[name][0]).rjust(8)
|
||||
julia_time = '{:.4f}s'.format(julia_times[name][0]).rjust(8)
|
||||
result = f"{padded_name}: {'Success' if are_equal else 'Failure'} (Max Diff: {formatted_diff}, C++: {cpp_time}, Julia: {julia_time})"
|
||||
result_color = GREEN if are_equal else RED
|
||||
results_dict[name] = f"{result_color}{result}{NC}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user