码迷,mamicode.com
首页 > 其他好文 > 详细

MATLAB求解浸润角

时间:2019-01-06 14:24:06      阅读:196      评论:0      收藏:0      [点我收藏+]

标签:tin   角度   提取   circle   let   density   ima   markers   mat   

1、概述

  通过后处理软件获得流场数据的密度云图,做出附着于壁面上液滴或气泡在接触点上的切线,测量可以获得浸润角度,手工做切线存在较大的自由度,所得的角度往往并不精确,可以考虑用圆拟合液滴或者气泡,通过拟合出的圆半径及圆心位置,则可以精确的计算出相应的角度,相比做切向的方法,准确度有较大的提升,但是如果还是通过手工来找准这个拟合圆,则数据准确性也受影响,可以考虑采用程序,通过图像处理的方式获取相应的信息,下面是大致的实现思路:

  • 从数据文件中获取流场数据
  • 从密度云图图像提取相界面处密度等值线
  • 通过等值线散点拟合圆,获取圆数据
  • 求解浸润角

2、求解效果

下面是一个算例的求解效果图

技术分享图片

技术分享图片

 

3、代码实现

clc;clear;
close all;

% load color data
load mycolor.mat;

% extract data
file_info = dir(‘*.plt‘);
tempB = file_info.name( isstrprop( file_info.name, ‘digit‘ ) );
num = str2double( tempB );

% file name
filename = strcat( ‘result‘, num2str(num), ‘.plt‘ );
[var,var_name,var_num] = tecplot2mat_2D(filename);

% load variables
for j = 1:var_num
    eval([var_name{1,j},‘=var(:,:,j)‘‘;‘]);
end

% figure 1
figure(‘units‘,‘centimeters‘,‘position‘,[32 18 18 6])
hold on
axis equal
box on
axis off
ax = gca;

pcolor( X, Y, Density );
[ C, h ] = contour( X, Y, Density, [ 1.0 ] , ‘k-‘, ‘linewidth‘, 2 );
shading interp

caxis( [ 0.5, 7 ] )
colormap(mycolor);
colorbar

% setup the axis
ax.LineWidth = 1.5;
ax.FontSize = 12;
ax.FontName = ‘Times New Roman‘;

% delete white space
set(gca,‘looseinset‘,get(gca,‘tightinset‘))
set(gca,‘looseinset‘,[0 0 0 0])

% points for polyfit circle
index = C(1,:) > min(min(X)) & C(1,:) < max(max(X));
C = C(:,index);
index = C(2,:) > min(min(Y)) & C(2,:) < max(max(Y));
C = C(:,index);
% plot( C(1,:), C(2,:), ‘b.‘, ‘markersize‘, 7 )

% polyfit circle
[ xc, yc, R, a ] = circfit( C(1,:), C(2,:) );
theta = 0:0.1:2*pi;
Circle1 = xc+R*cos(theta);
Circle2 = yc+R*sin(theta);

plot( xc, yc, ‘k.‘, ‘markersize‘, 15 );
plot( Circle1, Circle2, ‘m:‘, ‘linewidth‘, 2 );

% save picture
picname = strcat( ‘./Diameter_‘, num2str( num ), ‘.tiff‘);
print( gcf, ‘-dtiff‘, ‘-r150‘, picname );

% contact angle
if yc >= R
    angle = 0;
else
    angle = 90 - asin( yc / R ) * 180 / pi;
end

fprintf( ‘contact angle = % 10.5fбу \n‘, angle );

  

 

MATLAB求解浸润角

标签:tin   角度   提取   circle   let   density   ima   markers   mat   

原文地址:https://www.cnblogs.com/tonyturtle/p/10228713.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!