Changeset 731
- Timestamp:
- 06/02/09 15:42:05 (15 years ago)
- Location:
- issm/trunk/src/m/solutions/cielo
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/m/solutions/cielo/thermal.m
r727 r731 25 25 inputs=add(inputs,'dt',m_t.parameters.dt,'double'); 26 26 27 if strcmpi(md.sub_analysis_type,'steady'), 28 29 displaystring(md.debug,'\n%s',['computing temperatures...']); 30 [t_g m_t.loads melting_offset]=thermal_core(m_t,inputs,'thermal','steady'); 31 32 displaystring(md.debug,'\n%s',['computing melting...']); 33 inputs=add(inputs,'melting_offset',melting_offset,'double'); 34 inputs=add(inputs,'temperature',t_g,'doublevec',1,m_t.parameters.numberofnodes); 35 m_g=diagnostic_core_linear(m_m,inputs,'melting','steady'); 36 37 displaystring(md.debug,'\n%s',['load results...']); 38 solution=struct('step',[],'time',[],'temperature',[],'melting',[]); 39 solution.step=1; 40 solution.time=0; 41 solution.temperature=t_g; 42 solution.melting=m_g*md.yts; %from m/s to m/a; 43 md.results.thermal=solution; 27 %call core 28 results=thermal_core(m_t,m_m,inputs,md.sub_analysis_type); 44 29 45 else 46 47 %initialize temperature and melting 48 t_g=m_t.parameters.t_g; 49 m_g=m_m.parameters.m_g; 50 nsteps=m_t.parameters.ndt/m_t.parameters.dt; 51 52 %initialize temperature and melting 53 soln.t_g=t_g; 54 soln.m_g=m_g; 55 soln.time=0; 56 57 for n=1:nsteps, 58 59 displaystring(md.debug,'\n%s%i/%i\n','time step: ',n,nsteps); 60 soln(n+1).time=n*m_t.parameters.dt; 61 62 displaystring(md.debug,'\n%s',[' computing temperatures...']); 63 inputs=add(inputs,'temperature',soln(n).t_g,'doublevec',1,m_t.parameters.numberofnodes); 64 [soln(n+1).t_g m_t.loads melting_offset]=thermal_core(m_t,inputs,'thermal','transient'); 65 66 disp(' computing melting...'); 67 inputs=add(inputs,'temperature',soln(n).t_g,'doublevec',1,m_t.parameters.numberofnodes); 68 inputs=add(inputs,'melting_offset',melting_offset,'double'); 69 soln(n+1).m_g=diagnostic_core_linear(m_m,inputs,'melting','transient'); 70 71 end 72 73 %Wrap up 74 solution=struct('step',{},'time',{},'temperature',{},'melting',{}); 75 for n=1:nsteps+1, 76 solution(n).temperature=soln(n).t_g; 77 solution(n).melting=soln(n).m_g*md.yts; %in m/year 78 solution(n).time=soln(n).time/md.yts; %in years 79 solution(n).step=n; 80 end 81 md.results.thermal=solution; 82 end 30 %plug onto the model 31 md.results.thermal=results; 83 32 84 33 %stop timing -
issm/trunk/src/m/solutions/cielo/thermal_core.m
r617 r731 1 function [t_g ,loads, melting_offset]=thermal_core(m,inputs,analysis_type,sub_analysis_type) 2 %THERMAL_CORE - core of thermal solution sequence. 3 % model is return together with temperature 4 % 1 function solution=thermal_core(m_t,m_m,inputs,sub_analysis_type) 2 %THERMAL_CORE - core of thermal solution 5 3 % 6 4 % Usage: 7 % [t_g ,loads, melting_offset]=thermal_core(m,inputs,analysis_type,sub_analysis_type); 8 % 9 % 5 % solution=thermal_core(m_t,m_m,inputs,sub_analysis_type) 10 6 11 count=1;12 converged=0;13 7 14 % we are going to return the loads, make them a variable of this routine 15 loads=m.loads; 8 if strcmpi(sub_analysis_type,'steady'), 16 9 17 %stiffness and load generation only:18 m.parameters.kflag=1; m.parameters.pflag=1;10 displaystring(m_t.parameters.debug,'\n%s',['computing temperatures...']); 11 [t_g m_t.loads melting_offset]=thermal_core_nonlinear(m_t,inputs,'thermal','steady'); 19 12 20 displaystring(m.parameters.debug,'\n%s',[' starting direct shooting method']); 21 22 while(~converged), 13 displaystring(m_t.parameters.debug,'\n%s',['computing melting...']); 14 inputs=add(inputs,'melting_offset',melting_offset,'double'); 15 inputs=add(inputs,'temperature',t_g,'doublevec',1,m_t.parameters.numberofnodes); 16 m_g=diagnostic_core_linear(m_m,inputs,'melting','steady'); 23 17 24 %Update inputs in datasets 25 [m.elements,m.nodes, loads,m.materials]=UpdateFromInputs(m.elements,m.nodes, loads,m.materials,inputs); 18 displaystring(m_t.parameters.debug,'\n%s',['load results...']); 19 solution=struct('step',[],'time',[],'temperature',[],'melting',[]); 20 solution.step=1; 21 solution.time=0; 22 solution.temperature=t_g; 23 solution.melting=m_g*m_t.parameters.yts; %from m/s to m/a; 26 24 27 %system matrices 28 if ~m.parameters.lowmem 29 if count==1 30 displaystring(m.parameters.debug,'%s',[' system matrices']); 31 [K_gg_nopenalty, p_g_nopenalty]=SystemMatrices(m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type); 32 end 33 displaystring(m.parameters.debug,'%s',[' penalty system matrices']); 34 [K_gg , p_g, melting_offset]=PenaltySystemMatrices(K_gg_nopenalty,p_g_nopenalty,m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type); 35 else 36 displaystring(m.parameters.debug,'%s',[' system matrices']); 37 [K_gg , p_g]=SystemMatrices(m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type); 38 displaystring(m.parameters.debug,'%s',[' penalty system matrices']); 39 [K_gg , p_g, melting_offset]=PenaltySystemMatrices(K_gg,p_g,m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type); 40 end 25 else 41 26 42 %Reduce tangent matrix from g size to f size 43 [K_ff, K_fs] = Reducematrixfromgtof( K_gg, m.Gmn, m.nodesets); 27 %initialize temperature and melting 28 t_g=m_t.parameters.t_g; 29 m_g=m_m.parameters.m_g; 30 nsteps=m_t.parameters.ndt/m_t.parameters.dt; 44 31 45 %Reduce load from g size to f size 46 [p_f] = Reduceloadfromgtof( p_g, m.Gmn, K_fs, m.ys, m.nodesets); 32 %initialize temperature and melting 33 soln.t_g=t_g; 34 soln.m_g=m_g; 35 soln.time=0; 47 36 48 %Solve 49 displaystring(m.parameters.debug,'%s%g',' condition number of stiffness matrix: ',condest(K_ff)); 50 [t_f]=Solver(K_ff,p_f,[],m.parameters); 37 for n=1:nsteps, 51 38 52 %Merge back to g set 53 displaystring(m.parameters.debug,'%s',[' merging solution back to g set']); 54 [t_g]= Mergesolutionfromftog( t_f, m.Gmn, m.ys, m.nodesets ); 39 displaystring(m_t.parameters.debug,'\n%s%i/%i\n','time step: ',n,nsteps); 40 soln(n+1).time=n*m_t.parameters.dt; 55 41 56 %Update inputs in datasets 57 inputs=add(inputs,'temperature',t_g,'doublevec',m.parameters.numberofdofspernode,m.parameters.numberofnodes); 58 displaystring(m.parameters.debug,'%s',[' update inputs']); 59 [m.elements,m.nodes, loads,m.materials]=UpdateFromInputs(m.elements,m.nodes, loads,m.materials,inputs); 60 61 %penalty constraints 62 displaystring(m.parameters.debug,'%s',[' penalty constraints']); 63 [loads,constraints_converged,num_unstable_constraints] =PenaltyConstraints( m.elements,m.nodes, loads, m.materials,m.parameters,inputs,analysis_type,sub_analysis_type); 64 65 if ~converged, 66 displaystring(m.parameters.debug,'%s%i',' #unstable constraints ',num_unstable_constraints); 67 68 if num_unstable_constraints<=m.parameters.min_thermal_constraints, 69 converged=1; 70 end 71 end 42 displaystring(m_t.parameters.debug,'\n%s',[' computing temperatures...']); 43 inputs=add(inputs,'temperature',soln(n).t_g,'doublevec',1,m_t.parameters.numberofnodes); 44 [soln(n+1).t_g m_t.loads melting_offset]=thermal_core_nonlinear(m_t,inputs,'thermal','transient'); 72 45 73 count=count+1; 46 disp(' computing melting...'); 47 inputs=add(inputs,'temperature',soln(n).t_g,'doublevec',1,m_t.parameters.numberofnodes); 48 inputs=add(inputs,'melting_offset',melting_offset,'double'); 49 soln(n+1).m_g=diagnostic_core_linear(m_m,inputs,'melting','transient'); 50 74 51 end 75 52 53 %Wrap up 54 solution=struct('step',{},'time',{},'temperature',{},'melting',{}); 55 for n=1:nsteps+1, 56 solution(n).temperature=soln(n).t_g; 57 solution(n).melting=soln(n).m_g*m_t.parameters.yts; %in m/year 58 solution(n).time=soln(n).time/m_t.parameters.yts; %in years 59 solution(n).step=n; 60 end 76 61 end
Note:
See TracChangeset
for help on using the changeset viewer.