Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • s7603593/dune-microstructure
  • s7603593/dune-microstructure-backup
2 results
Show changes
Showing
with 338 additions and 0 deletions
F = @(t,y) [y(2); -y(1)];
y0 = [0 1]';
tspan= (0:1/36:1)*2*pi;
[t,y] = ode45(F,tspan,y0)
% plot phase-plane
plot(y(:,1),y(:,2), 'o-')
axis square
axis(1.2*[-1 1 -1 1])
\ No newline at end of file
[x,y,z] = meshgrid(1:20,1:20,1:20);
data = sqrt(x.^2 + y.^2 + z.^2);
p = patch(isosurface(x,y,z,data,20));
isonormals(x,y,z,data,p)
[r,g,b] = meshgrid(20:-1:1,1:20,1:20);
isocolors(x,y,z,r/20,g/20,b/20,p)
p.FaceColor = 'interp';
p.EdgeColor = 'none';
view(150,30)
daspect([1 1 1])
camlight
lighting gouraud
\ No newline at end of file
Copyright (c) 2009, Adam Auton
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the distribution
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
function yout = ode1(F,t0,h,tfinal,y0)
% ODE1 A simple ODE solver.
% yout = ode1(F,t0,h,tfinal,y0) uses Euler's
% method with fixed step size h on the intervall
% t0 <=t <= tfinal
% to solve
% dy/dt = F(t,y)
% with y(t0) = y0
y = y0;
yout = y;
for t = t0 : h : tfinal-h
s = F(t,y);
y = y+ h*s;
yout = [yout, y];
end
end
function yout = ode2(F,t0,h,tfinal,y0)
% ODE1 A simple ODE solver.
% yout = ode1(F,t0,h,tfinal,y0) uses Euler's
% method with fixed step size h on the intervall
% t0 <=t <= tfinal
% to solve
% dy/dt = F(t,y)
% with y(t0) = y0
y = y0;
yout = y;
for t = t0 : h : tfinal-h
s1 = F(t,y);
s2 = F(t + h/2 , y+ (h/2)*s1);
y = y+ h*s2;
yout = [yout, y];
end
end
function yout = ode2t(F,t0,h,tfinal,y0)
% ODE1 A simple ODE solver.
% yout = ode1(F,t0,h,tfinal,y0) uses Euler's
% method with fixed step size h on the intervall
% t0 <=t <= tfinal
% to solve
% dy/dt = F(t,y)
% with y(t0) = y0
y = y0;
yout = y;
for t = t0 : h : tfinal-h
s1 = F(t,y);
s2 = F(t + h , y+ h*s1);
y = y+ h*(s2+s1)/2;
yout = [yout, y];
end
end
File added
File added
function c = redblue(m)
%REDBLUE Shades of red and blue color map
% REDBLUE(M), is an M-by-3 matrix that defines a colormap.
% The colors begin with bright blue, range through shades of
% blue to white, and then through shades of red to bright red.
% REDBLUE, by itself, is the same length as the current figure's
% colormap. If no figure exists, MATLAB creates one.
%
% For example, to reset the colormap of the current figure:
%
% colormap(redblue)
%
% See also HSV, GRAY, HOT, BONE, COPPER, PINK, FLAG,
% COLORMAP, RGBPLOT.
% Adam Auton, 9th October 2009
if nargin < 1, m = size(get(gcf,'colormap'),1); end
if (mod(m,2) == 0)
% From [0 0 1] to [1 1 1], then [1 1 1] to [1 0 0];
m1 = m*0.5;
r = (0:m1-1)'/max(m1-1,1);
g = r;
r = [r; ones(m1,1)];
g = [g; flipud(g)];
b = flipud(r);
else
% From [0 0 1] to [1 1 1] to [1 0 0];
m1 = floor(m*0.5);
r = (0:m1-1)'/max(m1,1);
g = r;
r = [r; ones(m1+1,1)];
g = [g; 1; flipud(g)];
b = flipud(r);
end
c = [r g b];
<?xml version="1.0" encoding="UTF-8"?>
<addonCore>
<label>Red Blue Colormap</label>
<version>1.0.0.0</version>
<type>zip</type>
<identifier>e5698820-4a80-11e4-9553-005056977bd0</identifier>
<createdBy name="Adam Auton"/>
<image>resources/screenshot.png</image>
</addonCore>
<?xml version="1.0" encoding="UTF-8"?>
<paths>
<path>.</path>
</paths>
<?xml version="1.0" encoding="UTF-8"?>
<addOn>
<identifier>e5698820-4a80-11e4-9553-005056977bd0</identifier>
<displayType>Function</displayType>
<translatedDisplayType>
<en_US>Function</en_US>
<ja_JP>関数</ja_JP>
<ko_KR>함수</ko_KR>
<zh_CN>函数</zh_CN>
</translatedDisplayType>
<name>Red Blue Colormap</name>
<author>Adam Auton</author>
<version>1.0.0.0</version>
<downloadUrl>https://www.mathworks.com/matlabcentral/mlc-downloads/downloads/submissions/25536/versions/1/download/zip?src=addons_ml_desktop_install&amp;profile_id=14169257&amp;license=40758619&amp;release_family=R2020b</downloadUrl>
<licenseUrl>https://addons.mathworks.com/registry/v1/e5698820-4a80-11e4-9553-005056977bd0/1.0.0.0/-/license</licenseUrl>
<previewImageUrl>https://www.mathworks.com/responsive_image/160/120/0/0/0/cache/matlabcentral/mlc-downloads/downloads/submissions/25536/versions/1/screenshot.png</previewImageUrl>
<releaseNotesUrl>https://www.mathworks.com/add-ons/e5698820-4a80-11e4-9553-005056977bd0/d1034754-ea44-08f8-b658-22b590dfae7e/releaseNotes</releaseNotesUrl>
<installationFolder>Functions</installationFolder>
</addOn>
Matlab-Programs/resources/previewImage.png

