diff --git a/doc/matlab_macro_rugo/data_precalcul_nat.mat b/doc/matlab_macro_rugo/data_precalcul_nat.mat new file mode 100644 index 0000000000000000000000000000000000000000..1ef3449b26ff6916bb0d7644387664902b40cb79 Binary files /dev/null and b/doc/matlab_macro_rugo/data_precalcul_nat.mat differ diff --git a/doc/matlab_macro_rugo/find_Q_nat.m b/doc/matlab_macro_rugo/find_Q_nat.m new file mode 100644 index 0000000000000000000000000000000000000000..57eb3f7391c37f5e5aecdd723523067ea7c831e6 --- /dev/null +++ b/doc/matlab_macro_rugo/find_Q_nat.m @@ -0,0 +1,115 @@ +function [res]=find_Q_nat(cote_bas,ks,D,h,Cd0,S,L,pf,C,Q,sigma) +fprintf('*************************************\n') +fprintf('find_Q_nat Q=%f\n',Q) + +maxfun=5000; +maxiter=5000; +tolfun=1e-16; +tolx=1e-16; +g=9.81; +kappa=0.41; +U0=Q./L./pf; + +Fr=U0./(9.81*pf).^0.5; +Frg=Fr/(1-C^0.5); + + +if ks==0;ks=1e-34;end + + +coeff_contraction=0.4*Cd0+0.7; + +%if Cd0==2 + % fFr=(min(2.5,Frg^(-4/3)));% +%else + fFr=(min(coeff_contraction./(1-(Frg.^2)/4),Frg.^(-2/3))).^2; +%end + +if Frg>1.5 + fFr=(Frg.^(-2/3)).^2; +end + + + +alpha=1-(1.*C).^0.5-1/2*sigma.*C; +Cd=Cd0.*(1+1./(pf./D).^2).*fFr; + +%Cd=Cd0.*(0.8-2*C).*(1+0.4./(pf./D).^2).*fFr; +R=(1-sigma*C);%.*(1-C.^0.5).^2; + + +if pf/h>1.1; %fFr=1; + + choixturb=1; + htilde=h./D; + hstar=pf./h; + Rh=h.*(hstar-1); + ustar=(g.*S.*Rh).^0.5; + fprintf('ustar=%f\n',ustar) + + Cd1=Cd0.*(1+0.4./(pf./D).^2).*fFr; + CdCh=Cd1.*C.*htilde; + fprintf('CdCh=%f\n',CdCh) + + Cf=2./(5.1.*log10(h./ks)+6).^2; + + U0b=(2*g.*S.*R./(Cd1.*C.*h./D+Cf.*R).*h).^0.5; + fprintf('U0b=%f\n',U0b) + + % U0=(2*g.*S.*D.*R./(Cd1.*C)).^0.5; + + [P]=fminbnd(@(alphai) resolve_alpha(alphai,CdCh,R,U0b,hstar,h,C,D,Cd1,ustar,choixturb),1e-5*h,h,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)); + + alpha=P(1); + fprintf('alpha=%f\n',alpha) + + beta2=h.*CdCh./alpha./R; + beta=(beta2).^0.5; + a1=beta*(hstar-1)/(cosh(beta)); + c=1; + + UhU0=(a1*sinh(beta)+c)^0.5; + Uh=UhU0*U0b; + fprintf('Uh=%f\n',Uh) + + dhp=1-1/kappa*alpha./h.*Uh./ustar; + z0hp=(1-dhp).*exp(-1*(kappa*Uh./ustar)); + + qsup=ustar./kappa.*h.*((hstar-dhp).*(log((hstar-dhp)./z0hp) - 1)-((1-dhp).*(log((1-dhp)./z0hp) - 1))); + fprintf('qsup=%f\n',qsup) + %calcul intégrale dans la canopée---- + dzinf=0.01; + Zinf=(0:dzinf:1); + Uinf=U0b .*(beta.*Rh./h.*sinh(beta*Zinf)./cosh(beta)+1).^0.5; + Ub=zeros(size(Uinf)); + Ub(1:end-1)=Uinf(2:end); + qinf=sum((Uinf(1:end-1)+Ub(1:end-1))/2*dzinf.*h); + fprintf('qinf=%f\n',qinf) + qtot=qinf+qsup; + + PI=0; + delta=1; + + Umoy=qtot./pf; + res=abs(U0-Umoy); + +else + + hstar=pf/D; + Re=U0.*pf/1e-6; + + if ks==0 + Cf=0.3164/4.*Re.^(-0.25); + else + Cf=2/(5.1*log10(pf/ks-1)+6)^2; + end + + N= (alpha.*Cf)./(pf./D.*Cd.*C); + + res=abs(U0-(2*g.*S.*D.*(R)./(Cd.*C.*(1+N))).^0.5); + + + +end + +fprintf('res=%f\n',res) diff --git a/doc/matlab_macro_rugo/resolve_alpha.m b/doc/matlab_macro_rugo/resolve_alpha.m new file mode 100644 index 0000000000000000000000000000000000000000..d78606a91ac85451ff4fcd8a199e89ecc99e7562 --- /dev/null +++ b/doc/matlab_macro_rugo/resolve_alpha.m @@ -0,0 +1,47 @@ +function [res]= resolve_alpha(alpha,CdCh,R,U0,hstar,hp,C,D,Cd,ustar,choixturb) + if 1==1 + fprintf('resolve_alpha(alpha=%f,CdCh=%f,R=%f,U0=%f,hstar=%f,hp=%f,C=%f,D=%f,Cd=%f,ustar=%f)\n',alpha,CdCh,R,U0,hstar,hp,C,D,Cd,ustar) + end + +g=9.81; +kappa=0.41; + +L=D*(1/C^0.5-1); +beta2=hp.*CdCh./alpha./R; + +beta=(beta2).^0.5; +a1=beta*(hstar-1)/(cosh(beta)); + +c=1; +UhU0=(a1*sinh(beta)+c)^0.5; +Uh=UhU0*U0; + +%choix du modele de turbulence + +switch choixturb + + case 1 + + L1=min(L,0.15*hp); + %L1=L;%0.15*hp; + +% case 2 +% +% L1=L.*hp./(1/0.41*L+hp); +% +% case 3 +% L1=0.15*min(hp,D./C./Cd);%; +% case 4 +% if L/hp<1 +% L1=(1-L/hp).*L; +% if L1<0.05*hp && L/hp>0.8;L1=0.05*hp;end +% else +% L1=0.41*((1-hp./L))*hp; +% if L1<0.05*hp && L/hp<1.2;L1=0.05*hp;end +% end +end + + +res=abs(alpha*Uh-L1*ustar); +fprintf('resolve_alpha res=%f\n',res) +end \ No newline at end of file diff --git a/doc/matlab_macro_rugo/warning_4a1_1.fig b/doc/matlab_macro_rugo/warning_4a1_1.fig new file mode 100644 index 0000000000000000000000000000000000000000..379e63bc1434dd009798f5a9050ef0ae5656d5ad Binary files /dev/null and b/doc/matlab_macro_rugo/warning_4a1_1.fig differ diff --git a/doc/matlab_macro_rugo/warning_4a1_1.m b/doc/matlab_macro_rugo/warning_4a1_1.m new file mode 100644 index 0000000000000000000000000000000000000000..8058dc8856aecb05762489c00b484dc14a6555a2 --- /dev/null +++ b/doc/matlab_macro_rugo/warning_4a1_1.m @@ -0,0 +1,81 @@ +function varargout = warning_4a1_1(varargin) +% WARNING_4A1_1 MATLAB code for warning_4a1_1.fig +% WARNING_4A1_1, by itself, creates a new WARNING_4A1_1 or raises the existing +% singleton*. +% +% H = WARNING_4A1_1 returns the handle to a new WARNING_4A1_1 or the handle to +% the existing singleton*. +% +% WARNING_4A1_1('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in WARNING_4A1_1.M with the given input arguments. +% +% WARNING_4A1_1('Property','Value',...) creates a new WARNING_4A1_1 or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before warning_4a1_1_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to warning_4a1_1_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help warning_4a1_1 + +% Last Modified by GUIDE v2.5 08-Oct-2014 13:48:09 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @warning_4a1_1_OpeningFcn, ... + 'gui_OutputFcn', @warning_4a1_1_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before warning_4a1_1 is made visible. +function warning_4a1_1_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to warning_4a1_1 (see VARARGIN) + +% Choose default command line output for warning_4a1_1 +handles.output = hObject; + +% Update handles structure +guidata(hObject, handles); + +% UIWAIT makes warning_4a1_1 wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + +% --- Outputs from this function are returned to the command line. +function varargout = warning_4a1_1_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +close diff --git a/doc/matlab_macro_rugo/window_4a1.fig b/doc/matlab_macro_rugo/window_4a1.fig new file mode 100644 index 0000000000000000000000000000000000000000..b60b5f6315d11fe6de64ed54fda307ee070f53d2 Binary files /dev/null and b/doc/matlab_macro_rugo/window_4a1.fig differ diff --git a/doc/matlab_macro_rugo/window_4a1.m b/doc/matlab_macro_rugo/window_4a1.m new file mode 100644 index 0000000000000000000000000000000000000000..4cb4c6d0812ebf4975c736bd4d5d91c04369dd21 --- /dev/null +++ b/doc/matlab_macro_rugo/window_4a1.m @@ -0,0 +1,1028 @@ +function varargout = window_4a1(varargin) +% WINDOW_4A1 MATLAB code for window_4a1.fig +% WINDOW_4A1, by itself, creates a new WINDOW_4A1 or raises the existing +% singleton*. +% +% H = WINDOW_4A1 returns the handle to a new WINDOW_4A1 or the handle to +% the existing singleton*. +% +% WINDOW_4A1('CALLBACK',hObject,eventData,handles,...) calls the local +% function named CALLBACK in WINDOW_4A1.M with the given input arguments. +% +% WINDOW_4A1('Property','Value',...) creates a new WINDOW_4A1 or raises the +% existing singleton*. Starting from the left, property value pairs are +% applied to the GUI before window_4a1_OpeningFcn gets called. An +% unrecognized property name or invalid value makes property application +% stop. All inputs are passed to window_4a1_OpeningFcn via varargin. +% +% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one +% instance to run (singleton)". +% +% See also: GUIDE, GUIDATA, GUIHANDLES + +% Edit the above text to modify the response to help window_4a1 + +% Last Modified by GUIDE v2.5 04-Nov-2016 14:59:17 + +% Begin initialization code - DO NOT EDIT +gui_Singleton = 1; +gui_State = struct('gui_Name', mfilename, ... + 'gui_Singleton', gui_Singleton, ... + 'gui_OpeningFcn', @window_4a1_OpeningFcn, ... + 'gui_OutputFcn', @window_4a1_OutputFcn, ... + 'gui_LayoutFcn', [] , ... + 'gui_Callback', []); +if nargin && ischar(varargin{1}) + gui_State.gui_Callback = str2func(varargin{1}); +end + +if nargout + [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); +else + gui_mainfcn(gui_State, varargin{:}); +end +% End initialization code - DO NOT EDIT + + +% --- Executes just before window_4a1 is made visible. +function window_4a1_OpeningFcn(hObject, eventdata, handles, varargin) +% This function has no output args, see OutputFcn. +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) +% varargin command line arguments to window_4a1 (see VARARGIN) + +% Choose default command line output for window_4a1 +handles.output = hObject; + +% Update handles structure +guidata(hObject, handles); + +%cd('E:\lcassan\Mes documents\macro_rugosite\cassiopee\gui_matlab') +%cd('D:\macrorugosite\cassiopee\gui_matlab') +load data_precalcul_nat + + + +set(handles.edit1,'string',z_amont); +set(handles.edit17,'string',long); +set(handles.edit2,'string',ks); +set(handles.edit3,'string',D); +set(handles.edit4,'string',h); +set(handles.edit5,'string',Cd); +set(handles.edit6,'string',S); +set(handles.edit7,'string',L); +set(handles.edit8,'string',pf); +set(handles.edit9,'string',C); +set(handles.edit10,'string',Q); +set(handles.edit20,'string',paramin); +set(handles.edit21,'string',parapas); +set(handles.edit22,'string',paramax); + + +% UIWAIT makes window_4a1 wait for user response (see UIRESUME) +% uiwait(handles.figure1); + + +% --- Outputs from this function are returned to the command line. +function varargout = window_4a1_OutputFcn(hObject, eventdata, handles) +% varargout cell array for returning output args (see VARARGOUT); +% hObject handle to figure +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Get default command line output from handles structure +varargout{1} = handles.output; + + + +function edit1_Callback(hObject, eventdata, handles) +% hObject handle to edit3 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit3 as text +% str2double(get(hObject,'String')) returns contents of edit3 as a double + + + +% --- Executes during object creation, after setting all properties. +function edit1_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit3 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit2_Callback(hObject, eventdata, handles) +% hObject handle to edit2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit3 as text +% str2double(get(hObject,'String')) returns contents of edit3 as a double + + + +% --- Executes during object creation, after setting all properties. +function edit2_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + + +function edit3_Callback(hObject, eventdata, handles) +% hObject handle to edit3 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit3 as text +% str2double(get(hObject,'String')) returns contents of edit3 as a double + + +% --- Executes during object creation, after setting all properties. +function edit3_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit3 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit4_Callback(hObject, eventdata, handles) +% hObject handle to edit4 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit4 as text +% str2double(get(hObject,'String')) returns contents of edit4 as a double + + +% --- Executes during object creation, after setting all properties. +function edit4_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit4 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit5_Callback(hObject, eventdata, handles) +% hObject handle to edit5 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit5 as text +% str2double(get(hObject,'String')) returns contents of edit5 as a double + + +% --- Executes during object creation, after setting all properties. +function edit5_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit5 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +function edit6_Callback(hObject, eventdata, handles) +% hObject handle to edit6 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit6 as text +% str2double(get(hObject,'String')) returns contents of edit6 as a double + + +% --- Executes during object creation, after setting all properties. +function edit6_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit6 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +function edit7_Callback(hObject, eventdata, handles) +% hObject handle to edit7 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit7 as text +% str2double(get(hObject,'String')) returns contents of edit7 as a double + + +% --- Executes during object creation, after setting all properties. +function edit7_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit7 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +function edit8_Callback(hObject, eventdata, handles) +% hObject handle to edit8 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit8 as text +% str2double(get(hObject,'String')) returns contents of edit8 as a double + + + +% --- Executes during object creation, after setting all properties. +function edit8_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit8 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit9_Callback(hObject, eventdata, handles) +% hObject handle to edit9 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit9 as text +% str2double(get(hObject,'String')) returns contents of edit9 as a double + + +% --- Executes during object creation, after setting all properties. +function edit9_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit9 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit10_Callback(hObject, eventdata, handles) +% hObject handle to edit10 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit10 as text +% str2double(get(hObject,'String')) returns contents of edit10 as a double + + +% --- Executes during object creation, after setting all properties. +function edit10_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit10 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit13_Callback(hObject, eventdata, handles) +% hObject handle to edit13 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit13 as text +% str2double(get(hObject,'String')) returns contents of edit13 as a double + + +% --- Executes during object creation, after setting all properties. +function edit13_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit13 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit14_Callback(hObject, eventdata, handles) +% hObject handle to edit14 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit14 as text +% str2double(get(hObject,'String')) returns contents of edit14 as a double + + +% --- Executes during object creation, after setting all properties. +function edit14_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit14 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit15_Callback(hObject, eventdata, handles) +% hObject handle to edit15 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit15 as text +% str2double(get(hObject,'String')) returns contents of edit15 as a double + + +% --- Executes during object creation, after setting all properties. +function edit15_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit15 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit11_Callback(hObject, eventdata, handles) +% hObject handle to edit11 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit11 as text +% str2double(get(hObject,'String')) returns contents of edit11 as a double + + +% --- Executes during object creation, after setting all properties. +function edit11_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit11 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit12_Callback(hObject, eventdata, handles) +% hObject handle to edit12 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit12 as text +% str2double(get(hObject,'String')) returns contents of edit12 as a double + + +% --- Executes during object creation, after setting all properties. +function edit12_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit12 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit16_Callback(hObject, eventdata, handles) +% hObject handle to edit16 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit16 as text +% str2double(get(hObject,'String')) returns contents of edit16 as a double + + +% --- Executes during object creation, after setting all properties. +function edit16_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit16 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + + + + + + +% --- Executes on button press in pushbutton1. +function pushbutton1_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton1 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + +maxfun=5000; +maxiter=5000; +tolfun=1e-24; +tolx=1e-24; + +% DEBUG +%maxiter=2; + +z_amont=get(handles.edit1,'string'); +z_amont=str2num(z_amont); + +long=get(handles.edit17,'string'); +long=str2num(long); + +%setappdata(gcf,'z_amont',z_amont); +ks=get(handles.edit2,'string'); +ks=str2num(ks); +setappdata(gcf,'ks',ks); +D=get(handles.edit3,'string'); +D=str2num(D); +%setappdata(gcf,'D',D); +h=get(handles.edit4,'string'); +h=str2num(h); +%setappdata(gcf,'h',h); +Cd=get(handles.edit5,'string'); +Cd=str2num(Cd); +%setappdata(gcf,'Cd',Cd); +S=get(handles.edit6,'string'); +S=str2num(S); +%setappdata(gcf,'S',S); +L=get(handles.edit7,'string'); +L=str2num(L); +%setappdata(gcf,'L',L); +pf=get(handles.edit8,'string'); +pf=str2num(pf); +%setappdata(gcf,'pf',pf); +C=get(handles.edit9,'string'); +C=str2num(C); +%setappdata(gcf,'C',C); +Q=get(handles.edit10,'string'); +Q=str2num(Q); +%setappdata(gcf,'Q',Q); + + +paramin=str2num(get(handles.edit20,'string')); +parapas=str2num(get(handles.edit21,'string')); +paramax=str2num(get(handles.edit22,'string')); +para=(paramin:parapas:paramax); + +save data_precalcul_nat z_amont long ks D h Cd S L pf C Q paramin parapas paramax + +% +% z_amont=getappdata(gcf,'z_amont'); +% ks=getappdata(gcf,'ks'); +% D=getappdata(gcf,'D'); +% h=getappdata(gcf,'h'); +% Cd=getappdata(gcf,'Cd'); +% S=getappdata(gcf,'S'); +% L=getappdata(gcf,'L'); +% pf=getappdata(gcf,'pf'); +% C=getappdata(gcf,'C'); +% Q=getappdata(gcf,'Q'); + +f=1; + + + +if Cd==2 ;sigma=1;else sigma=pi/4; end +alpha=1-(f.*C).^0.5-1/2*sigma.*C; +g=9.81; + +if Q~=0 & pf~=0 & L~=0 & S~=0 & C~=0 + warning_4a1_1 +end + + +if Q==0 + N=0; + q0=(2*g.*S.*D.*(1-(sigma*C))./(Cd.*C.*(1+N))).^0.5*pf*L; + + [Q res]=fminsearch(@(Qi) find_Q_nat(z_amont,ks,D,h,Cd,S,L,pf,C,Qi,sigma),q0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)) + set(handles.edit10,'string',num2str(Q)) + +elseif pf==0 + [pf res]=fminsearch(@(pfi) find_Q_nat(z_amont,ks,D,h,Cd,S,L,pfi,C,Q,sigma),h*1.1,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)) + set(handles.edit8,'string',num2str(pf)) + +elseif L==0 + [L res]=fminsearch(@(Li) find_Q_nat(z_amont,ks,D,h,Cd,S,Li,pf,C,Q,sigma),10,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)) + set(handles.edit7,'string',num2str(L)) + +elseif S==0 + S0=0.1; + [S res]=fminsearch(@(Si) find_Q_nat(z_amont,ks,D,h,Cd,Si,L,pf,C,Q,sigma),S0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)) + set(handles.edit6,'string',num2str(S)) + +elseif C==0 + C0=0.1; + [C res]=fminsearch(@(Ci) find_Q_nat(z_amont,ks,D,h,Cd,S,L,pf,Ci,Q,sigma),C0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)) + set(handles.edit9,'string',num2str(C)) + +end + + + + +cote_bas=z_amont-S*long; +set(handles.edit11,'string',num2str(cote_bas)) + +Vdeb=Q/L/pf; +set(handles.edit12,'string',num2str(Vdeb)) +coeff_contraction=0.4*Cd+0.7; +Vg=Q/L/pf/(1-C^0.5); +Fr=Vg./(g.*pf).^0.5; +if Cd==2 + Vmax=Vg.*(min(coeff_contraction./(1-(Fr.^2)/4),Fr.^(-2/3)));% +else + Vmax=Vg.*(min(coeff_contraction./(1-(Fr.^2)/4),Fr.^(-2/3))); +end + +set(handles.edit16,'string',num2str(Vmax)) + +P=1000*g*Q/L*S; +set(handles.edit13,'string',num2str(P)) + + +set(handles.edit14,'string',num2str(Fr)) + +if pf/h<1 + set(handles.edit15,'string','emergent') +elseif pf/h<1.1 && pf/h>=1 + set(handles.edit15,'string','quasi emergent') +else + set(handles.edit15,'string','immerge') +end + + + +if pf/h>1.1 + + q_technique=0.955*(pf/h)^2.282*S^0.466*C^(-0.23)*(9.81*h)^0.5.*h*L; + set(handles.edit19,'string','NC') + set(handles.edit16,'string','NC') +else + if Cd==2 + + q_technique= 0.648*(pf/D)^1.084*S^0.56*C^(-0.456)*(9.81*D)^0.5.*D*L; + V_technique=3.35*(pf/D)^0.27*S^0.53*(9.81*D)^0.5; + else + q_technique=0.815*(pf/D)^1.45*S^0.557*C^(-0.456)*(9.81*D)^0.5.*D*L; + V_technique=4.54*(pf/D)^0.32*S^0.56*(9.81*D)^0.5; + + end + + set(handles.edit19,'string',num2str(V_technique)) ; +end +set(handles.edit18,'string',num2str(q_technique)) ; + + + +function edit17_Callback(hObject, eventdata, handles) +% hObject handle to edit17 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit17 as text +% str2double(get(hObject,'String')) returns contents of edit17 as a double + + +% --- Executes during object creation, after setting all properties. +function edit17_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit17 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit19_Callback(hObject, eventdata, handles) +% hObject handle to edit19 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit19 as text +% str2double(get(hObject,'String')) returns contents of edit19 as a double + + +% --- Executes during object creation, after setting all properties. +function edit19_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit19 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit18_Callback(hObject, eventdata, handles) +% hObject handle to edit18 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit18 as text +% str2double(get(hObject,'String')) returns contents of edit18 as a double + + +% --- Executes during object creation, after setting all properties. +function edit18_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit18 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edi5_Callback(hObject, eventdata, handles) +% hObject handle to edi5 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edi5 as text +% str2double(get(hObject,'String')) returns contents of edi5 as a double + + +% --- Executes during object creation, after setting all properties. +function edi5_CreateFcn(hObject, eventdata, handles) +% hObject handle to edi5 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + +% --- Executes on button press in pushbutton2. +function pushbutton2_Callback(hObject, eventdata, handles) +% hObject handle to pushbutton2 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + + + +maxfun=5000; +maxiter=5000; +tolfun=1e-24; +tolx=1e-24; + + +z_amont=get(handles.edit1,'string'); +z_amont=str2num(z_amont); + +long=get(handles.edit17,'string'); +long=str2num(long); + +%setappdata(gcf,'z_amont',z_amont); +ks=get(handles.edit2,'string'); +ks=str2num(ks); +%setappdata(gcf,'ks',ks); +D=get(handles.edit3,'string'); +D=str2num(D); +%setappdata(gcf,'D',D); +h=get(handles.edit4,'string'); +h=str2num(h); +%setappdata(gcf,'h',h); +Cd=get(handles.edit5,'string'); +Cd=str2num(Cd); +%setappdata(gcf,'Cd',Cd); +S=get(handles.edit6,'string'); +S=str2num(S); +%setappdata(gcf,'S',S); +L=get(handles.edit7,'string'); +L=str2num(L); +%setappdata(gcf,'L',L); +pf=get(handles.edit8,'string'); +pf=str2num(pf); +%setappdata(gcf,'pf',pf); +C=get(handles.edit9,'string'); +C=str2num(C); +%setappdata(gcf,'C',C); +Q=get(handles.edit10,'string'); +Q=str2num(Q); +%setappdata(gcf,'Q',Q); + + +paramin=str2num(get(handles.edit20,'string')); +parapas=str2num(get(handles.edit21,'string')); +paramax=str2num(get(handles.edit22,'string')); +para=(paramin:parapas:paramax); + +save data_precalcul_nat z_amont long ks D h Cd S L pf C Q paramin parapas paramax + + +% +% z_amont=getappdata(gcf,'z_amont'); +% ks=getappdata(gcf,'ks'); +% D=getappdata(gcf,'D'); +% h=getappdata(gcf,'h'); +% Cd=getappdata(gcf,'Cd'); +% S=getappdata(gcf,'S'); +% L=getappdata(gcf,'L'); +% pf=getappdata(gcf,'pf'); +% C=getappdata(gcf,'C'); +% Q=getappdata(gcf,'Q'); + +f=1; + + + +if Cd==2 ;sigma=1;else sigma=pi/4; end +alpha=1-(f.*C).^0.5-1/2*sigma.*C; +g=9.81; + +if Q~=0 & pf~=0 & L~=0 & S~=0 & C~=0 + warning_4a1_1 +end + +for tt=1:length(para) + + if D==0 + + N=0; + q0=(2*g.*S.*para(tt).*(1-(sigma*C))./(Cd.*C.*(1+N))).^0.5*pf*L; + [Qr(tt) res]=fminsearch(@(Qi) find_Q_nat(z_amont,ks,para(tt),h,Cd,S,L,pf,C,Qi,sigma),q0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)) ; + + Vdeb(tt)=Qr(tt)/L/pf; + Vg(tt)=Qr(tt)/L/pf/(1-C^0.5); + Fr(tt)=Vg(tt)./(g.*pf).^0.5; + + + elseif Q==0 + + N=0; + + + [pf2(tt) res]=fminsearch(@(pfi) find_Q_nat(z_amont,ks,D,h,Cd,S,L,pfi,C,para(tt),sigma),pf,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)); + + Vdeb(tt)=para(tt)/L/pf2(tt); + Vg(tt)=para(tt)/L/pf2(tt)/(1-C^0.5); + Fr(tt)=Vg(tt)./(g.*pf2(tt)).^0.5; + + + elseif pf==0 + + N=0; + q0=(2*g.*S.*D.*(1-(sigma*C))./(Cd.*C.*(1+N))).^0.5*para(tt)*L; + + [Qr(tt) res]=fminsearch(@(Qi) find_Q_nat(z_amont,ks,D,h,Cd,S,L,para(tt),C,Qi,sigma),q0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)); + + Vdeb(tt)=Qr(tt)/L/para(tt); + Vg(tt)=Qr(tt)/L/para(tt)/(1-C^0.5); + Fr(tt)=Vg(tt)./(g.*para(tt)).^0.5; + + + elseif L==0 + + N=0; + q0=(2*g.*S.*D.*(1-(sigma*C))./(Cd.*C.*(1+N))).^0.5*pf*para(tt); + [Qr(tt) res]=fminsearch(@(Qi) find_Q_nat(z_amont,ks,D,h,Cd,S,para(tt),pf,C,Qi,sigma),q0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)); + + Vdeb(tt)=Qr(tt)/para(tt)/pf; + Vg(tt)=Qr(tt)/para(tt)/pf/(1-C^0.5); + Fr(tt)=Vg(tt)./(g.*pf).^0.5; + + + elseif S==0 + S0=0.1; + + N=0; + q0=(2*g.*para(tt).*D.*(1-(sigma*C))./(Cd.*C.*(1+N))).^0.5*pf*L; + [Qr(tt) res]=fminsearch(@(Qi) find_Q_nat(z_amont,ks,D,h,Cd,para(tt),L,pf,C,Qi,sigma),q0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)); + + Vdeb(tt)=Qr(tt)/L/pf; + Vg(tt)=Qr(tt)/L/pf/(1-C^0.5); + Fr(tt)=Vg(tt)./(g.*pf).^0.5; + + + + elseif C==0 + + N=0; + q0=(2*g.*S.*D.*(1-(sigma*para(tt)))./(Cd.*para(tt).*(1+N))).^0.5*pf*L; + [Qr(tt) res]=fminsearch(@(Qi) find_Q_nat(z_amont,ks,D,h,Cd,S,L,pf,para(tt),Qi,sigma),q0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)) ; + + Vdeb(tt)=Qr(tt)/L/pf; + Vg(tt)=Qr(tt)/L/pf/(1-para(tt)^0.5); + Fr(tt)=Vg(tt)./(g.*pf).^0.5; + + + end + + + if Cd==2 + Vmax(tt)=Vg(tt).*(min(1.6./(1-(Fr(tt).^2)/4),Fr(tt).^(-2/3)));% + else + Vmax(tt)=Vg(tt).*(min(1.2./(1-(Fr(tt).^2)/4),Fr(tt).^(-2/3))); + end + + +end + + + +figure(1) +subplot(2,1,1) +hold on +plot(para,Vg,'k','LineWidth',2) +plot(para,Vmax,'k:','LineWidth',2) +plot(para,Vdeb,'k-.','LineWidth',2) + + if D==0 + xlabel('Diametre (m)','Interpreter','Latex','FontSize',24) + elseif Q==0 + xlabel('Débit (m2/s)','Interpreter','Latex','FontSize',24) + elseif pf==0 + xlabel('Profondeur','Interpreter','Latex','FontSize',24) + elseif L==0 + xlabel('Largeur','Interpreter','Latex','FontSize',24) + elseif S==0 + xlabel('Pente','Interpreter','Latex','FontSize',24) + + elseif C==0 + xlabel('Concentration','Interpreter','Latex','FontSize',24) + end + + ylabel('Vitesse (m/s)','Interpreter','Latex','FontSize',24) +hleng=legend('Vg','V_{max}','V_{debitant}'); +set(hleng, 'FontName','Times New Roman','FontSize',20) +set(gca, 'FontSize', 20, 'fontName','Times'); + +% +figure(1) +subplot(2,1,2) +hold on +if Q==0 + plot(para,pf2,'k','LineWidth',2) +else +plot(para,Qr,'k','LineWidth',2) +end + if D==0 + xlabel('Diametre (m)','Interpreter','Latex','FontSize',24) + elseif Q==0 + xlabel('Débit (m3/s)','Interpreter','Latex','FontSize',24) + elseif pf==0 + xlabel('profondeur','Interpreter','Latex','FontSize',24) + elseif L==0 + xlabel('Largeur','Interpreter','Latex','FontSize',24) + elseif S==0 + xlabel('Pente','Interpreter','Latex','FontSize',24) + + elseif C==0 + xlabel('Concentration','Interpreter','Latex','FontSize',24) + end + + + if Q==0 +ylabel('Profondeur (m)','Interpreter','Latex','FontSize',24) +else +ylabel('Débit (m3/s)','Interpreter','Latex','FontSize',24) + end + +%hleng=legend('Débit (m^2/s)'); +%set(hleng, 'FontName','Times New Roman','FontSize',20) +set(gca, 'FontSize', 20, 'fontName','Times'); + + + +function edit20_Callback(hObject, eventdata, handles) +% hObject handle to edit20 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit20 as text +% str2double(get(hObject,'String')) returns contents of edit20 as a double + + +% --- Executes during object creation, after setting all properties. +function edit20_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit20 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit21_Callback(hObject, eventdata, handles) +% hObject handle to edit21 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit21 as text +% str2double(get(hObject,'String')) returns contents of edit21 as a double + + +% --- Executes during object creation, after setting all properties. +function edit21_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit21 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end + + + +function edit22_Callback(hObject, eventdata, handles) +% hObject handle to edit22 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles structure with handles and user data (see GUIDATA) + +% Hints: get(hObject,'String') returns contents of edit22 as text +% str2double(get(hObject,'String')) returns contents of edit22 as a double + + +% --- Executes during object creation, after setting all properties. +function edit22_CreateFcn(hObject, eventdata, handles) +% hObject handle to edit22 (see GCBO) +% eventdata reserved - to be defined in a future version of MATLAB +% handles empty - handles not created until after all CreateFcns called + +% Hint: edit controls usually have a white background on Windows. +% See ISPC and COMPUTER. +if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor')) + set(hObject,'BackgroundColor','white'); +end diff --git a/doc/scilab_tests/macrorugo_find_Q_nat.sci b/doc/scilab_tests/macrorugo_find_Q_nat.sci new file mode 100644 index 0000000000000000000000000000000000000000..b54926333caa69b9b766d65229bf579cceed3a68 --- /dev/null +++ b/doc/scilab_tests/macrorugo_find_Q_nat.sci @@ -0,0 +1,116 @@ +function [res]=find_Q_nat(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg) + if bDbg then + printf('*************************************\n') + print_r('Q') + end + //fonction pour ax=ay + + maxfun=5000; + maxiter=5000; + tolfun=1e-16; + tolx=1e-16; + opt = optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'TolFun',tolfun,'TolX',tolx) + g=9.81; + kappa=0.41; + U0=Q./L./pf; + if(bDbg) then print_r("U0"); end; + + Fr=U0./(9.81*pf).^0.5; + Frg=Fr/(1-C^0.5); + + if ks==0;ks=1e-34;end + + coeff_contraction=0.4*Cd0+0.7; + + //if Cd0==2 + // fFr=(min(2.5,Frg^(-4/3)));// + //else + fFr=(min(coeff_contraction./(1-(Frg.^2)/4),Frg.^(-2/3))).^2; + //end + + if Frg>1.5 + fFr=(Frg.^(-2/3)).^2; + end + + if(bDbg) then print_r("fFr"); end; + + alpha=1-(1.*C).^0.5-1/2*sigma.*C; + Cd=Cd0.*(1+1./(pf./D).^2).*fFr; + + //Cd=Cd0.*(0.8-2*C).*(1+0.4./(pf./D).^2).*fFr; + R=(1-sigma*C);//%.*(1-C.^0.5).^2; + + + if pf/h>1.1; //fFr=1; + + choixturb=1; + htilde=h./D; + hstar=pf./h; + Rh=h.*(hstar-1); + ustar=(g.*S.*Rh).^0.5; + if bDbg then print_r('ustar'); end; + + Cd1=Cd0.*(1+0.4./(pf./D).^2).*fFr; + CdCh=Cd1.*C.*htilde; + if bDbg then print_r('CdCh'); end; + + Cf=2./(5.1.*log10(h./ks)+6).^2; + U0b=(2*g.*S.*R./(Cd1.*C.*h./D+Cf.*R).*h).^0.5; + if bDbg then print_r('U0b'); end; + + // U0=(2*g.*S.*D.*R./(Cd1.*C)).^0.5; + + //[P]=fminbnd(@(alphai) resolve_alpha(alphai,CdCh,R,U0b,hstar,h,C,D,Cd1,ustar,choixturb),1e-5*h,h,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)); + //alpha=P(1); + [alpha fval] = fminsearch(list(resolve_alpha, CdCh,R,U0b,hstar,h,C,D,Cd1,ustar), h/10, opt) + if bDbg then print_r('alpha'); end; + beta2=h.*CdCh./alpha./R; + beta=(beta2).^0.5; + a1=beta*(hstar-1)/(cosh(beta)); + c=1; + + UhU0=(a1*sinh(beta)+c)^0.5; + Uh=UhU0*U0b; + if bDbg then print_r('Uh'); end; + + dhp=1-1/kappa*alpha./h.*Uh./ustar; + z0hp=(1-dhp).*exp(-1*(kappa*Uh./ustar)); + + qsup=ustar./kappa.*h.*((hstar-dhp).*(log((hstar-dhp)./z0hp) - 1)-((1-dhp).*(log((1-dhp)./z0hp) - 1))); + if bDbg then print_r('qsup'); end; + //calcul intégrale dans la canopée---- + dzinf=0.01; + Zinf=(0:dzinf:1); + Uinf = U0b.*(beta.*Rh./h.*sinh(beta*Zinf)./cosh(beta)+1).^0.5; + Ub=zeros(Uinf); + Ub(1:$-1)=Uinf(2:$); + qinf=sum((Uinf(1:$-1)+Ub(1:$-1))/2*dzinf.*h); + if bDbg then print_r('qinf'); end; + qtot=qinf+qsup; + + PI=0; + delta=1; + + Umoy=qtot./pf; + res=abs(U0-Umoy); + + else + + hstar=pf/D; + Re=U0.*pf/1e-6; + + if ks==0 + Cf=0.3164/4.*Re.^(-0.25); + else + Cf=2/(5.1*log10(pf/ks-1)+6)^2; + end + + N= (alpha.*Cf)./(pf./D.*Cd.*C); + + res=abs(U0-(2*g.*S.*D.*(R)./(Cd.*C.*(1+N))).^0.5); + + + + end + +endfunction diff --git a/doc/scilab_tests/macrorugo_find_Q_nat2.sci b/doc/scilab_tests/macrorugo_find_Q_nat2.sci deleted file mode 100644 index 04275b15737b3985636ea725af6013fcd8e2bfeb..0000000000000000000000000000000000000000 --- a/doc/scilab_tests/macrorugo_find_Q_nat2.sci +++ /dev/null @@ -1,118 +0,0 @@ -function [res]=find_Q_nat2(Q,ks,D,h,Cd0,S,L,pf,C,sigma,bDbg) - -//fonctin pour ax=ay - - -maxfun=5000; -maxiter=5000; -tolfun=1e-16; -tolx=1e-16; -g=9.81; -kappa=0.41; -U0=Q./L./pf; -if(bDbg) then print_r("U0"); end; - -Fr=U0./(9.81*pf).^0.5; -Frg=Fr/(1-C^0.5); - - -coeff_contraction=0.4*Cd0+0.7; - -//if Cd0==2 - // fFr=(min(2.5,Frg^(-4/3)));// -//else - fFr=(min(coeff_contraction./(1-(Frg.^2)/4),Frg.^(-2/3))).^2; -//end - -if Frg>1.5 - fFr=(Frg.^(-2/3)).^2; -end - -if(bDbg) then print_r("fFr"); end; - -alpha=1-(1.*C).^0.5-1/2*sigma.*C; -//Cd=Cd0.*(1+1./(pf./D).^2).*fFr; - -Cd=Cd0.*(0.8-2*C).*(1+0.4./(pf./D).^2).*fFr; -R=(1-sigma*C).*(1-C.^0.5).^2; - - -if pf/h>1.1; fFr=1; - - choixturb=1; - htilde=h./D; - hstar=pf./h; - Rh=h.*(hstar-1); - ustar=(g.*S.*Rh).^0.5; - CdCh=Cd0.*(1+0.4./(pf./D).^2).*C.*htilde; - u0=(2*g.*S.*D.*R./(Cd0.*C)).^0.5; - // [P]=fminbnd(@(alphai) resolve_alpha(alphai,CdCh,R,u0,hstar,h,C,D,Cd0,ustar,choixturb),1e-5*h,h,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)); - - - //[P]=fminbnd(@(alphai) resolve_alpha(alphai,CdCh,R,u0,hstar,h,C,D,Cd0,ustar,choixturb),1e-5*h,h); - [alpha fval] = fminsearch(list(resolve_alpha, CdCh,R,u0,hstar,h,C,D,Cd0,ustar), 1e-5*h) - - beta2=h.*CdCh./alpha./R; - beta2=(beta2).^0.5; - a1=beta2*(hstar-1)/(cosh(beta2)); - c=1; - UhU0=(a1*sinh(beta2)+c)^0.5; - Uh=UhU0*u0; - dhp=1-1/kappa*alpha./h.*Uh./ustar; - z0hp=(1-dhp).*exp(-1*(kappa*Uh./ustar)); - qsup=ustar./kappa.*h.*((hstar-dhp).*(log((hstar-dhp)./z0hp) - 1)-((1-dhp).*(log((1-dhp)./z0hp) - 1))); - - //calcul intégrale dans la canopée---- - - U(1)=u0; - U(2)=u0.*(beta2.*Rh./h.*sinh(beta2*0.1)./cosh(beta2)+c).^0.5; - U(3)=u0.*(beta2.*Rh./h.*sinh(beta2*0.2)./cosh(beta2)+c).^0.5; - U(4)=u0.*(beta2.*Rh./h.*sinh(beta2*0.3)./cosh(beta2)+c).^0.5; - U(5)=u0.*(beta2.*Rh./h.*sinh(beta2*0.4)./cosh(beta2)+c).^0.5; - U(6)=u0.*(beta2.*Rh./h.*sinh(beta2*0.5)./cosh(beta2)+c).^0.5; - U(7)=u0.*(beta2.*Rh./h.*sinh(beta2*0.6)./cosh(beta2)+c).^0.5; - U(8)=u0.*(beta2.*Rh./h.*sinh(beta2*0.7)./cosh(beta2)+c).^0.5; - U(9)=u0.*(beta2.*Rh./h.*sinh(beta2*0.8)./cosh(beta2)+c).^0.5; - U(10)=u0.*(beta2.*Rh./h.*sinh(beta2*0.9)./cosh(beta2)+c).^0.5; - U(11)=Uh; - - Ub=zeros(U); - Ub(1:$-1)=U(2:$); - qinf=sum((U(1:$-1)+Ub(1:$-1))/2*0.1.*h); - qtot=qinf+qsup; - PI=0.2; - delta=1; - Umax=ustar./kappa*(log((delta*(h-h)-dhp*h)/(z0hp*h))+2*PI); - Umoy=qtot./pf; - res=abs(U0-Umoy); - -else - - hstar=pf/D; - Re=U0.*pf/1e-6; - - if ks==0 - Cf=0.3164/4.*Re.^(-0.25); - else - Cf=2/(5.1*log10(pf/ks-1)+6)^2; - end - - if(bDbg) then print_r("Cf"); end; - - -//[u res]=fminsearch(@(U0i) find_U0_complet(U0i,pf,C,D,sigma,Cd0,Cf,coeff_contraction,S),U0,optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'Tolfun',tolfun,'TolX',tolx)); -[u res] = fminsearch ( list(find_U0_R0,pf,C,D,sigma,Cd0,Cf,coeff_contraction,S) , U0 ) - - - // N= (alpha.*Cf)./(pf./D.*Cd.*C); - - // res=abs(U0-(2*g.*S.*D.*(R)./(Cd.*C.*(1+N))).^0.5); - - - res=abs(U0-u); - - - -end - -endfunction diff --git a/doc/scilab_tests/macrorugo_resolve_alpha.sci b/doc/scilab_tests/macrorugo_resolve_alpha.sci index 3c68729b6c71bbd81638f696ae2fdf87cc4fcca6..877ee789c4da4b91ea38e316cc48562fee22e601 100644 --- a/doc/scilab_tests/macrorugo_resolve_alpha.sci +++ b/doc/scilab_tests/macrorugo_resolve_alpha.sci @@ -1,6 +1,8 @@ function [res]= resolve_alpha(alpha,CdCh,R,U0,hstar,hp,C,D,Cd,ustar) - +if bDbg then + printf('resolve_alpha(alpha=%f,CdCh=%f,R=%f,U0=%f,hstar=%f,hp=%f,C=%f,D=%f,Cd=%f,ustar=%f)\n',alpha,CdCh,R,U0,hstar,hp,C,D,Cd,ustar) +end g=9.81; kappa=0.41; @@ -41,5 +43,8 @@ Uh=UhU0*U0; res=abs(alpha*Uh-L1*ustar); +if bDbg then + printf('resolve_alpha res=%f\n',res) +end endfunction diff --git a/doc/scilab_tests/macrorugo_resultats_complementaires.sci b/doc/scilab_tests/macrorugo_resultats_complementaires.sci index 6a9f5c259b2aca1db941243f084cbf9f668a71f9..b9b277538910dd8be6509f4445e7f9ba299e45f2 100644 --- a/doc/scilab_tests/macrorugo_resultats_complementaires.sci +++ b/doc/scilab_tests/macrorugo_resultats_complementaires.sci @@ -11,40 +11,33 @@ function macrorugo_resultComp(z_amont, S, long, Q, L, pf, C, Cd, h, D) Vg=Q/L/pf/(1-C^0.5); Fr=Vg./(g.*pf).^0.5; print_r("Fr"); - if Cd==2 - Vmax=Vg.*(min(1.6./(1-(Fr.^2)/4),Fr.^(-2/3)));% - else - Vmax=Vg.*(min(1.2./(1-(Fr.^2)/4),Fr.^(-2/3))); - end - - print_r("Vmax"); P=1000*g*Q/L*S; print_r("P"); if pf/h<1 flowcond = 'emergent' - elseif pf/h<1.1 & pf/h>=1 + elseif pf/h<1.1 && pf/h>=1 flowcond = 'quasi emergent' - elseif pf/h>1.2 + else flowcond = 'immerge' end print_r("flowcond"); - + if pf/h>1.1 - - q_technique=0.955*(pf/h)^2.282*S^0.466*C^(-0.23)*(9.81*D)^0.5.*h*L; + q_technique=0.955*(pf/h)^2.282*S^0.466*C^(-0.23)*(9.81*h)^0.5.*h*L; else + coeff_contraction=0.4*Cd+0.7; if Cd==2 - q_technique= 0.648*(pf/D)^1.084*S^0.56*C^(-0.456)*(9.81*D)^0.5.*D*L; V_technique=3.35*(pf/D)^0.27*S^0.53*(9.81*D)^0.5; + Vmax=Vg.*(min(coeff_contraction/(1-(Fr.^2)/4),Fr.^(-2/3))); else q_technique=0.815*(pf/D)^1.45*S^0.557*C^(-0.456)*(9.81*D)^0.5.*D*L; V_technique=4.54*(pf/D)^0.32*S^0.56*(9.81*D)^0.5; - + Vmax=Vg.*(min(coeff_contraction/(1-(Fr.^2)/4),Fr.^(-2/3))); end - + print_r("Vmax"); print_r("V_technique"); end print_r("q_technique"); diff --git a/doc/scilab_tests/macrorugo_searchQ.sci b/doc/scilab_tests/macrorugo_searchQ.sci new file mode 100644 index 0000000000000000000000000000000000000000..e9c3656c5de0835e675ba7e194a3fe69d92ba906 --- /dev/null +++ b/doc/scilab_tests/macrorugo_searchQ.sci @@ -0,0 +1,26 @@ +function macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) + printf("ks=%f\n", ks) + printf("D=%f\n", D) + printf("k=%f\n", k) + printf("Cd0=%f\n", Cd0) + printf("S=%f\n", S) + printf("B=%f\n", B) + printf("h=%f\n", h) + printf("C=%f\n", C) + + maxfun=5000; + maxiter=5000; + tolfun=1e-24; + tolx=1e-24; + if bDbg then + maxiter=1 + end + opt = optimset('MaxIter',maxiter,'MaxFunEvals',maxfun,'TolFun',tolfun,'TolX',tolx) + if Cd0==2; sigma=1; else sigma=%pi/4; end + g=9.81 + N=0; + q0=(2*g.*S.*D.*(1-(sigma*C))/(Cd0.*C.*(1+N))).^0.5*h*B; + [Q fVal, exitflag, outputs] = fminsearch(list(find_Q_nat, ks,D,k,Cd0,S,B,h,C,sigma,bDbg), q0, opt); + printf("Q=%f fVal=%f\n",Q, fVal); + macrorugo_resultComp(z_amont, S, long, Q, B, h, C, Cd0, k, D) +endfunction diff --git a/doc/scilab_tests/main_macrorugo.sce b/doc/scilab_tests/main_macrorugo.sce index 29ca61fbe5fd23967d05277c4c21f3c7e232ea85..b14271cd07f80f2f068401825742c7b6d44d2ae0 100644 --- a/doc/scilab_tests/main_macrorugo.sce +++ b/doc/scilab_tests/main_macrorugo.sce @@ -3,46 +3,39 @@ clear sCurrentPath = get_absolute_file_path("main_macrorugo.sce"); getd(sCurrentPath); +bDbg = %f; + // Tests parameters -ks = 0.01 -Cd0=1.5 -S = 0.05 -C = 0.05; -D = 0.5; -sigma = 1; -B = 1 -z_amont = 12.5; -long = 6; +ks = 0.01 // Rugosité de fond (m) +Cd0=1.5 // Forme +S = 0.05 // Pente +C = 0.13; // Concentration +D = 0.5; // Diamètre +B = 1 // Largeur +z_amont = 12.5; // Cote amont (m) +long = 6; // Longueur rampe (m) // ***************************************************************************** -printf("\n*** Emergent conditions ***\n") +printf("\n*** Emergent conditions Cd=1.5***\n") // ***************************************************************************** h = 0.6 -k = 0.8 - -// Test de find_U0_R0 -Cf=2/(5.1*log10(h/ks-1)+6)^2 -coeff_contraction=0.4*Cd0+0.7 -res = find_U0_R0(2.58, h, C, D, sigma, Cd0, Cf, coeff_contraction, S) -printf("find_U0_R0=%f\n",res); - -// Test de find_Q_nat2 -[Q fVal] = fminsearch(list(find_Q_nat2, ks,D,k,Cd0,S,B,h,C,sigma,%f), 0.1); -printf("Qemerg=%f fVal=%f\n",Q, fVal); -res = find_Q_nat2(Q,ks,D,k,Cd0,S,B,h,C,sigma,%t) -printf("find_Q_nat2=%f\n",res); -macrorugo_resultComp(z_amont, S, long, Q, B, h, C, Cd0, k, D) +k = 0.7 +Cd0 = 1.5 +macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) +// ***************************************************************************** +printf("\n*** Emergent conditions Cd=2***\n") +// ***************************************************************************** +h = 0.6 +k = 0.7 +Cd0 = 2 +macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) // ***************************************************************************** printf("\n*** Submerged conditions ***\n") // ***************************************************************************** -k = 0.6 +k = 0.7 h = 0.8 - -[Q fVal] = fminsearch(list(find_Q_nat2, ks,D,k,Cd0,S,B,h,C,sigma,%f), 0.1); -printf("Qsubmerg=%f fVal=%f\n",Q, fVal); -res = find_Q_nat2(Q,ks,D,k,Cd0,S,B,h,C,sigma,%t) -printf("find_Q_nat2=%f\n",res); -macrorugo_resultComp(z_amont, S, long, Q, B, h, C, Cd0, k, D) +Cd0 = 1.5 +macrorugo_searchQ(ks, D, k, Cd0, S, B, h, C, z_amont, long, bDbg) diff --git a/doc/scilab_tests/print_r.sci b/doc/scilab_tests/print_r.sci index 918fceb24cd9ca98f1a1e3d10e5fe52659220937..0c33364324dbe47d4636ec3f60b6b34b417da46d 100644 --- a/doc/scilab_tests/print_r.sci +++ b/doc/scilab_tests/print_r.sci @@ -1,5 +1,5 @@ function print_r(s) - e = eval(s) + e = evstr(s) if typeof(e) == "string" then pat = "s" else