Compare commits
2 Commits
3ed8093481
...
fix
| Author | SHA1 | Date | |
|---|---|---|---|
| e06d350fd3 | |||
| 409b3ecd97 |
44
Error_folder/combine_ansys.py
Normal file
44
Error_folder/combine_ansys.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import re
|
||||
|
||||
def parse_temp_file(temp_file):
|
||||
node_temps = {}
|
||||
with open(temp_file, 'r') as f:
|
||||
for line in f:
|
||||
match = re.match(r'^\s*(\d+)\s+([\d.]+)\s*$', line.strip())
|
||||
if match:
|
||||
node = int(match.group(1))
|
||||
temp = float(match.group(2))
|
||||
node_temps[node] = temp
|
||||
return node_temps
|
||||
|
||||
def parse_node_file(node_file):
|
||||
node_coords = {}
|
||||
with open(node_file, 'r') as f:
|
||||
for line in f:
|
||||
match = re.match(r'^\s*(\d+)\s+([-\d.Ee]+)\s+([-\d.Ee]+)\s+([-\d.Ee]+)\s+[-\d.]+', line.strip())
|
||||
if match:
|
||||
node = int(match.group(1))
|
||||
x = float(match.group(2))
|
||||
y = float(match.group(3))
|
||||
node_coords[node] = (x, y)
|
||||
return node_coords
|
||||
|
||||
def process_files(temp_file, node_file, output_file):
|
||||
node_temps = parse_temp_file(temp_file)
|
||||
node_coords = parse_node_file(node_file)
|
||||
|
||||
with open(output_file, 'w') as f:
|
||||
for node in node_temps:
|
||||
if node in node_coords:
|
||||
x, y = node_coords[node]
|
||||
temp = node_temps[node]
|
||||
f.write(f"100 {int(x)} {int(y)} {temp}\n")
|
||||
else:
|
||||
print(f"Warning: Node {node} not found in coordinate file")
|
||||
|
||||
temp_file = "temp_data.txt"
|
||||
node_file = "node_data.txt"
|
||||
output_file = "ansys.txt"
|
||||
|
||||
process_files(temp_file, node_file, output_file)
|
||||
print(f"Output written to {output_file}")
|
||||
60
Error_folder/get_average.py
Normal file
60
Error_folder/get_average.py
Normal file
@@ -0,0 +1,60 @@
|
||||
import math
|
||||
|
||||
def read_points(filename):
|
||||
points = []
|
||||
with open(filename, 'r') as f:
|
||||
for line in f:
|
||||
parts = line.strip().split()
|
||||
if len(parts) == 4:
|
||||
try:
|
||||
x = float(parts[1])
|
||||
y = float(parts[2])
|
||||
temp = float(parts[3])
|
||||
points.append((x, y, temp))
|
||||
except ValueError:
|
||||
print(f"Warning: Skipping invalid line in {filename}: {line.strip()}")
|
||||
return points
|
||||
|
||||
def euclidean_distance(p1, p2):
|
||||
return math.sqrt((p2[0] - p1[0])**2 + (p2[1] - p1[1])**2)
|
||||
|
||||
def find_closest_points(myprog_points, ansys_points):
|
||||
differences = []
|
||||
for myprog_point in myprog_points:
|
||||
myprog_x, myprog_y, myprog_temp = myprog_point
|
||||
min_distance = float('inf')
|
||||
temp_diff = None
|
||||
closest_point = None
|
||||
# Find closest point in ansys.txt
|
||||
for ansys_point in ansys_points:
|
||||
ansys_x, ansys_y, ansys_temp = ansys_point
|
||||
distance = euclidean_distance((myprog_x, myprog_y), (ansys_x, ansys_y))
|
||||
if distance < min_distance:
|
||||
min_distance = distance
|
||||
temp_diff = abs(myprog_temp - ansys_temp)
|
||||
closest_point = ansys_point
|
||||
if temp_diff is not None:
|
||||
differences.append(temp_diff)
|
||||
print(f"Myprog point ({myprog_x}, {myprog_y}, {myprog_temp}) -> Closest Ansys point ({closest_point[0]}, {closest_point[1]}, {closest_point[2]}) -> Temp diff: {temp_diff}")
|
||||
return differences
|
||||
|
||||
def process_files(myprog_file, ansys_file):
|
||||
myprog_points = read_points(myprog_file)
|
||||
ansys_points = read_points(ansys_file)
|
||||
|
||||
if not myprog_points or not ansys_points:
|
||||
print("Error: One or both files are empty or contain no valid data.")
|
||||
return
|
||||
|
||||
differences = find_closest_points(myprog_points, ansys_points)
|
||||
|
||||
if differences:
|
||||
avg_difference = sum(differences) / len(differences)
|
||||
print(f"\nAverage temperature difference: {avg_difference}")
|
||||
else:
|
||||
print("No valid matches found between the files.")
|
||||
|
||||
myprog_file = "myprog.txt"
|
||||
ansys_file = "ansys.txt"
|
||||
|
||||
process_files(myprog_file, ansys_file)
|
||||
4
Error_folder/sanitize_i10.py
Normal file
4
Error_folder/sanitize_i10.py
Normal file
@@ -0,0 +1,4 @@
|
||||
file = open('../implicit10.txt').readlines()
|
||||
|
||||
lines = [line for line in file if line.startswith('100')]
|
||||
open('myprog.txt', 'w').write(''.join(lines))
|
||||
@@ -14,7 +14,6 @@ protected:
|
||||
public:
|
||||
Form();
|
||||
virtual double Function(double, double);
|
||||
virtual std::pair<double, double> Second_Deriative(double, double);
|
||||
virtual bool Inhere(double, double);
|
||||
virtual std::pair<double, double> missX(double);
|
||||
virtual std::pair<double, double> missY(double);
|
||||
|
||||
@@ -15,7 +15,6 @@ private:
|
||||
public:
|
||||
Rectangle(double, double, double, double, bool, int);
|
||||
double Function(double, double) override;
|
||||
std::pair<double, double> Second_Deriative(double, double) override;
|
||||
bool Inhere(double, double) override;
|
||||
std::pair<double, double> missX(double) override;
|
||||
std::pair<double, double> missY(double) override;
|
||||
@@ -30,7 +29,6 @@ private:
|
||||
public:
|
||||
Circle(double, double, double, double, bool, int);
|
||||
double Function(double, double) override;
|
||||
std::pair<double, double> Second_Deriative(double, double) override;
|
||||
bool Inhere(double, double) override;
|
||||
std::pair<double, double> missX(double) override;
|
||||
std::pair<double, double> missY(double) override;
|
||||
@@ -46,7 +44,6 @@ private:
|
||||
public:
|
||||
Arc(double, double, double, double, bool, int);
|
||||
double Function(double, double) override;
|
||||
std::pair<double, double> Second_Deriative(double, double) override;
|
||||
std::pair<double, double> missX(double) override;
|
||||
std::pair<double, double> missY(double) override;
|
||||
std::pair<double, double> size() override;
|
||||
|
||||
@@ -6,10 +6,6 @@ double Form::Function(double, double) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::pair<double, double> Form::Second_Deriative(double, double) {
|
||||
return { 0, 0 };
|
||||
}
|
||||
|
||||
std::pair<double, double> Form::size() {
|
||||
return { 0, 0 };
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ double Rectangle::Function(double _x, double _y) {
|
||||
return std::max(h_x * std::abs(_x - x), h_y * std::abs(_y - y));
|
||||
}
|
||||
|
||||
std::pair<double, double> Rectangle::Second_Deriative(double _x, double _y) {
|
||||
return { (h_x / 2) * ((_x - x) / std::abs(_x - x)), (h_y / 2) * ((_y - y) / std::abs(_y - y)) };
|
||||
}
|
||||
|
||||
bool Rectangle::Inhere(double x, double y) {
|
||||
return Function(x, y) <= EPS_RECTANGLE;
|
||||
}
|
||||
@@ -44,10 +40,6 @@ double Circle::Function(double _x, double _y) {
|
||||
return pow(h_x * (_x - x), 2) + pow(h_y * (_y - y), 2);
|
||||
}
|
||||
|
||||
std::pair<double, double> Circle::Second_Deriative(double _x, double _y) {
|
||||
return { 2 * h_x * (_x - x), 2 * h_y * (_y - y) };
|
||||
}
|
||||
|
||||
std::pair<double, double> Circle::size() {
|
||||
return { 1 / h_x, 1 / h_y };
|
||||
}
|
||||
@@ -75,19 +67,6 @@ double Arc::Function(double _x, double _y) {
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
std::pair<double, double> Arc::Second_Deriative(double _x, double _y) {
|
||||
if (_x >= x && _y >= y) {
|
||||
return { 2 * h_x * (_x - x), 2 * h_y * (_y - y) };
|
||||
}
|
||||
if (_x < x) {
|
||||
//std::cout << "_x < a\n";
|
||||
}
|
||||
if (_y < y) {
|
||||
//std::cout << "_y < b\n";
|
||||
}
|
||||
return { -1.0, -1.0 };
|
||||
}
|
||||
|
||||
std::pair<double, double> Arc::size() {
|
||||
return { 1 / h_x, 1 / h_y };
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//#define HOLE_Y 255.
|
||||
//#define HOLE_RADIUS 50.
|
||||
|
||||
#define CONDUCTIVITY 50. // Теплопроводность материала
|
||||
#define CONDUCTIVITY 100. // Теплопроводность материала
|
||||
|
||||
void visualize(std::ofstream& file, std::string filename, int time_end) {
|
||||
file << "set cbrange [" << 0 << ":" << 100 << "]" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user