18.8 KiB

File added
Matlab-Programs/resources/screenshot.png

17 KiB

clc
clear all
mu_1 = 1;
rho_1 = 1;
% HYPERBOLIC
b1 = @(a,b,t) (mu_1*rho_1/4).*(b./(t+(1-t).*b)).*(1-t.*(1+a));
b2 = @(a,b,t) mu_1.*(rho_1/8).*(1-t.*(1+b.*a));
h = @(a,b,t) b1(a,b,t).*b2(a,b,t);
% fix alpha
% a=1;
% fix theta , value in (0,1)
theta= 0.55;
% ELLIPTIC
q1 = @(b,t) mu_1.*(b./(t+(1-t).*b)); %harmonic mean
q2 = @(b,t) mu_1.*((1-t)+t.*b); % mu_bar
q3 = @(b,t) q1(b,t);
b1 = @(a,b,t) (mu_1*rho_1/4).*(b./(t+(1-t).*b)).*(1-t.*(1+a));
b2 = @(a,b,t) mu_1.*(rho_1/8).*(1-t.*(1+b.*a));
a1 = @(a,b,t) (q2(b,t).*q1(b,t).*b1(a,b,t) - q3(b,t).*q2(b,t).*b2(a,b,t))./(q1(b,t).*q2(b,t)-q3(b,t).^2);
a2 = @(a,b,t) (q1(b,t).*q2(b,t).*b2(a,b,t) - q3(b,t).*q1(b,t).*b1(a,b,t))./(q1(b,t).*q2(b,t)-q3(b,t).^2);
e = @(a,b,t) a1(a,b,t).*a2(a,b,t);
x = -20:0.2:20;
y = 0:0.1:20;
[X,Y] = meshgrid(x,y);
T = theta*ones(size(X));
V = e(X,Y,T);
V2 = h(X,Y,T);
% COLOR-Test
% C = double((V>=0));
%
% surf(X,Y,V,C, 'FaceAlpha',0.5,'EdgeColor','none')
% xlabel('alpha');
% ylabel('beta');
% axis([-20 20 0 20 -100 100])
% % colorbar
% hold on
%
% C2 = double((V2>=0));
% surf(X,Y,V2,C2,'FaceAlpha',0.5,'EdgeColor','none')
% xlabel('alpha');
% ylabel('beta');
% axis([-20 20 0 20 -100 100])
% colorbar
% mycolors = [1 0 0 ; 0 0 1];
% colormap(mycolors);
% % view(90,0)
% %plot values above zero
surf(X,Y,(V>=0).*V,'FaceAlpha',0.5,'EdgeColor','none','FaceColor','r')
xlabel('alpha');
ylabel('beta');
axis([-20 20 0 20 -100 100])
colorbar
hold on
surf(X,Y,(V<0).*V,'FaceAlpha',0.5,'EdgeColor','none','FaceColor','b')
xlabel('alpha');
ylabel('beta');
axis([-20 20 0 20 -100 100])
colorbar
% view(90,0)
hold on
surf(X,Y,(V2>=0).*V2,'FaceAlpha',0.5,'EdgeColor','none','FaceColor','black')
xlabel('alpha');
ylabel('beta');
axis([-20 20 0 20 -100 100])
colorbar
hold on
surf(X,Y,(V2<0).*V2,'FaceAlpha',0.5,'EdgeColor','none','FaceColor','g')
xlabel('alpha');
ylabel('beta');
axis([-20 20 0 20 -100 100])
colorbar
\ No newline at end of file
Matlab-Programs/singulatities.png

53.3 KiB

function [outputMatrix] = stVenant(inputMatrix,mu,lambda)
%compute symmetric gradient
symGrad = 0.5 * (inputMatrix'+ inputMatrix);
outputMatrix = 2*mu*symGrad + lambda* trace(inputMatrix)*eye(size(inputMatrix));
end
F = @(t,y) sqrt(1-y^2);
t0 = 0;
h = pi/32;
tfinal = pi/2;
y0 = 0;
ode2(F,t0,h,tfinal,y0);
\ No newline at end of file
This diff is collapsed.