forked from GTSL-UC/T-Blade3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3dbgb.f90
1172 lines (1053 loc) · 44 KB
/
3dbgb.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
!****************************************************************************************
!****************************************************************************************
!****************************************************************************************
! 3 DIMENSIONAL BLADE GEOMETRY BUILDER (3DBGB)
!****************************************************************************************
! This is a program which generates a 3d blade shape and outputs section files.
! inputs: inlet angle, exit angle, chord, thickness, scaling factor among others.
!
! output: 3d blade shape, 3d blade coordinates (x, y, z), section files
!---------------------------------------------------- by Kiran Siddappaji, Ahmed Nemnem
!----------------------------------------------------University of Cincinnati
!****************************************************************************************
!****************************************************************************************
!****************************************************************************************
! CODE STRUCTURE : ORDER OF OPERATION
!****************************************************************************************
! 00. Start Program.
! 01. Declare variables and display Welcome message and info about the code and Authors.
! 02. Reading the primary input file (3dbgbinput.#.dat).
! b. Reading from the input 'controlinput.dat' if curvature/thick/LE switches are on.
!i ) Reading curvature.
!ii ) Reading thickness.
!iii) Reading Leading edge parameters.
! 03. Print selected read data to the screen.
!a. Splining the LE and TE coordinates from the input file.
! 04. Calculating m prime coordinates using x, r coordinates as the input for streamlines.
!a. Writing dimensional hub and casing streamlines.
! 05. Splining the x, r coordinates of the stream/construction lines to create m' splines.
!a. Calculating offsets for the hub-tip streamlines if the offset is given as input.
! 06. Obtaining LE/TE x, r values on each streamline using the LE/TE curve and...
!...the streamline curve intersection.
! 07. Checking if r_slope > x_slope for non-axial flow.
! 08. Calculating msLE and msTE using LE, TE (x, r) and determining axial/radial/mixed flow.
!a. Obtaining initial guesss values for msle and mste to calculate the correct values.
!b. Determining purely axial, purely radial, mixed flow.
!c. Calculating the phi to adjust for BetaZ conversion.
! 09. Passing input parameters for blade generation (2D airfoils).
!a. Splining Control points for chord, stagger, outbeta, tm/c.
! 10. Allocating more variables for further calculations regarding throat and other data.
! 11. Calling the subroutine bladegen which performs the blade creation for various airfoils.
!a. BetaZ-betaM conversion.
!b. Chord switches.
!c. Stagger switches.
!d. calling bladegen
! i)Also creating 2D blade grids with background.
! 12. Stacking blade sections to create a 3d blade shape with various stacking options.
! 13. Writing relevant bladedata to an external file (volume calculation).
! 14. Writing throat-index to the screen and external file.
! 15. Writing dimensional 3D blade coordinates to separate files.
! 16. Writing pitch and chord non-dimensional values to a file.
! 17. Format statements.
! 18. Deallocation of the allocatable variables.
! 19. End Program
!****************************************************************************************
!****************************************************************************************
!!#define STAND_ALONE 1
#ifdef STAND_ALONE
program bgb3d ! 3d blade geometry builder
use globvar
implicit none
character*256 :: fname, row_type
character*32 :: arg2, arg3
call getarg(1, fname)
narg = iargc()
if(narg.ge.2)then
call getarg(2, arg2)
else
arg2 = ''
endif
if(narg.eq.3)then
call getarg(3, arg3)
else
arg3 = ''
endif
k = (index(fname, '.')+1)
do i = k, len(trim(fname))
if (fname(i:i) == '.') then
j = i-1
continue
endif
enddo
row_type = fname(k:j)
!call bgb3d_sub(fname, 'controlinputs.'//trim(row_type)//'.dat', arg2, arg3)
call bgb3d_sub(fname, 'spancontrolinputs.'//trim(row_type)//'.dat', arg2, arg3)
end program bgb3d
! Variable override subroutines for ESP intergation
! Added by Simon Livingston
subroutine override_chord(n, a)
real*8 a(*)
end subroutine override_chord
subroutine override_thk_c(n, a)
real*8 a(*)
end subroutine override_thk_c
subroutine override_inci(n, a)
real*8 a(*)
end subroutine override_inci
subroutine override_devn(n, a)
real*8 a(*)
end subroutine override_devn
subroutine override_cur2(n, a)
real*8 a(*)
end subroutine override_cur2
subroutine override_cur3(n, a)
real*8 a(*)
end subroutine override_cur3
subroutine override_cur4(n, a)
real*8 a(*)
end subroutine override_cur4
subroutine override_cur5(n, a)
real*8 a(*)
end subroutine override_cur5
subroutine override_cur6(n, a)
real*8 a(*)
end subroutine override_cur6
subroutine override_cur7(n, a)
real*8 a(*)
end subroutine override_cur7
subroutine override_in_beta(n, a)
real*8 a(*)
end subroutine override_in_beta
subroutine override_out_beta(n, a)
real*8 a(*)
end subroutine override_out_beta
subroutine override_u2(n, a)
real*8 a(*)
end subroutine override_u2
subroutine override_u3(n, a)
real*8 a(*)
end subroutine override_u3
subroutine override_u4(n, a)
real*8 a(*)
end subroutine override_u4
subroutine override_u5(n, a)
real*8 a(*)
end subroutine override_u5
subroutine override_u6(n, a)
real*8 a(*)
end subroutine override_u6
subroutine override_span_in_beta(n, a)
real*8 a(*)
end subroutine override_span_in_beta
subroutine override_span_out_beta(n, a)
real*8 a(*)
end subroutine override_span_out_beta
subroutine override_span_curv_ctrl(n, a)
real*8 a(*)
end subroutine override_span_curv_ctrl
#endif
!****************************************************************************************
subroutine bgb3d_sub(fname_in, aux_in, arg2, arg3) ! 3d blade geometry builder
use globvar
implicit none
!
real spl_eval, dspl_eval
real*8 xdiff, rdiff
real*8 inBetaInci, outBetaDevn
! !
character*(*) :: fname_in, aux_in
character*256 :: fname, temp, tempr1, fname1, fname2, fname3, fname4, row_type, path
character*(*) :: arg2, arg3
! !
logical axial_LE, radial_LE, axial_TE, radial_TE
axial_LE = .False.
radial_LE = .False.
axial_TE = .False.
radial_TE = .False.
is2d = .False.
wing_flag = 0
!-------constants-----------------------------------------------------------
pi = 4.*atan(1.0)
dtor = pi/180.
radius_tolerance = 1e-05
abs_zero = 0.0000000000000000
!****************************************************************************
!Displays the welcome message and some info about the code capabilities
call displayMessage
!****************************************************************************
!--------counting the number of command line arguments passed: --------------
fname = fname_in
! Types of 2nd argument
if (trim(arg2).eq.'dev') then
print*, '2nd Argument:', 'develop'
isdev = .true.
elseif (trim(arg2).eq.'xygrid') then ! Only for the 2d grids in xy
print*, '2nd Argument:', 'xygrid'
isxygrid = .true.
elseif (trim(arg2).eq.'xyzstreamlines') then ! only when you want the xyz streamlines.sldcrv
print*, '2nd Argument:', 'xyzstreamlines'
is_xyzstreamlines = .true.
elseif ((trim(arg2).eq.'2d') .or. (trim(arg2).eq.'2D')) then
print*, '2nd Argument:', '2D'
is2d = .True.
endif
! Types of 3rd argument
if (trim(arg3).eq.'dev') then
print*, '3rd Argument:', 'develop'
isdev = .true.
elseif (trim(arg3).eq.'xygrid') then ! Only for the 2d grids in xy
print*, '3rd Argument:', 'xygrid'
isxygrid = .true.
elseif (trim(arg3).eq.'xyzstreamlines') then ! only when you want the xyz streamlines.sldcrv
print*, '3rd Argument:', 'xyzstreamlines'
is_xyzstreamlines = .true.
elseif ((trim(arg3).eq.'2d') .or. (trim(arg3).eq.'2D')) then
print*, '3rd Argument:', '2D'
is2d = .True.
endif
j = -1
! Finding path
do i = len(trim(fname)), 1, -1
if ((fname(i:i) .eq. '/') .or. (fname(i:i) .eq. '\')) then
j = i
exit
endif
enddo
if (j == -1) then
path = ''
else
path = fname(1:j)
endif
! indicating the row number and type of blade from input file name:
!-----------------------------------------------------------------
k = 0
do i = len(trim(fname)), 1, -1
if (fname(i:i) .eq. '.') then
k = k+1
if (k .eq. 1) then
j = i-1
endif
if (k .eq. 2) then
k = i+1
exit
endif
endif
enddo
row_type = fname(k:j)
print*, 'Row number and blade type is ', row_type
!****************************************************************************
!---reading the primary input file---------------------------------------
call readinput(fname)
write(*,*)
write(*,*) 'Reading inputs from file : ', fname
if((curv.ne.0.or.thick.ne.0.or.LE.ne.0&
.or.thick_distr.ne.0).and.trim(spanwise_spline).ne.'spanwise_spline')then
!---reading secondary input file (controlinputdat)-----------------------
write(*, *)
print*, 'Reading the controlinput file ....'
write(*, *)
! call readcontrolinput(aux_in)
call readcontrolinput(row_type, path)
elseif((curv.ne.0.or.thick.ne.0.or.LE.ne.0&
.or.thick_distr.ne.0).and.trim(spanwise_spline).eq.'spanwise_spline')then
!---reading secondary input file (spancontrolinputdat)-----------------------
write(*, *)
print*, 'Reading the spanwise_input file ....'
write(*, *)
! call read_spanwise_input(aux_in)
call read_spanwise_input(row_type, path)
endif
!****************************************************************************
!****************************************************************************
!--Messages to the screen----------------------------------------------------
write(*, *)
write(*, *)'case:', fext
write(*, *)'bladerow #:', ibrow
print*, ibrowc
write(*, *)
print*, 'Number of blades in this row:', nbls
write(*, *)'bsf:', scf
write(*, *)
print*, 'Number of streamlines:', nsl
write(*, *)
if (.not. spanwise_angle_spline) then
print*, ' in_betaZ* out_betaZ*'
do js = 1, nspn
print*, in_beta(js), out_beta(js)
enddo
endif
!! splining the LE and TE coordinates from the input file
write(*, *)
write(*, *)'LE/TE defined by a curve with no. of points as:', npoints
write(*, *)'xLE rLE xTE rTE'
do i = 1, npoints
print*, xle(i), rle(i), xte(i), rte(i)
!Spline LE curve
call arclength(xle(1), rle(1), sle(1), npoints)
call spline(xle(1), xles(1), sle(1), npoints, 999.0, -999.0)
call spline(rle(1), rles(1), sle(1), npoints, 999.0, -999.0)
!Spline TE curve
call arclength(xte(1), rte(1), ste(1), npoints)
call spline(xte(1), xtes(1), ste(1), npoints, 999.0, -999.0)
call spline(rte(1), rtes(1), ste(1), npoints, 999.0, -999.0)
enddo
!----------------------------------------
if(LE.ne.0) then ! LE spline options
do js = 1, nspn
print*, airfoil(js), stk_u(js), stk_v(js), umxthk_all(js), jcellblade_all(js), etawidth_all(js), BGgrid_all(js)
enddo
elseif(LE == 0) then ! elliptical LE
do js = 1, nspn
print*, airfoil(js), stk_u(js), stk_v(js), umxthk_all(js), lethk_all(js), tethk_all(js), jcellblade_all(js), etawidth_all(js), BGgrid_all(js)
enddo
endif
!****************************************************************************
!SWEEP and LEAN
! Differentiating between true and axial SWEEP
if(trim(trueleansweep).ne.'')then
print*, 'Sweep along the chord (1 = yes): ', chrdsweep
write(*, *)
else
print*, 'Sweep in the axial direction (m-prime).'
write(*, *)
endif
! Differentiating between true and axial LEAN
if(trim(trueleansweep).ne.'')then
print*, 'Lean normal to the chord (1 = yes): ', chrdlean
write(*, *)
else
print*, 'Lean in the tangential direction (theta).'
write(*, *)
endif
!--------------------------------------------------------------------------------
! ! Writing dimensional hub and casing streamlines
!(adding hub here before eliminating zero radius points nemnem 6/25/2014)
do i = 1, nsp(nsl)
xt(i, 1) = xm(i, nsl)
rt(i, 1) = rm(i, nsl)
enddo
call hubTipStreamline(xm(1, 1), rm(1, 1), nsp(1), xt, rt, nsp(nsl), nsl, scf, casename)
!****************************************************************************
! Calculating m prime coordinates...
! using x, r coordinates as the input for streamlines
!****************************************************************************
write(*, *)
print*, 'Using x_s and r_s coordinates for streamline from the input file...'
write(*, *)
print*, 'Calculating the m_prime coordinates for each streamline...'
write(*, *)
!
! if (rm(1, 1) .eq. abs_zero .and. rm(1, nsp(1)) .eq. abs_zero) then
! rm(1, 1) = 0.0000000000000001
! rm(1, nsp(1)) = 0.0000000000000001
! endif
!
do ia = 1, nsl
mp(1, ia) = 0.
k = 0
! !print*, ' mp xm rm'
do i = 2, nsp(ia)
if (rm(i, ia)< radius_tolerance) then
k = k + 1 ! nemnem 6 10 2014
print*, 'Radius less than', radius_tolerance, ', excluding point number', k
xm(1, ia) = xm(i, ia) ! switch to new intial value after elimination zero radius points
rm(1, ia) = rm(i, ia)
print*, 'xm(1, ia)', xm(1, ia), 'rm(1, ia)', rm(1, ia)
else
!print*, 'i-k, nsp(ia)', i-k, nsp(ia)
mp(i-k, ia) = mp(i-k-1, ia) + 2.*sqrt((rm(i, ia)-rm(i-1, ia))**2 + (xm(i, ia)-xm(i-1, ia))**2)/(rm(i, ia)+rm(i-1, ia))
xm(i-k, ia) = xm(i, ia) ! Reindex the mp, xm, rm for hub
rm(i-k, ia) = rm(i, ia) ! Reindex the mp, xm, rm for hub
endif
enddo
if (k /= 0) then
nsp_hub = nsp(ia) ! nsp_hub is used for full hub streamline extraction nemnem 6 10 2014
nsp(ia) = i-k-1 ! Update the hub number of valid points
print*, 'nsp for streamline', ia, 'changed from', nsp_hub, 'to', nsp(ia)
endif
if (is_xyzstreamlines) then
if ((ia > 1).and.(ia < nsl)) then
call streamlines(xm(:, ia), rm(:, ia), nsp(ia), scf, casename, ia) ! Ahmed nemnem 4 23 2014 extracting streamlines
endif
endif
!print*, 'mp(:, ia)', mp(1:nsp(ia), ia)
enddo
!-------------------------------------------------------------------------------
!*************************************************************************************
! Debugging :Create an interpolated xm rm for nonoffset hub streamline for plotting : Nemnem 7 16 2014
if (hub.ne.0) then
n_inter_intervals = 3 ! number of points = no_intervals + 1
k = 1
xm_nonoffset_hub(k) = xm(1, 1)
rm_nonoffset_hub(k) = rm(1, 1)
if (allocated(hub_slope)) deallocate(hub_slope)
Allocate(hub_slope(nsp(1)-1))
! interpolate hub streamline xm rm:
do i = 1, nsp(1)-1 !number of hub segments
hub_slope(i) = (rm(i+1, 1)-rm(i, 1))/(xm(i+1, 1)-xm(i, 1))
!print*, 'slope', hub_slope(i), k
do j = 1, n_inter_intervals
k = j + (i-1)*n_inter_intervals
xm_nonoffset_hub(k+1) = xm_nonoffset_hub(k)+((xm(i+1, 1)-xm(i, 1))/(n_inter_intervals))
rm_nonoffset_hub(k+1) = rm_nonoffset_hub(k)+(xm_nonoffset_hub(k+1)-xm_nonoffset_hub(k))*hub_slope(i)
nsp_interpolated_hub = k+1 ! this should k+1 but I put k to remove the first point
enddo
enddo
! calculate mp_nonoffset_hub:
mp_nonoffset_hub(1) = 0.0
do i = 2, nsp_interpolated_hub
mp_nonoffset_hub(i) = mp_nonoffset_hub(i-1) + 2.*sqrt((rm_nonoffset_hub(i)-rm_nonoffset_hub(i-1))**2 &
+ (xm_nonoffset_hub(i)-xm_nonoffset_hub(i-1))**2)/(rm_nonoffset_hub(i)+rm_nonoffset_hub(i-1))
!mp(i-k, ia) = mp(i-k-1, ia) + 2.*sqrt((rm(i, ia)-rm(i-1, ia))**2 + (xm(i, ia)-xm(i-1, ia))**2)/(rm(i, ia)+rm(i-1, ia))
enddo
! write to file:
! fname1 = 'plot_xm_mp_nonoffset_hub.'//trim(casename)//'.dat'
! open(12, file = fname1, status = 'unknown')
! do i = 1, nsp_interpolated_hub
! write(12, *) xm_nonoffset_hub(i), mp_nonoffset_hub(i), rm_nonoffset_hub(i)
! enddo
! close(12)
! splining:
call spline(xm_nonoffset_hub, xms_nonoffset_hub, mp_nonoffset_hub, nsp_interpolated_hub, 999.0, -999.0)
call spline(rm_nonoffset_hub, rms_nonoffset_hub, mp_nonoffset_hub, nsp_interpolated_hub, 999.0, -999.0)
! Offseting the interpolated hub spline:
temp = 'interpolated'
!print*, 'temp = ', temp
call huboffset(mp_nonoffset_hub, xm_nonoffset_hub, rm_nonoffset_hub, xms_nonoffset_hub &
, rms_nonoffset_hub, hub, nsp_interpolated_hub, scf, temp)
! write to file:
! fname2 = 'plot_xm_mp_offset_hub.'//trim(casename)//'.dat'
! open(13, file = fname2, status = 'unknown')
! do i = 1, nsp_interpolated_hub
! write(13, *) xm_nonoffset_hub(i), mp_nonoffset_hub(i), rm_nonoffset_hub(i)
! enddo
! close(13)
endif
!*************************************************************************
!--------------------------------------------------------------------------------
!--------------------------------------------------------------------------------
! Splining the x, r coordinates of the streamlines (construction lines)...
! to create mprime spline coeffs.
na = nsl
do ia = 1, na
if(fext.eq.'e3c-des')then
call spl_discjoint(xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
call spl_discjoint(rm(1, ia), rms(1, ia), mp(1, ia), nsp(ia))
else
call spline(xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia), 999.0, -999.0)
call spline(rm(1, ia), rms(1, ia), mp(1, ia), nsp(ia), 999.0, -999.0)
endif
enddo
! print*, "xm(i, ia), rm(i, ia), mp(i, ia), xms(i, ia), rms(i, ia)"
! do ia = 1, na
! do i = 1, nsp(ia)
! print*, xm(i, ia), rm(i, ia), mp(i, ia), xms(i, ia), rms(i, ia)
! enddo
! print*, " "
! enddo
!
!-----------------------------------------------------------------------------
!---------------------------------------------------------------------------
!Calculating offsets for the streamlines if the offset is given as input.
!---------------------------------------------------------------------------
write(*, *)
print*, 'hub offset:', hub
print*, 'tip offset:', tip
write(*, *)
!HUB offset
if(hub.ne.0)then
call huboffset(mphub(1, 1), xm(1, 1), rm(1, 1), xms(1, 1), rms(1, 1), hub, nsp(1), scf, casename)
!Offset mprime coordinates updated to the mprime array at hub and casing.
do i = 1, nsp(1)
mp(i, 1) = mphub(i, 1)
!print*, 'mphub', mp(i, 1)
enddo
endif
!TIP offset
if(tip.ne.0)then
do i = 1, nsp(na)
xt(i, 1) = xm(i, na)
rt(i, 1) = rm(i, na)
dxn(i, 1) = xms(i, na)
drn(i, 1) = rms(i, na)
enddo
!call tipoffset(mptip, xt, rt, dxn, drn, tip, nsp(na), scf, nsl, casename) ! changed by the next line Nemnem 6 10 2014
call tipoffset(mptip, xm(1, nsl), rm(1, nsl), xms(1, nsl), rms(1, nsl), tip, nsp(nsl), scf, nsl, casename)
!Offset mprime coordinates updated to the mprime array at hub and casing.
do i = 1, nsp(na)
mp(i, na) = mptip(i, 1)
!print*, mp(i, na)
enddo
endif
!----------------------------------------------------------------------------------
! taking some values for analysis:
!------------------------------
! if (hub == 0) then! picking up some analysis values
! fname1 = 'plot_xm_mp.unoffset.'//trim(casename)//'.dat'
! fname2 = 'plot_rm_mp.unoffset.'//trim(casename)//'.dat'
! fname3 = 'plot_xm_rm.unoffset.'//trim(casename)//'.dat'
! else
! fname1 = 'plot_xm_mp.'//trim(casename)//'.dat'
! fname2 = 'plot_rm_mp.'//trim(casename)//'.dat'
! fname3 = 'plot_xm_rm.'//trim(casename)//'.dat'
! endif
! open(1, file = fname3, status = 'unknown')
! open(2, file = fname1, status = 'unknown')
! open(22, file = fname2, status = 'unknown')
! do ia = 1, na
! do i = 1, nsp(ia)
! write(*, *) xm(i, ia), rm(i, ia), mp(i, ia)
! enddo
! write(*, *) ' 0 0'
! do i = 1, nsp(ia)
! write(2, *) xm(i, ia), mp(i, ia)
! enddo
! write(2, *) ' 0 0'
! do i = 1, nsp(ia)
! write(22, *) rm(i, ia), mp(i, ia)
! enddo
! write(22, *) ' 0 0'
! enddo
! close(22)
! close(2)
! close(1)
!----------------------------------------------------------------------------------
!----------------------------------------------------------------------------------
! Obtaining LE/TE x, r values on each streamline using the LE/TE curve and...
! ...the streamline curve intersection 3/27/12----
!----------------------------------------------------------------------------------
write(*, *)'xLE rLE xTE rTE'
! LE curve intersection with the streamline curve---------
print*, 'Calculating LE x, r points... '
do ia = 1, na
! if (npoints.eq.nsl)then ! LE, TE points same as no. of streamlines
! x_le(ia) = xle(ia)
! r_le(ia) = rle(ia)
! else ! when interpolation of LE, TE coordinates is required
s1le(ia) = mp(2, ia)
s2le(1) = rle(1)
if(ia.eq.1)then
s2le(ia) = s2le(1)
else
s2le(ia) = s2le(ia-1)
endif
!------------------------------
!print*, 's1le, s2le', s1le(ia), s2le(ia)
! print*, 'inlet to spl_intersect', s1le(ia), s2le(ia), xm(1, ia), xms(1, ia), rm(1, ia), &
! rms(1, ia), mp(1, ia), nsp(ia), xle(1), xles(1), rle(1), &
! rles(1), sle(1), npoints
call spl_intersect(s1le(ia), s2le(ia), xm(1, ia), xms(1, ia), rm(1, ia), &
rms(1, ia), mp(1, ia), nsp(ia), xle(1), xles(1), rle(1), &
rles(1), sle(1), npoints)
x_le(ia) = spl_eval(s1le(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
r_le(ia) = spl_eval(s1le(ia), rm(1, ia), rms(1, ia), mp(1, ia), nsp(ia))
! endif
enddo
! TE curve intersection with the streamline curve---------
!if(xslope_TE.ge.rslope_TE)then
print*, 'Calculating TE x, r points...'
do ia = 1, na
! if (npoints.eq.nsl)then ! LE, TE points same as no. of streamlines
! x_te(ia) = xte(ia)
! r_te(ia) = rte(ia)
! else ! when interpolation of LE, TE coordinates is required
s1te(ia) = s1le(ia)
s2te(1) = rte(1)
if(ia.eq.1)then
s2te(ia) = s2te(1)
else
s2te(ia) = s2te(ia-1)
endif
!print*, 's1te, s2te', s1te(ia), s2te(ia)
call spl_intersect(s1te(ia), s2te(ia), xm(1, ia), xms(1, ia), rm(1, ia), &
rms(1, ia), mp(1, ia), nsp(ia), xte(1), xtes(1), rte(1), &
rtes(1), ste(1), npoints)
x_te(ia) = spl_eval(s1te(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
r_te(ia) = spl_eval(s1te(ia), rm(1, ia), rms(1, ia), mp(1, ia), nsp(ia))
! endif
!!KB
! write(*, *) 'Initial msle = ', s1le(ia), ' Initial mste = ', s1te(ia)
enddo
!-------------------------------------------------------
!! Assigning to separate variables to be written to a file later
fname1 = 'LE_TE_intersection.'//trim(casename)//'.dat'
open(3, file = fname1, status = 'unknown')
if (allocated(sec_radius)) deallocate(sec_radius)
Allocate(sec_radius(nsl, 2))
do ia = 1, na
! write(*, *)x_le(ia), r_le(ia), x_te(ia), r_te(ia)
write(3, *)x_le(ia), r_le(ia), x_te(ia), r_te(ia) !Ahmed Nemnem 6/13/2014
sec_radius(ia, 1) = r_le(ia) !for LE Ahmed Nemnem 2/11/2014
sec_radius(ia, 2) = r_te(ia) !for TE
enddo
close(3)
! write(*, *)
! do ia = 1, nsl
! print*, 'Nondimensional sec_radius for LE, TE, sec(', ia, ') = ', sec_radius(ia, :)
! enddo
! write(*, *)
! write(*, *)
!--------------------------------------------------------------------
! Checking if r_slope > x_slope for non-axial machines
!--------------------------------------------------------------------
! i_slope = 1
do ia = 1, na
i_slope = 0
do i = 1, nsp(ia)
xm_slope = abs(xms(i, ia))
rm_slope = abs(rms(i, ia))
if(rm_slope.ge.xm_slope.and.i_slope.eq.0) i_slope = i
enddo
print*, 'i_slope', i_slope
enddo
!--------------------------------------------------------------------
! Calculating msLE and msTE using LE, TE (x, r) and determining axial/radial/mixed flow
!--------------------------------------------------------------------
! Obtaining initial guesss values for msle and mste to calculate the correct values-----
do ia = 1, na
xsle = x_le(ia)
xste = x_te(ia)
rsle = r_le(ia)
rste = r_te(ia)
ile = 0
ite = 0
!Leading Edge index --------------------------------------------------
do i = 1, nsp(ia) - 1
ii = i
xi = xm(i, ia)
ri = rm(i, ia)
xi1 = xm(i+1, ia)
ri1 = rm(i+1, ia)
x1hub = xm(1, 1)
x1tip = xm(1, na)
r1hub = rm(1, 1)
r1tip = rm(1, na)
if(i_slope.eq.0)then ! purely axial flow
if((xi1.ge.xsle.and.xi.le.xsle).and.ile.eq.0) ile = i
elseif(i_slope.ne.0)then ! not purely axial flow
if(ii.le.i_slope)then ! flow at LE
if((r1tip.gt.r1hub).or.(r1tip.lt.r1hub))then ! axial flow at LE
axial_LE = .True.
if((xi1.ge.xsle.and.xi.le.xsle).and.ile.eq.0) ile = i
elseif((x1hub.lt.x1tip).or.(x1hub.gt.x1tip))then ! radial flow at LE
radial_LE = .True.
if(ri1.ge.rsle.and.ri.le.rsle.and.ile.eq.0) ile = i
endif
endif
endif
enddo
print*, 'ile:', ile
! if(ile.le.2)then
! msle(ia) = 0.
! else
! msle(ia) = mp(ile-2, ia)
! endif
! print*, 'msle-initial guess', msle(ia)
!--------------------------------------------------------------------
!
! Trailing Edge index -----------------------------------------------
do i = 1, nsp(ia) - 1
ii = i
xi = xm(i, ia)
ri = rm(i, ia)
xi1 = xm(i+1, ia)
ri1 = rm(i+1, ia)
if(i_slope.eq.0)then ! purely axial flow
if((xi1.ge.xste.and.xi.le.xste).and.ite.eq.0) ite = i
elseif(i_slope.ne.0)then ! not purely axial flow
if(ii.ge.i_slope)then! flow at TE
if((r1tip.gt.r1hub).or.(r1tip.lt.r1hub))then ! Radial flow at TE
radial_TE = .True.
if((ri1.ge.rste.and.ri.le.rste).and.ite.eq.0) ite = i
elseif((x1hub.lt.x1tip).or.(x1hub.gt.x1tip))then ! Axial flow at TE
axial_TE = .True.
if((xi1.ge.xste.and.xi.le.xste).and.ite.eq.0) ite = i
endif
endif
endif
enddo
print*, 'ite:', ite
! mste(ia) = mp(ite+2, ia)
! print*, 'mste-initial guess', mste(ia)
! write(*, *)
enddo
!-----------------------------------------------------------------------
!--------------------------------------------------------------------
!!Determining purely axial, purely radial, mixed flow
!--------------------------------------------------------------------
do ia = 1, na
!!KB
msle(ia) = s1le(ia)
mste(ia) = s1te(ia)
! print*, msle(ia), s1le(ia)
if(i_slope.eq.0)then ! purely axial flow
print*, 'Using x values for msLE due to a purely axial flow.'
!print*, 'msle(ia), x_le(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia) before'
!print*, msle(ia), x_le(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia)
! call spl_inv(msle(ia), x_le(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
!print*, 'msle(ia), x_le(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia) after'
!print*, msle(ia), x_le(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia)
print*, 'Using x values for msTE due to a purely axial flow.'
!print*, 'mste(ia), x_te(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia) before'
!print*, mste(ia), x_te(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia)
! call spl_inv(mste(ia), x_te(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
!print*, 'mste(ia), x_te(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia) after'
!print*, mste(ia), x_te(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia)
!---Evaluating span for an axial blade
lref = abs(r_le(na) - r_le(1))
span(ia) = abs(r_le(ia) - r_le(1))/real(lref)
elseif(i_slope.ne.0)then
!----Leading Edge--------------------------------------------------
if(axial_LE)then ! axial flow at LE
print*, 'Using x values for msLE due to axial flow at LE.'
! call spl_inv(msle(ia), x_le(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
!---Evaluating span for an axial blade
lref = abs(r_le(na) - r_le(1))
span(ia) = abs(r_le(ia) - r_le(1))/real(lref)
elseif(radial_LE)then! non-axial flow at LE
print*, 'Using r values for msLE due to non-axial flow at LE.'
! call spl_inv(msle(ia), r_le(ia), rm(1, ia), rms(1, ia), mp(1, ia), nsp(ia))
!---Evaluating span for a non-axial blade
xdiff = abs(x_le(na) - x_le(1))
lref = xdiff
span(ia) = abs(x_le(ia) - x_le(1))/real(lref)
endif ! endif for LE
!----Trailing Edge ------------------------------------------------
if(axial_TE)then ! axial flow at TE
print*, 'Using x values for msTE due to axial flow at TE.'
! call spl_inv(mste(ia), x_te(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
elseif(radial_TE)then ! non-axial flow at TE
print*, 'Using r values for msTE due to non-axial flow at TE.'
! call spl_inv(mste(ia), r_te(ia), rm(1, ia), rms(1, ia), mp(1, ia), nsp(ia))
endif ! end if for TE
endif ! endif for axial/radial flow determination
print*, 'msle:', msle(ia)
print*, 'mste:', mste(ia)
chordm(ia) = abs(mste(ia) - msle(ia))
print*, 'chordm:', chordm(ia)
! write(*, *)
enddo
!--------------------------------------------------------------------
!Calculating the phi to adjust for BetaZ conversion
!--------------------------------------------------------------------
do ia = 1, na
xmsle(ia) = 0.
rmsle(ia) = 0.
!--- Calculating dx/dm' and dr/dm' value at LE of each streamline------
xmsle(ia) = dspl_eval(msle(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
rmsle(ia) = dspl_eval(msle(ia), rm(1, ia), rms(1, ia), mp(1, ia), nsp(ia))
!-----Calculating dphi_s_in = dr/dx = (dr/dm')/(dx/dm') -------
phi_s_in(ia) = (atan(rmsle(ia)/xmsle(ia)))
print*, 'phi_s_in(ia)', phi_s_in(ia)/dtor
enddo
do ia = 1, na
xmste(ia) = 0.
rmste(ia) = 0.
!--- Calculating dx/dm' and dr/dm' value at TE of each streamline------
xmste(ia) = dspl_eval(mste(ia), xm(1, ia), xms(1, ia), mp(1, ia), nsp(ia))
rmste(ia) = dspl_eval(mste(ia), rm(1, ia), rms(1, ia), mp(1, ia), nsp(ia))
!-----Calculating dphi_s_out = dr/dx = (dr/dm')/(dx/dm') -------
phi_s_out(ia) = (atan(rmste(ia)/xmste(ia)))
print*, 'phi_s_out(ia)', phi_s_out(ia)/dtor
enddo
!--------------------------------------------------------------------------------------
!**************************************************************************************
!*****Adding new inputs from spancontrolinputs(Syed Moez 03/02/2014) ********************
!**************************************************************************************
if((curv.ne.0.or.thick.ne.0.or.LE.ne.0&
.or.thick_distr.ne.0).and.trim(spanwise_spline).eq.'spanwise_spline')then
!This program is being called to create cubic bspline
!between the inputs from spancontrolinputs and
!incorporate those values into 3dbgb.
call span_variation(nsl)
end if
!**************************************************************************************
!*****input parameters for blade generation (2D airfoils) *****************************
!**************************************************************************************
nspn = na
do js = 1, nspn
in_beta(js) = in_beta(js)
out_beta(js) = out_beta(js)
thk_c(js) = thk_c(js)
enddo
!endif
!----------------------------------------------------------------------
!!-Control points for spanwise inlet Betaz------------------------------------------
if((trim(anglespline).eq.'inletspline').or.(trim(anglespline).eq.'inoutspline'))then
write(*, *)
write(*, *)' Inlet Beta defined spanwise by a cubic B-spline using control points.'
write(*, *)' span in_Beta (spline)'
call cubicspline(xcpinbeta, spaninbeta, cpinbeta, xbs, ybs, y_spl_end, nspline, xc, yc, ncp1)
call cubicbspline_intersec(y_spl_end, xc, yc, ncp1, span, inbeta_s, na, xbs, ybs)
do ia = 1, na
print*, span(ia), inbeta_s(ia)
in_beta(ia) = inbeta_s(ia)
enddo
elseif (trim(anglespline).eq.'inci_dev_spline')then
write(*, *)
write(*, *)' Inlet Beta incidence defined spanwise by a cubic B-spline using control points.'
write(*, *)' span in_Beta (spline)'
call cubicspline(xcpinbeta, spaninbeta, cpinbeta, xbs, ybs, y_spl_end, nspline, xc, yc, ncp1)
call cubicbspline_intersec(y_spl_end, xc, yc, ncp1, span, inci_s, na, xbs, ybs)
do ia = 1, na
in_beta(ia) = inBetaInci(in_beta(ia), inci_s(ia))
print*, span(ia), in_beta(ia)
enddo
endif
!----------------------------------------------------------------------
!!-Control points for panwise outlet BetaZ------------------------------------------
if((trim(anglespline).eq.'outletspline').or.(trim(anglespline).eq.'inoutspline'))then
write(*, *)
write(*, *)' Outlet Beta defined spanwise by a cubic B-spline using control points.'
write(*, *)' span out_Beta (spline)'
call cubicspline(xcpoutbeta, spanoutbeta, cpoutbeta, xbs, ybs, y_spl_end, nspline, xc, yc, ncp1)
call cubicbspline_intersec(y_spl_end, xc, yc, ncp1, span, outbeta_s, na, xbs, ybs)
do ia = 1, na
print*, span(ia), outbeta_s(ia)
out_beta(ia) = outbeta_s(ia)
enddo
elseif (trim(anglespline).eq.'inci_dev_spline')then
write(*, *)
write(*, *)' Outlet Beta deviation defined spanwise by a cubic B-spline using control points.'
write(*, *)' span out_Beta (spline)'
call cubicspline(xcpoutbeta, spanoutbeta, cpoutbeta, xbs, ybs, y_spl_end, nspline, xc, yc, ncp1)
call cubicbspline_intersec(y_spl_end, xc, yc, ncp1, span, dev_s, na, xbs, ybs)
do ia = 1, na
out_beta(ia) = outBetaDevn(in_beta(ia), out_beta(ia), dev_s(ia))
print*, span(ia), out_beta(ia)
enddo
endif
!----------------------------------------------------------------------
! Splining Control points for chord, stagger, outbeta, tm/c
!----------------------------------------------------------------------
!!---Control points for chord -----------------------------------------
if(chord_switch.eq.2)then ! Changed to spline multiplier 9 3 2014 Nemnem (default = 1)
write(*, *)
write(*, *)' span chord_multipliers'
call cubicspline(xcpchord, spanchord, cpchord, xbs, ybs, y_spl_end, nspline, xc, yc, ncp1)
call cubicbspline_intersec(y_spl_end, xc, yc, ncp1, span, chords, na, xbs, ybs)
do ia = 1, na
print*, span(ia), chords(ia)
enddo
endif
!----------------------------------------------------------------------
!!-Control points for stagger------------------------------------------
staggspline = in_beta(1)
if(staggspline.eq.999.)then
write(*, *)
write(*, *)' Stagger defined spanwise by a cubic B-spline using control points.'
write(*, *)' span stagger'
call cubicspline(xcpinbeta, spaninbeta, cpinbeta, xbs, ybs, y_spl_end, nspline, xc, yc, ncp1)
call cubicbspline_intersec(y_spl_end, xc, yc, ncp1, span, inbeta_s, na, xbs, ybs)
do ia = 1, na
print*, span(ia), inbeta_s(ia)
enddo
endif
!----------------------------------------------------------------------
!!-Control points for tm/c spline multiplier---------------------------------------
if(tm_c_spline)then
write(*, *)' tm/c thickness ratio defined radially with 2D spline using control points.'
call cubicspline(xcptm_c, spantm_c, cptm_c, xbs, ybs, y_spl_end, nspline, xc, yc, ncp1)
call cubicbspline_intersec(y_spl_end, xc, yc, ncp1, span, thk_tm_c_spl, na, xbs, ybs)
do ia = 1, na
print*, span(ia), thk_tm_c_spl(ia)
enddo
endif
!-------------------------------------------------------------
! Allocating variables for further calculations
!!-------------------------------------------------------------
!000000000000000000000000000000000000000000000000000000000000
if (allocated(bladedata )) deallocate(bladedata )
if (allocated(intersec_coord)) deallocate(intersec_coord)
if (allocated(throat_3D )) deallocate(throat_3D )
if (allocated(mouth_3D )) deallocate(mouth_3D )
if (allocated(exit_3D )) deallocate(exit_3D )
if (allocated(throat_pos )) deallocate(throat_pos )
if (allocated(throat_index )) deallocate(throat_index )
Allocate(bladedata(amount_data, nsl))
Allocate(intersec_coord(12, nsl))
Allocate(throat_3D(nsl))
Allocate(mouth_3D(nsl))
Allocate(exit_3D(nsl))
Allocate(throat_pos(nsl))
Allocate(throat_index(nsl))
!0000000000000000000000000000000000000000000000000000000000000
!-------------------------------------------------------------
! calling bladegen routine to create 2D airfoil shapes
!!-------------------------------------------------------------
do js = 1, nspn
mles = msle(js)
! msle = msle(1)
mtes = mste(js)
mr1 = mrel1(js)
stak_u = stk_u(js)
stak_v = stk_v(js)
!----------------------------------------------------------------------
!betaZ-betaM conversion
!----------------------------------------------------------------------
!print*, in_beta(js), out_beta(js)
! if(trim(fext).eq.'e3c')then
if(beta_switch.eq.0)then ! All axial: Converting Beta_z to Beta_m ;tanBetaM = tanBetaz* cos(phi)
!print*, 'Converting BetaZ to BetaM...'
sinl = tan(in_beta(js)*dtor)*cos(phi_s_in(js))! angles used are Beta_m for axial machines
sext = tan(out_beta(js)*dtor)*cos(phi_s_out(js))
elseif(beta_switch.eq.1)then ! All radial: Converting Beta_r to Beta_m {tanBetaM = tanBetaR*sin(phi)}
sinl = tan(in_beta(js)*dtor)*sin(phi_s_in(js))
sext = tan(out_beta(js)*dtor)*sin(phi_s_out(js))
elseif(beta_switch.eq.2)then ! AxailIN-RadialOUT: Converting Beta_r to Beta_m {tanBetaM = tanBetaR*sin(phi)}
sinl = tan(in_beta(js)*dtor)*cos(phi_s_in(js))
sext = tan(out_beta(js)*dtor)*sin(phi_s_out(js))
elseif(beta_switch.eq.3)then ! RadialIN-AxialOUT: Converting Beta_r to Beta_m {tanBetaM = tanBetaR*sin(phi)}
sinl = tan(in_beta(js)*dtor)*sin(phi_s_in(js))
sext = tan(out_beta(js)*dtor)*cos(phi_s_out(js))