diff --git a/BondOrderScript.m b/BondOrderScript.m index cbe0b93..c08a618 100644 --- a/BondOrderScript.m +++ b/BondOrderScript.m @@ -2,14 +2,40 @@ % % while false -%% Run multiple molecules +%% Get already-run calcs with a given file prefix +field = []; +if (true) + fn = '17-merPPV'; + + flist = dir('s:\NoAngle\*.mat'); + for i = 1:length(flist) + fstr = regexpi(flist(i).name, ['^',fn,'-([0-9.]+)VA\.mat$'], 'tokens'); + if (~isempty(fstr)) + field(end+1) = str2double(fstr{1}{1}); + end + end + + field = sort(field,'ascend'); + + S = load(['s:\NoAngle\',fn,'-0VA.mat']); + + mols = {fn,field(end),S.obj.axis_params}; +else -mols = {'8-merPPV-ampac101-N2Opt',.176,[59 62]}; -nstates = 25; + +% If you didn't load the data from above, insert data to run here (or Run multiple molecules) + mols = {'17-merPPV',.068,[3 134]}; +end + +%% Set other params and run + +sysvars = ECESysVars.getInstance('init','indo','c:\mscpp\demo-dci-working.exe'); + +nstates = 10; norbs = 1000; -poolsize = 3; +poolsize = sysvars.getVars('poolsize'); -run_energy_calcs = true; +run_energy_calcs = false; load_data = true; run_struct_opt = false; @@ -17,6 +43,8 @@ matlabpool(poolsize); end + %% Do calculations + for imol = 1:size(mols, 1); % system('subst s: /d'); % system('subst o: /d'); @@ -30,12 +58,14 @@ % system(['subst s: "',rootdir,SFolder,'"']); % system(['subst o: "',rootdir,OFolder,'"']); % system(['subst p: "',rootdir,PFolder,'"']); - - field = 0:0.001:mols{imol,2}; - % field = [0:0.001:0.045, 0.0452:0.0002:0.065, 0.066:0.001:mols{imol,2}]; + if (isempty(field)) + field = 0:0.001:mols{imol,2}; + %field = [0:0.001:0.054, 0.0542:0.0002:0.083, 0.084:0.001:mols{imol,2}]; + %field = [0:0.001:0.054, 0.0542:0.0002:mols{imol,2}]; + end -%% Are you loading pre-existing data? Set this to false. +%% Running calculations if (run_energy_calcs) %% @@ -58,7 +88,7 @@ disp(num2str(field(k))); myece = ECEParams('AM1', {}, true, field(k), norbs, nstates,... - [pwd,'\data\params_for_all.txt']); + [pwd,'\..\data\params_for_all.txt']); myexp = EnergyCalcExp(myece,... ['s:\NoAngle\',mols{imol,1},'.dat'],... @@ -67,7 +97,8 @@ 'o:\',... 'p:\',... false,... - ['MeLPPP-13mer Field calcs - ',num2str(field(k)),'VA']); + ['MeLPPP-13mer Field calcs - ',num2str(field(k)),'VA'],... + sysvars); myexp.run('quiet'); no_field_dm = ['o:\', myexp.data(1).indo_hash, '-dm.bin']; @@ -86,7 +117,7 @@ continue; else myece = ECEParams('AM1', {}, true, field(pk), norbs, nstates,... - [pwd,'\data\params_for_all.txt']); + [pwd,'\..\data\params_for_all.txt']); if (~isempty(no_field_dm)) myece.dm_guess = no_field_dm; @@ -100,7 +131,8 @@ 'o:\',... 'p:\',... false,... - ['MeLPPP-13mer Field Calcs - ',num2str(field(pk)),'VA']); + ['MeLPPP-13mer Field Calcs - ',num2str(field(pk)),'VA'],... + sysvars); pmyexp.run('quiet'); end % if (~exist('n','var')) @@ -112,10 +144,13 @@ %% Doing calcs? Terminate end % close(waithdl,'force'); -%% Skip data loading because you're doing BOBL opt? Set to false +%% Loading data that's been calculated already +try % If this fails, it will close the progress bar window and rethrow the error if (load_data) - -%% Load data that's been calculated already + +S = load(['s:\NoAngle\',mols{imol,1},'-',num2str(field(1)),'VA.mat']); +myexp = S.obj; +nstates = length(myexp.data(1).Eexc); dp = zeros(1,length(field)); dpgs = zeros(1,length(field)); @@ -155,6 +190,7 @@ S = load(['s:\NoAngle\',mols{imol,1},'-',num2str(field(idx)),'VA.mat']); myexp = S.obj; + myexp.data(1).update_paths('p:\','o:\'); tmp = myexp.get_field('indo.dipole',1,1); dpgs(idx) = sum(tmp .^ 2, 1) .^ (0.5); @@ -185,8 +221,8 @@ eexc(idx,1:nstates) = myexp.get_field('Eexc',:); igs(idx) = myexp.get_field('indo.esci',1); opint(idx,1:nstates) = myexp.get_field('Tint',:); -% tmp = squeeze(myexp.get_field('indo.r',2,:,:)); % From n=2 -% midx = 2; % for n=2 + tmp = squeeze(myexp.get_field('indo.r',2,:,:)); % From n=2 + midx = 2; % for n=2 % for l = 1:nstates % tmpeexc = eexc(idx,1:nstates); % [~,midx] = max(opint(idx,1:nstates)); @@ -195,6 +231,7 @@ % end % end + close(waithdl,'force'); % Make all cells because cross-compatibility with code @@ -225,15 +262,16 @@ end - +catch excpt + if (exist('waithdl','var') && ishandle(waithdl)) + close(waithdl,'force'); + end + rethrow(excpt) end - -%% Skip structure opt? Debugging? +%% Structure optimization if (run_struct_opt) -%% Do structure optimizations - % fields_to_opt_struct = field; fields_to_opt_struct = 0; @@ -320,6 +358,7 @@ save(['s:\',mols{imol,1},'-BOScript-PaulingwithAM1.mat']); +end end disp('Calculation finished'); @@ -336,15 +375,22 @@ nstates = length(eexc{1,1}(k,:)); end +statesx = zeros(length(xaxis)*nstates,1); +statesy = statesx; for k = 1:length(xaxis) - plot(xaxis(k), eexc{1,1}(k,1:nstates) + igs{1,1}(k) - igs{1,1}(1), 'g^'); + statesx(((k-1)*nstates)+(1:nstates)) = xaxis(k); + statesy(((k-1)*nstates)+(1:nstates)) = eexc{1,1}(k,1:nstates) + igs{1,1}(k) - igs{1,1}(1); end +ptshnd = plot(statesx, statesy, 'g.','MarkerSize',6); + +opinthnd = zeros(length(xaxis),nstates); maxopint = max(opint{1,1}(:)); for k = 1:length(xaxis) for l = 1:nstates - if (opint{1,1}(k,l)*30/maxopint > 1) - plot(xaxis(k), eexc{1,1}(k,l) + igs{1,1}(k) - igs{1,1}(1), 'bo', 'MarkerSize', (opint{1,1}(k,l)*30 / maxopint) + 1e-3); + if (sqrt((opint{1,1}(k,l)*50 / maxopint)) > 1) + opinthnd(k,l) = plot(xaxis(k), eexc{1,1}(k,l) + igs{1,1}(k) - igs{1,1}(1), 'bo',... + 'MarkerSize', sqrt((opint{1,1}(k,l)*50 / maxopint)) + 1e-3); end end end @@ -446,36 +492,88 @@ get_slope_from_n2_after_cross = true; use_n2_at_zero_for_eb = true; hold_nofield_energy = false; +clear_plots = false; -if (exist('ebhnd','var') && ishandle(ebhnd)) - delete(ebhnd); +if (clear_plots) + if (exist('ebhndlin','var')) + for i = 1:length(ebhndlin) + delete(ebhndlin(i)); + end + end + if (exist('ebhndquad','var')) + for i = 1:length(ebhndquad) + delete(ebhndquad(i)); + end + end end figure(8); hold on; if (get_slope_from_n2_after_cross) + bail=false; dcm_obj = datacursormode(8); for i = 1:2 disp(['Pick point ',num2str(i),' with the data cursor and then type return']); figure(8); keyboard; + if (bail) + return; + end info_struct = getCursorInfo(dcm_obj); - pts(i) = info_struct.Position(1); + x_pts(i) = info_struct.Position(1); + y_pts(i) = info_struct.Position(2); end - start_idx = find(field == pts(1)); - end_idx = find(field == pts(2)); + start_idx = find(field == x_pts(1)); + end_idx = find(field == x_pts(2)); + + n_start = find(eexc{1}(start_idx,:)+ igs{1,1}(start_idx) - igs{1,1}(1)==y_pts(1)); + n_end = find(eexc{1}(end_idx,:)+ igs{1,1}(end_idx) - igs{1,1}(1)==y_pts(2)); + if (n_start ~= n_end) + disp('State n values are not the same for range selected!'); + return; + end x = field(start_idx:end_idx)'; - y = eexc{1}(start_idx:end_idx,2) + igs{1,1}(start_idx:end_idx)' - igs{1,1}(1); + y = eexc{1}(start_idx:end_idx,n_start) + igs{1,1}(start_idx:end_idx)' - igs{1,1}(1); else - [x,y] = ginput(3); + % [x,y] = ginput(3); + dcm_obj = datacursormode(8); + done = false; + bail = false; + dontinclude = false; + ii=1; + x=[]; + y=[]; + while ~done + disp(['Pick point ',num2str(ii),' with the data cursor and then type return']); + figure(8); + keyboard; + if (bail) + return; + end + if (~dontinclude || ~done) + info_struct = getCursorInfo(dcm_obj); + x(ii) = info_struct.Position(1); + y(ii) = info_struct.Position(2); + ii=ii+1; + end + end end fit = polyfit(x,y,1); m = fit(1); +yint = fit(2); + +fit = polyfit(x,y,2); +a = fit(1); b = fit(2); +c = fit(3); + +cubicfit = polyfit(x,y,3); +quartfit = polyfit(x,y,4); +fivefit = polyfit(x,y,5); if (~hold_nofield_energy || ~exist('eby','var')) if (use_n2_at_zero_for_eb) @@ -485,11 +583,24 @@ end end -ebenergy = b-eby; +ebenergy = yint-eby; -ebhnd = plot(xaxis, m .* xaxis + b, 'k-'); - -disp(['The equation of the line is ',num2str(m),'x + ',num2str(b)]); +if (exist('ebhndlin','var')) + plotnum = length(ebhndlin)+1; +else + plotnum = 1; +end +figure(8); +% ebhndlin(plotnum) = plot(xaxis, m .* xaxis + yint, 'k-'); +% ebhndquad(plotnum) = plot(xaxis, a.*xaxis.^2 + b.*xaxis + c, 'r-'); +% plot(xaxis, cubicfit(1).*xaxis.^3 + cubicfit(2).*xaxis.^2 + cubicfit(3).*xaxis + cubicfit(4), 'c-'); +% plot(xaxis, quartfit(1).*xaxis.^4 + quartfit(2).*xaxis.^3 + quartfit(3).*xaxis.^2 + quartfit(4).*xaxis + quartfit(5), 'k-'); +plot(xaxis, fivefit(1).*xaxis.^5 + fivefit(2).*xaxis.^4 + ... + fivefit(3).*xaxis.^3 + fivefit(4).*xaxis.^2 + fivefit(5).*xaxis + fivefit(6), 'r-'); +% plot(xaxis, sixfit(1).*xaxis.^6 + sixfit(2).*xaxis.^5 + ... +% sixfit(3).*xaxis.^4 + sixfit(4).*xaxis.^3 + sixfit(5).*xaxis.^2 + sixfit(6).*xaxis + sixfit(7), 'r-'); + +disp(['The equation of the line is ',num2str(m),'x + ',num2str(yint)]); disp(['The dipole moment of this state is ',num2str(-m),' e-A (',num2str(-m*4.802456),' D)']); disp(['The exciton binding energy is approximately ', num2str(ebenergy), ' eV']); @@ -642,21 +753,24 @@ fignum = 5; exciton = false; -mol_name = '8-merPPV-N2Opt'; +mol_name = '17-merPPV'; pick_a_point = true; % If pick_a_point, the following will be overwritten field_strength = 0; -state_n = 2; +state_n = 22; % Put how your y-axis is plotted here. Otherwise set y_offset = 0 for % absolute energies. S = load(['s:\NoAngle\',mol_name,'-0VA.mat']); myexp = S.obj; +myexp.data(1).update_paths('p:\','o:\'); myexp.data(1).load_to_memory('indo','load'); myindo = myexp.data(1).raw_indo; y_offset = myindo.esci(1); +centroid_offset = [0 0 11]; + % Graphing charge density binsize = 2; % Angstroms. +- amount for bin capture dr = 0.05; % How many angstroms to incrememnt for bin center @@ -681,7 +795,7 @@ S = load(['s:\NoAngle\',mol_name,'-',num2str(field_strength),'VA.mat']); myexp = S.obj; - +myexp.data(1).update_paths('p:\','o:\'); myexp.data(1).load_to_memory('indo','load'); myindo = myexp.data(1).raw_indo; @@ -717,11 +831,13 @@ % esdm = gsdm + deltadm; -% Uses a similar script to extract the Cartesian coords of using openbabel. atom_type contains the chemical symbol of each atom -myexp.data(1).generate_ampac_file('out','p:\'); -[xyz, atom_type] = ampac_to_xyz(['p:\', myexp.data(1).ampac_hash, '.out']); % Ground state -zmat = ampac_to_zmatrix(['p:\', myexp.data(1).ampac_hash, '.out']); -% atomsbonds = get_connectivity(['p:\', myexp.data(1).ampac_hash, '.out']); % Takes path to mopac/ampac file +% Get cartesian coordinates from ampac +if (~exist('last_mol_run','var') || ~strcmpi(myexp.data(1).ampac_hash, last_mol_run)) + myexp.data(1).generate_ampac_file('out','p:\'); + [xyz, atom_type] = ampac_to_xyz(['p:\', myexp.data(1).ampac_hash, '.out']); % Ground state + zmat = ampac_to_zmatrix(['p:\', myexp.data(1).ampac_hash, '.out']); + last_mol_run = myexp.data(1).ampac_hash; +end % Mulliken charge mchg = zeros(1,length(xyz)); @@ -767,7 +883,6 @@ hold on; axis equal; axis([min(rot_xyz(:,1))-1 max(rot_xyz(:,1))+1 min(rot_xyz(:,2))-1 max(rot_xyz(:,2))+1 min(rot_xyz(:,3))-1 max(rot_xyz(:,3))+1]); -camorbit(0,270); cptcmap('scaled_mulliken','mapping','direct') scatter3(rot_xyz(:,1),rot_xyz(:,2),rot_xyz(:,3),120,mchg*1e3/max(abs(mchg)),'o','filled','MarkerEdgeColor','k') @@ -785,7 +900,7 @@ else carr = [1 0 0]; end -harr = arrow(centroid+[0 0 10],centroid'+[0 0 10]'+rotmat*tdv','Width',3,'FaceColor',carr); +harr = arrow(centroid+centroid_offset,centroid'+centroid_offset'+rotmat*tdv','Width',3,'FaceColor',carr); % Graph of spatial distribution of charges diff --git a/BondOrderScript_JKLDrives.m b/BondOrderScript_JKLDrives.m index 4edc12f..61c2e83 100644 --- a/BondOrderScript_JKLDrives.m +++ b/BondOrderScript_JKLDrives.m @@ -1,13 +1,35 @@ -% %% DON'T RUN FROM HERE -% -% while false +%% Get already-run calcs with a given file prefix +field = []; + +if (true) + fn = '8-merPPV-N2Optimized'; + + + flist = dir('j:\NoAngle\*.mat'); + for i = 1:length(flist) + fstr = regexpi(flist(i).name, ['^',fn,'-([0-9.]+)VA\.mat$'], 'tokens'); + if (~isempty(fstr)) + field(end+1) = str2double(fstr{1}{1}); + end + end + + field = sort(field,'ascend'); + + S = load(['j:\NoAngle\',fn,'-0VA.mat']); -%% Run multiple molecules + mols = {fn,field(end),S.obj.axis_params}; +else + + +%% If you didn't load the data from above, insert data to run here (or Run multiple molecules) + mols = {'15-merPPV-N2Optimized',.083,[3 118]}; +end + +%% Set other params and run -mols = {'MeLPPP-13mer',.064,[1 186]}; nstates = 25; norbs = 1000; -poolsize = 7; +poolsize = 3; run_energy_calcs = false; load_data = true; @@ -30,10 +52,11 @@ % system(['subst s: "',rootdir,SFolder,'"']); % system(['subst o: "',rootdir,OFolder,'"']); % system(['subst p: "',rootdir,PFolder,'"']); - - field = 0:0.001:mols{imol,2}; - % field = [0:0.001:0.045, 0.0452:0.0002:0.065, 0.066:0.001:mols{imol,2}]; - + if (isempty(field)) + field = 0:0.001:mols{imol,2}; + %field = [0:0.001:0.054, 0.0542:0.0002:0.083, 0.084:0.001:mols{imol,2}]; + %field = [0:0.001:0.054, 0.0542:0.0002:mols{imol,2}]; + end %% Are you loading pre-existing data? Set this to false. if (run_energy_calcs) diff --git a/EnergyCalcExp.m b/EnergyCalcExp.m index 260751d..5723f91 100644 --- a/EnergyCalcExp.m +++ b/EnergyCalcExp.m @@ -39,7 +39,8 @@ fail_iterator; % unsigned int: keeps track of the next index available in fail_bucket. % length(fail_bucket) = m = fail_iterator - 1 - ampacexe = '"c:\Program Files\Semichem, Inc\Ampac-10.1\ampac.exe"'; % Path to the AMPAC executable, including " marks + sysvars; % Contains paths to ampac and indo and other info for the system that runs this calculation + ampacexe; % Ampac path with leading and trailing " marks end properties (SetAccess = public) @@ -371,14 +372,8 @@ % Output: % obj: EnergyCalcExp object. The constructed object. %--------------------------------------------------------------------------------------------------% - function obj = EnergyCalcExp(parameters, mol, axis_params, MAT, indo, ampac, load_libs, varargin) - if (~exist('c:\Program Files\Semichem, Inc\Ampac-10.1\ampac.exe','file')) - if (exist('c:\Program Files (x86)\Semichem, Inc\Ampac-10.1\ampac.exe','file')) - obj.ampacexe = '"c:\Program Files (x86)\Semichem, Inc\Ampac-10.1\ampac.exe"'; - else - throw(MException('EnergyCalcExp:InvalidAmpacPath','EnergyCalcExp: Cannot find AMPAC! Update path')); - end - end + function obj = EnergyCalcExp(parameters, mol, axis_params, MAT, indo, ampac, load_libs, description, sysvars) + if (nargin > 4) % pause(0.02); % Hard drive delay catch-up... if (~exist(mol,'file')) @@ -390,10 +385,18 @@ obj.MATFilename = MAT; obj.molecule = mol; obj.axis_params = axis_params; + obj.description = description; - if (~isempty(varargin)) - obj.description = varargin{1}; + if (~isempty(sysvars)) + obj.sysvars = sysvars; + else + obj.sysvars = ECESysVars.getInstance; + warning('off','ECESysVars:AlreadyInit'); + obj.sysvars.initialize; + warning('on','ECESysVars:AlreadyInit'); end + + obj.ampacexe = ['"',sysvars.getVars('ampac'),'"']; if (indo(end) ~= '\') indo = [indo, '\']; @@ -665,7 +668,7 @@ tmp_indo_path = tmp_indo_path(1:end-1); end - indo = Indo(indoparams, tmp_ampac_path, ampac.hash, tmp_indo_path, indo_out.hash); + indo = Indo(indoparams, tmp_ampac_path, ampac.hash, tmp_indo_path, indo_out.hash, obj.sysvars); % % if (indoparams.output_dm) % movefile([obj.ampacdatapath, ampac.hash, '-dm.bin'], ... @@ -1501,7 +1504,7 @@ tmp_indo_path = tmp_indo_path(1:end-1); end - indo = Indo(indoparams, tmp_ampac_path, ampac.hash, tmp_indo_path, indo_out.hash); + indo = Indo(indoparams, tmp_ampac_path, ampac.hash, tmp_indo_path, indo_out.hash, obj.sysvars); indo_out.indo = indo; diff --git a/Indo.m b/Indo.m index dd4e0d7..1cb22b1 100644 --- a/Indo.m +++ b/Indo.m @@ -31,8 +31,7 @@ ehsci % (i,1) hole of the ith SCI basis function (0 if GS) % (i,2) = elec of the ith SCI basis function (0 if GS) - indoExe = '"c:\mscpp\demo-dci-working.exe"'; - % indoExe = '"c:\mscpp\demo-dci\Release\demo-dci.exe"'; + indoExe; % Path to INDO exe end % properties properties (Transient) osc % (1,i) oscillator strength from gs to state i @@ -159,7 +158,8 @@ function readIndo(obj, inputfile) end end methods - function res = Indo(ConfigIn, dataPathIn, jobNameIn, varargin) + function res = Indo(ConfigIn, dataPathIn, jobNameIn, dataPathOut, jobNameOut, sysvars) + if (nargin < 1) res.config = Indo.defaultConfig(); else @@ -178,13 +178,21 @@ function readIndo(obj, inputfile) if (nargin < 4) res.dataPathOut = res.dataPathIn; else - res.dataPathOut = varargin{1}; + res.dataPathOut = dataPathOut; end if (nargin < 5) res.jobNameOut = res.jobNameIn; else - res.jobNameOut = varargin{2}; + res.jobNameOut = jobNameOut; + end + if (nargin < 6) + sysvars = ECESysVars.getInstance; + warning('off','ECESysVars:AlreadyInit'); + sysvars.initialize; + warning('on','ECESysVars:AlreadyInit'); end + res.indoExe = ['"',sysvars.getVars('indo'),'"']; + if (nargin > 0) % jobstring = [res.indoExe,' "',res.dataPath,'\',res.jobName,'"', ... % ' ',num2str(res.config.charge), ... diff --git a/LoadPPVData.m b/LoadPPVData.m index 890dbda..47c26f5 100644 --- a/LoadPPVData.m +++ b/LoadPPVData.m @@ -2,58 +2,58 @@ %% 6-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\6-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\6-merPPV\'; mat_file_path = {'..\6-merPPV-EvsF.mat'}; %% 7-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\7-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\7-merPPV\'; mat_file_path = {'..\7-merPPV-EvsF.mat'}; %% 8-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\8-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\8-merPPV\'; mat_file_path = {'..\8-merPPV-EvsF.mat'}; %% 9-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\9-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\9-merPPV\'; mat_file_path = {'..\9-merPPV-EvsF.mat'}; %% 10-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\10-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\10-merPPV\'; mat_file_path = {'..\10-merPPV-EvsF.mat'}; %% 13-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\13-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\13-merPPV\'; mat_file_path = {'..\13-merPPV-EvsF.mat'}; %% 15-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\15-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\15-merPPV\'; mat_file_path = {'..\15-merPPV-EvsF.mat'}; %% 17-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\17-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\17-merPPV\'; mat_file_path = {'..\17-merPPV-EvsF.mat'}; %% 20-mer PPV Unrelaxed -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\20-merPPV\'; +loadrootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\20-merPPV\'; mat_file_path = {'..\20-merPPV-EvsF.mat'}; %% Load data here -if (rootdir(end) ~= '\') - rootdir = [rootdir, '\']; +if (loadrootdir(end) ~= '\') + loadrootdir = [loadrootdir, '\']; end for i = 1:length(mat_file_path) - load([rootdir, mat_file_path{i}]); + load([loadrootdir, mat_file_path{i}]); end if (strcmpi(myexp.ampacdatapath, 'p:\')) @@ -70,10 +70,10 @@ OFolder = 'INDOLib'; PFolder = 'GSLib'; -system('subst ',expt,': /d'); -system('subst ',indo,': /d'); -system('subst ',ampac,': /d'); +system(['subst ',expt,': /d']); +system(['subst ',indo,': /d']); +system(['subst ',ampac,': /d']); -system(['subst ',expt,': "',rootdir,SFolder,'"']); -system(['subst ',indo,': "',rootdir,OFolder,'"']); -system(['subst ',ampac,': "',rootdir,PFolder,'"']); \ No newline at end of file +system(['subst ',expt,': "',loadrootdir,SFolder,'"']); +system(['subst ',indo,': "',loadrootdir,OFolder,'"']); +system(['subst ',ampac,': "',loadrootdir,PFolder,'"']); \ No newline at end of file diff --git a/OptExcStateStructure.m b/OptExcStateStructure.m index d0cf47d..ecb1c13 100644 --- a/OptExcStateStructure.m +++ b/OptExcStateStructure.m @@ -4,10 +4,12 @@ % ampac_pathonly = 'C:\Users\Christian\Documents\Research\Yaron\dyes2\data\DMG-8mer\'; % ampac_nameonly = '8-merPPVampac'; - - % EXECUTABLE PATHWAYS, NO QUOTES - AmpacEXE = 'C:\Program Files\Semichem, Inc\Ampac-10.1\ampac.exe'; - OpenBabelEXE = 'C:\Program Files (x86)\OpenBabel-2.3.2\babel.exe'; + if (~ECE_system_vars('check')) + ECE_system_vars('setall'); + end + + global AMPACEXE; + AmpacEXE = AMPACEXE; indoidx = find(cellfun(@(x)isequal(lower(x),'indo'), varargin)); diff --git a/SetUpSubstDrives.m b/SetUpSubstDrives.m index e46d97d..d85f918 100644 --- a/SetUpSubstDrives.m +++ b/SetUpSubstDrives.m @@ -8,7 +8,8 @@ %% Load substituted drives -rootdir = fullfile(pwd,'data\8-merPPV-newampac\Coupling'); +rootdir = fullfile(pwd,'..\data\17-merPPV\'); +% rootdir = fullfile('C:\Users\clegaspi\Documents\MATLAB\data\13-merPPV\'); SFolder = 'Exp'; OFolder = 'INDOLib'; PFolder = 'GSLib'; @@ -18,7 +19,12 @@ end if (~exist(rootdir,'dir')) - mkdir(rootdir); + response = questdlg('This directory does not exist. Create?','Dir DNE','Yes','No','Yes'); + if (strcmp(response,'Yes')) + mkdir(rootdir); + else + return; + end end if (~exist([rootdir,SFolder],'dir')) mkdir([rootdir,SFolder]); @@ -46,7 +52,7 @@ %% Load substituted drives -rootdir = 'C:\Users\clegaspi\Documents\MATLAB\data\MeLPPP-13mer\'; +rootdir = fullfile(pwd,'..\data\PFH-13mer-N2Opt\'); SFolder = 'Exp'; OFolder = 'INDOLib'; PFolder = 'GSLib'; @@ -56,7 +62,12 @@ end if (~exist(rootdir,'dir')) - mkdir(rootdir); + response = questdlg('This directory does not exist. Create?','Dir DNE','Yes','No','Yes'); + if (strcmp(response,'Yes')) + mkdir(rootdir); + else + return; + end end if (~exist([rootdir,SFolder],'dir')) mkdir([rootdir,SFolder]); diff --git a/ampac_to_xyz.m b/ampac_to_xyz.m index ddda18b..fcc9547 100644 --- a/ampac_to_xyz.m +++ b/ampac_to_xyz.m @@ -2,16 +2,8 @@ %AMPAC_TO_XYZ Summary of this function goes here % Detailed explanation goes here - % OpenBabelEXE = 'C:\Program Files (x86)\OpenBabel-2.3.2\babel.exe'; - ampacexe = 'C:\Program Files\Semichem, Inc.\Ampac-10.1\ampac.exe'; - - if (~exist(ampacexe, 'file')) - if (exist('C:\Program Files (x86)\Semichem, Inc.\Ampac-10.1\ampac.exe', 'file')) - ampacexe = 'C:\Program Files (x86)\Semichem, Inc.\Ampac-10.1\ampac.exe'; - else - throw(MException('ampac_to_xyz:AmpacNotFound', 'ampac_to_xyz: AMPAC EXE not found. Please edit.')); - end - end + sysvars = ECESysVars.getInstance; + ampacexe = sysvars.getVars('ampac'); if (iscell(input)) zmatrix = input; diff --git a/closest_member.m b/closest_member.m index d8c9464..dbc4f93 100644 --- a/closest_member.m +++ b/closest_member.m @@ -15,9 +15,9 @@ [b,ix] = sort(myset,'ascend'); for i = 1:length(b) - if (b(i) < a) + if (b(i) < a && i < length(b)) continue; - elseif (b(i) == a) + elseif (b(i) == a || (b(i) < a && i == length(b))) varargout{1} = b(i); switch nargout case 2 diff --git a/distort_geometry.m b/distort_geometry.m index dbaed0d..bd5e38d 100644 --- a/distort_geometry.m +++ b/distort_geometry.m @@ -1,5 +1,11 @@ function newzmatrix = distort_geometry(zmatrix, ring_info, newblsbyatom, varargin) - AmpacEXE = 'C:\Program Files\Semichem, Inc\Ampac-10.1\ampac.exe'; + if (~ECE_system_vars('check')) + ECE_system_vars('setall'); + end + + global AMPACEXE; + AmpacEXE = AMPACEXE; + newzmatrix = zmatrix; natoms = size(zmatrix, 1); rings = {ring_info.rings}; diff --git a/import_fluor.m b/import_fluor.m index 543efad..063f559 100644 --- a/import_fluor.m +++ b/import_fluor.m @@ -1,4 +1,4 @@ -function [Wavelengthnm,VarName2] = import_fluor(filename, startRow, endRow) +function [wl,cps] = import_fluor(filename, startRow, endRow) %IMPORTFILE Import numeric data from a text file as column vectors. % [WAVELENGTHNM,VARNAME2] = IMPORTFILE(FILENAME) Reads data from text % file FILENAME for the default selection. @@ -20,27 +20,36 @@ endRow = inf; end +%% Open the text file. +fileID = fopen(filename,'r'); + +%% Figure out how many spectra are contained in this file + +firstline = textscan(fileID, '%s',1,'delimiter','\n'); +frewind(fileID); +nexpts = regexpi(firstline{1},'Expt\s+(\d+),*\s*$','tokens'); + +if (isempty(nexpts{1})) + nexpts = 1; +else + nexpts = str2double(nexpts{1}{1}); + startRow = 3; +end + %% Format string for each line of text: % column1: double (%f) % column2: double (%f) % For more information, see the TEXTSCAN documentation. -formatSpec = '%f%f%[^\n\r]'; - -%% Open the text file. -fileID = fopen(filename,'r'); +formatSpec = '%[^\n\r]'; +for i = 1:nexpts + formatSpec = ['%f%f' formatSpec]; +end %% Read columns of data according to format string. % This call is based on the structure of the file used to generate this % code. If an error occurs for a different file, try regenerating the code % from the Import Tool. dataArray = textscan(fileID, formatSpec, endRow(1)-startRow(1)+1, 'Delimiter', delimiter, 'HeaderLines', startRow(1)-1, 'ReturnOnError', false); -for block=2:length(startRow) - frewind(fileID); - dataArrayBlock = textscan(fileID, formatSpec, endRow(block)-startRow(block)+1, 'Delimiter', delimiter, 'HeaderLines', startRow(block)-1, 'ReturnOnError', false); - for col=1:length(dataArray) - dataArray{col} = [dataArray{col};dataArrayBlock{col}]; - end -end %% Close the text file. fclose(fileID); @@ -52,6 +61,10 @@ % script. %% Allocate imported array to column variable names -Wavelengthnm = dataArray{:, 1}; -VarName2 = dataArray{:, 2}; +wl = zeros(length(dataArray{1}),nexpts); +cps = zeros(length(dataArray{1}),nexpts); +for i = 1:nexpts + wl(:,i) = dataArray{2*i-1}; + cps(:,i) = dataArray{2*i}; +end diff --git a/import_fluor_by_dialog.m b/import_fluor_by_dialog.m index 2689003..842188a 100644 --- a/import_fluor_by_dialog.m +++ b/import_fluor_by_dialog.m @@ -1,42 +1,75 @@ %% Import data -fignum = 11; -wavenum = 1; +append_data = 1; +fignum = 5; +wavenum = 0; if (~exist('em_last_path', 'var')) em_last_path = pwd; end -[fn,path,~] = uigetfile([em_last_path,'\*.csv'],'Select data','MultiSelect','on'); -if (~iscell(fn)) - if (fn==0) +[tfn,path,~] = uigetfile([em_last_path,'\*.csv'],'Select data','MultiSelect','on'); + +if (~iscell(tfn)) + if (tfn==0) return; end - fn = {fn}; + tfn = {tfn}; +end + +if (append_data) + fn = [fn tfn]; +else + fn = tfn; end em_last_path = path; -emwl = cell(1,length(fn)); -emdata = emwl; +if (~append_data) + emwl = cell(1,length(fn)); + emdata = emwl; + start = 1; +else + start = length(emwl)+1; + emwl = [emwl cell(1,length(tfn))]; + emdata = [emdata cell(1,length(tfn))]; +end -for i = 1:length(fn); +for i = start:(start+length(tfn)-1) [emwl{i}, emdata{i}] = import_fluor([path,fn{i}]); + if (size(emdata{i},2) > 1) + emdata{i} = mean(emdata{i},2); % Average if we have multiple runs + emwl{i} = emwl{i}(:,1); % Collapse wl to 1D + end end %% Plot +if (~append_data && ishandle(fignum)) + clf(fignum); + sidx = 1; + eidx = length(emwl); +elseif (append_data && ishandle(fignum)) + sidx = start; + eidx = start+length(fn)-1; +else + sidx = 1; + eidx = length(emwl); +end + figure(fignum); hold on color = 'rgbkmc'; pattern = {'-',':','--','-.','-',':','--','-.'}; -for i = 1:length(fn) +for i = sidx:eidx if (wavenum) x = 1e7./emwl{i}; else x = emwl{i}; end - plot(x,emdata{i}, 'LineStyle', pattern{floor((i-1)/length(color))+1} , 'LineWidth', 2, ... - 'Color',color(mod(i-1,length(color))+1),... - 'DisplayName', fn{i}); + htmp = plot(x,emdata{i}, 'LineStyle', pattern{floor((i-1)/length(color))+1} , 'LineWidth', 2, ... + 'Color',color(mod(i-1,length(color))+1)); + if (length(fn)>=i-sidx+1) + set(htmp,'DisplayName', fn{i-sidx+1}); + end end if (wavenum) @@ -45,4 +78,6 @@ xlabel('Wavelength (nm)'); end ylabel('Intensity (cps)'); -legend('show'); \ No newline at end of file +if (~append_data) + legend('show','-DynamicLegend'); +end \ No newline at end of file diff --git a/import_myfluor_script.m b/import_myfluor_script.m index a4c64dc..046ddcf 100644 --- a/import_myfluor_script.m +++ b/import_myfluor_script.m @@ -1,10 +1,10 @@ -uiippath = 'C:\Users\clegaspi\Google Drive\Experimental Data\Fluorometer\092413'; -fn = 'methft'; -fignum = 12; +path = 'C:\Users\clegaspi\Google Drive\Experimental Data\Fluorometer\112113\2TD1X'; +fn = '2tdeb'; +fignum = 10; wavenum = 0; legend_str = 'Ex '; -wl_range = 200:10:600; +wl_range = 200:10:450; n = length(wl_range); %% @@ -22,22 +22,41 @@ end %% +if (ishandle(fignum)) + clf(fignum,'reset'); +end figure(fignum); hold on color = 'rgbkmc'; pattern = {'-',':','--','-.','-',':','--','-.'}; -for i = 1:10 +for i = 1:n if (wavenum) x = 1e7./wl{i}; else x = wl{i}; end - plot(x,data{i}, 'LineStyle', pattern{floor((i-1)/length(color))+1} , 'LineWidth', 2, ... + + nidx = find(x == 350); + x = x(nidx:end); + y = data{i}(nidx:end); + + nval = 1; + % nidx = find(x == 439); + % nval = data{i}(nidx); + nval = max(y); + +% if (isempty(nval)) +% continue +% end + y=y./nval; + + plot(x,y, 'LineStyle', pattern{floor((i-1)/length(color))+1} , 'LineWidth', 2, ... 'Color',color(mod(i-1,length(color))+1),... 'DisplayName', [legend_str, num2str(wl_range(i))]); - if (i==21) +% line(repmat(1e7/(1e7/wl_range(i) + 3000),[1 2]),[min(data{i}) max(data{i})]); + if (i==1) legend('show','-DynamicLegend'); end end diff --git a/import_uvvis.m b/import_uvvis.m index ac04d40..e37dfdd 100644 --- a/import_uvvis.m +++ b/import_uvvis.m @@ -8,8 +8,8 @@ varargout{1} = raw{1}(1:end-2); end -for i = length(raw)-1:-1:3 - if (isempty(raw{i})) +for i = 3:length(raw) + if (isempty(regexp(raw{i},'^\s*[0-9\.]+,[0-9\.\-EeDd]+,*\s*$','match'))) raw = raw(3:i-1); break; end diff --git a/import_uvvis_by_dialog.m b/import_uvvis_by_dialog.m index 5fa35d1..813d948 100644 --- a/import_uvvis_by_dialog.m +++ b/import_uvvis_by_dialog.m @@ -1,6 +1,11 @@ %% Import data fignum = 11; wavenum = 0; + +epsilon = 0; +conc = 1.0e-5.*[1 2 3 5 10]; % Molarity +path_length = repmat(1.0,[1 5]); % Centimeters + if (~exist('abs_last_path', 'var')) abs_last_path = pwd; end @@ -63,7 +68,12 @@ else x = abswl{i}; end - plot(x,absdata{i}, 'LineStyle', pattern{floor((i-1)/length(color))+1} , 'LineWidth', 2, ... + if (epsilon) + y = absdata{i} ./ (path_length(i) * conc(i)); + else + y = absdata{i}; + end + plot(x,y, 'LineStyle', pattern{floor((i-1)/length(color))+1} , 'LineWidth', 2, ... 'Color',color(mod(i-1,length(color))+1),... 'DisplayName', sampname); end @@ -73,5 +83,9 @@ else xlabel('Wavelength (nm)'); end -ylabel('Absorbance (AU)'); +if (epsilon) + ylabel('Extinction \epsilon (M^{-1} cm^{-1})'); +else + ylabel('Absorbance (AU)'); +end legend('show'); \ No newline at end of file