|
244 | 244 | oneSym = str2sym('1');
|
245 | 245 |
|
246 | 246 | % change to parfor?
|
247 |
| - parfor iRxn = 1:n_reactions |
| 247 | + for iRxn = 1:n_reactions |
248 | 248 | prop_vars = symvar(symbolicExpression{iRxn});
|
249 | 249 | hybridFactor =[];
|
250 | 250 | prefixNameLocal = [prefixName,'_',num2str(iRxn)];
|
|
419 | 419 | for i2=1:length(upstreamODEs)
|
420 | 420 | expr_tx = subs(expr_tx,upstreamODEs{i2},varODEs(i2));
|
421 | 421 | end
|
| 422 | + |
422 | 423 | [obj{iRxn}.(jntFactorName),expr_dt_vec_dodei] = ...
|
423 | 424 | sym2propfun(expr_tx, true, true, nonXTpars(:,1), speciesStoch, varODEs, logicTerms(iRxn), true);
|
424 | 425 | obj{iRxn}.isTimeDependent = true;
|
|
564 | 565 | n = [0,0,0];
|
565 | 566 | stNew = st;
|
566 | 567 | for i=1:3
|
567 |
| - J = strfind(stNew,logTypes{i}); |
568 |
| - for j = 1:length(J) |
569 |
| - K = strfind(stNew,'('); |
570 |
| - k1 = max(K(K<J(j))); |
571 |
| - K = strfind(stNew,')'); |
572 |
| - k2 = min(K(K>J(j))); |
573 |
| - logE = stNew(k1:k2); |
574 |
| - if contains(logE,'t')&&max(contains(logE,species)) |
575 |
| - n(1)=n(1)+1; |
576 |
| - logicTerms.logJ{n(1),1} = logE; |
577 |
| - counter = counter+1; |
578 |
| - logicTerms.logJ{n(1),2} = ['logJ',num2str(counter)]; |
579 |
| - stNew = strrep(stNew,logE,['(',logicTerms.logJ{n(1),2},')']); |
580 |
| - elseif contains(logE,'t') |
581 |
| - n(2)=n(2)+1; |
582 |
| - logicTerms.logT{n(2),1} = logE; |
583 |
| - counter = counter+1; |
584 |
| - logicTerms.logT{n(2),2} = ['logT',num2str(counter)]; |
585 |
| - stNew = strrep(stNew,logE,['(',logicTerms.logT{n(2),2},')']); |
586 |
| - elseif max(contains(logE,species)) |
587 |
| - n(3)=n(3)+1; |
588 |
| - logicTerms.logX{n(3),1} = logE; |
589 |
| - counter = counter+1; |
590 |
| - logicTerms.logX{n(3),2} = ['logX',num2str(counter)]; |
591 |
| - stNew = strrep(stNew,logE,['(',logicTerms.logX{n(3),2},')']); |
| 568 | + while ~isempty(strfind(stNew,logTypes{i})) |
| 569 | + J = strfind(stNew,logTypes{i}); |
| 570 | + for j = 1%:length(J) |
| 571 | + K = strfind(stNew,'('); |
| 572 | + k1 = max(K(K<J(j))); |
| 573 | + K = strfind(stNew,')'); |
| 574 | + k2 = min(K(K>J(j))); |
| 575 | + logE = stNew(k1:k2); |
| 576 | + if contains(logE,'t')&&max(contains(logE,species)) |
| 577 | + n(1)=n(1)+1; |
| 578 | + logicTerms.logJ{n(1),1} = logE; |
| 579 | + counter = counter+1; |
| 580 | + logicTerms.logJ{n(1),2} = ['logJ',num2str(counter)]; |
| 581 | + stNew = strrep(stNew,logE,['(',logicTerms.logJ{n(1),2},')']); |
| 582 | + elseif contains(logE,'t') |
| 583 | + n(2)=n(2)+1; |
| 584 | + logicTerms.logT{n(2),1} = logE; |
| 585 | + counter = counter+1; |
| 586 | + logicTerms.logT{n(2),2} = ['logT',num2str(counter)]; |
| 587 | + stNew = strrep(stNew,logE,['(',logicTerms.logT{n(2),2},')']); |
| 588 | + elseif max(contains(logE,species)) |
| 589 | + n(3)=n(3)+1; |
| 590 | + logicTerms.logX{n(3),1} = logE; |
| 591 | + counter = counter+1; |
| 592 | + logicTerms.logX{n(3),2} = ['logX',num2str(counter)]; |
| 593 | + stNew = strrep(stNew,logE,['(',logicTerms.logX{n(3),2},')']); |
| 594 | + end |
592 | 595 | end
|
593 | 596 | end
|
594 | 597 | end
|
|
677 | 680 |
|
678 | 681 | % import ssit.fsp.*
|
679 | 682 | varNames = string(symvar(symbolicExpression));
|
| 683 | +varNames = unique([varNames,species{:}]); |
| 684 | +% len = zeros(1,length(varNames)); |
| 685 | +% for i = 1:length(varNames) |
| 686 | +% len(i) = length(varNames{i}); |
| 687 | +% end |
| 688 | +% [~,J] = sort(len,'descend'); |
| 689 | +% varNames = varNames(J); |
680 | 690 | % sort(varNames, 'descend');
|
681 | 691 |
|
682 | 692 | if jacobian&&~isempty(varODEs)
|
|
689 | 699 | end
|
690 | 700 |
|
691 | 701 | exprStr = char(symbolicExpression);
|
| 702 | + |
| 703 | +% Get rid of max rules. |
| 704 | +k = strfind(exprStr,', ''omitnan'); |
| 705 | +if ~isempty(k) |
| 706 | + exprStr = [exprStr(1:k-1),')']; |
| 707 | +end |
| 708 | + |
| 709 | +% exprStr = char(strrep(exprStr,", [], 2, 'omitnan', false","")); |
| 710 | + |
| 711 | + |
| 712 | + |
692 | 713 | opVar = {'*','/','^'};
|
693 | 714 | for i = 1:length(opVar)
|
694 | 715 | op = opVar{i};
|
|
0 commit comments