@@ -106,6 +106,15 @@ arma_vec Grid::baselat_spacing(precision_t extent,
106
106
dlat = (lat_high - lat_low) / (nLats_here+1 );
107
107
report.print (4 , " baselats laydown!" );
108
108
109
+ // edge case for 1-D
110
+ // In 1-D, the base latitudes will be 1/2 way between LatMax & minApex,
111
+ // dlat is adjustable if it doesn't suit your needs.
112
+ if (!HasYdim){
113
+ DO_FLIPBACK=false ;
114
+ dlat=1.0 * cDtoR;
115
+ nLats_here = nLats + 1 ;
116
+ }
117
+
109
118
for (int64_t j = 0 ; j < nLats_here; j++)
110
119
{
111
120
ang0 = lat_low + (j + 1 ) * dlat;
@@ -167,6 +176,7 @@ void Grid::fill_field_lines(arma_vec baseLatsLoc,
167
176
168
177
// temp holding of results from q,p -> r,theta conversion:
169
178
std:: pair<precision_t , precision_t > r_theta;
179
+ report.print (3 , " calculating lshells!" );
170
180
171
181
// Find L-Shell for each baseLat
172
182
// using L=R/sin2(theta), where theta is from north pole
@@ -316,7 +326,7 @@ Planets planet){
316
326
// They will not, however, line up from one field line to the next.
317
327
// It's not going to be *too* hard to get the corners to line up, but it messes with the
318
328
// orthogonality too much for me to figure out right now.
319
- void Grid::dipole_alt_edges (Planets planet){
329
+ void Grid::dipole_alt_edges (Planets planet, precision_t min_altRe ){
320
330
321
331
std::string function = " Grid::dipole_alt_edges" ;
322
332
static int iFunction = -1 ;
@@ -327,7 +337,7 @@ void Grid::dipole_alt_edges(Planets planet){
327
337
precision_t pTmp;
328
338
329
339
for (int64_t iLon = 0 ; iLon < nLons; iLon++) {
330
- for (int64_t iLat = 0 ; iLat < nLats; iLat++) {
340
+ for (int64_t iLat = 0 ; iLat < nLats + 1 ; iLat++) {
331
341
pTmp = magP_Down (iLon, iLat, 0 );
332
342
for (int64_t iAlt = 0 ; iAlt < nAlts; iAlt ++){
333
343
magP_Corner (iLon, iLat, iAlt) = pTmp;
@@ -344,46 +354,36 @@ void Grid::dipole_alt_edges(Planets planet){
344
354
magP_Corner (iLon, iLat, nAlts) = magP_Corner (iLon, iLat, nAlts - 1 );
345
355
}
346
356
}
347
-
348
- // next, take the final p-value (in lat) to be one more step in p.
349
- // Will not be the same size as prev. cells, but that's (hopefully) ok
350
- // And at high latitudes, that cell is going to be super awkward.
351
- // This is what needs changing when it's supercell time #todo
352
- for (int64_t iLon = 0 ; iLon < nLons + 1 ; iLon++) {
353
- for (int64_t iAlt = 0 ; iAlt < nAlts + 1 ; iAlt++) {
354
- magP_Corner (iLon, nLats, iAlt) = (magP_Corner (iLon, nLats - 2 , iAlt) - magP_Corner (nLons, nLats - 1 , iAlt)) / 2
355
- + magP_Corner (iLon, nLats - 1 , iAlt);
356
- }
357
- }
358
357
359
358
// And final step, use the longitude symmetry.
360
359
// It's fine, until the dipole is offset. then the entire fill_field_lines needs to be redone.
361
- for (int64_t iAlt = 0 ; iAlt < nAlts- 1 ; iAlt++) {
362
- for (int64_t iLat = 0 ; iLat < nLats- 1 ; iLat++) {
360
+ for (int64_t iAlt = 0 ; iAlt < nAlts+ 1 ; iAlt++) {
361
+ for (int64_t iLat = 0 ; iLat < nLats+ 1 ; iLat++) {
363
362
magP_Corner (nLons, iLat, iAlt) = magP_Corner (nLons-1 , iLat, iAlt);
364
363
}
365
364
}
366
365
367
- // For q-coord we'll avg q above and below the point...
366
+ // For q-coord we'll avg q_down (from different baseLat) above and below the point...
368
367
// May need to change the dipole spacing func's to get this working exactly though.
369
- // With how the field line pts are currently put in, there would be one edge at the equator (r=inf)
370
- // so for the last point we'll take a step in q equal to the final center + the q-dist from the
371
- // previous corner, to ensure the final center is within the final 2 corners .
368
+ // With how the field line pts are currently put in, this ends up being quite a hassle.
369
+ // Not to mention, there would be a corner at q=0 (so r=A_LOT).
370
+ // Top and bottom-most corners take the same q-step as the previous cell .
372
371
precision_t qTmp;
373
372
374
373
for (int64_t iLon = 0 ; iLon < nLons; iLon++) {
375
- for (int64_t iLat = 0 ; iLat < nLats; iLat++) {
376
- for (int64_t iAlt = 0 ; iAlt < nAlts; iAlt ++){
377
- magQ_Corner (iLon, iLat, iAlt) = magQ_Down (iLon, iLat, iAlt) ;
374
+ for (int64_t iLat = 0 ; iLat < nLats+ 1 ; iLat++) {
375
+ for (int64_t iAlt = 1 ; iAlt < nAlts; iAlt ++){
376
+ magQ_Corner (iLon, iLat, iAlt) = ( magQ_Down (iLon, iLat, iAlt- 1 ) + magQ_Down (iLon, iLat, iAlt))/ 2 ;
378
377
}
378
+ magQ_Corner (iLon, iLat, 0 ) = (2 *magQ_Corner (iLon, iLat, 1 ) - magQ_Corner (iLon, iLat, 2 ));
379
379
}
380
380
}
381
381
382
382
// for last (alt) corner, take the same step as the prev corner to the highest center.
383
383
// this will force the highest corner to be above the last center
384
384
for (int64_t iLon = 0 ; iLon < nLons; iLon++) {
385
385
for (int64_t iLat = 0 ; iLat < nLats; iLat++) {
386
- qTmp = 2 *magQ_scgc (iLon, iLat, nAlts - 1 ) - magQ_Corner (iLon, iLat, nAlts - 1 );
386
+ qTmp = 2 *magQ_Corner (iLon, iLat, nAlts - 1 ) - magQ_Corner (iLon, iLat, nAlts - 2 );
387
387
magQ_Corner (iLon, iLat, nAlts) = qTmp;
388
388
}
389
389
}
@@ -394,14 +394,6 @@ void Grid::dipole_alt_edges(Planets planet){
394
394
magQ_Corner (nLons, iLat, iAlt) = magQ_Corner (nLons - 1 , iLat, iAlt);
395
395
}
396
396
}
397
- // last lat corner is tricky. just take another latitude step, I guess.
398
- // Will work for now.
399
- for (int64_t iAlt = 0 ; iAlt < nAlts + 1 ; iAlt ++) {
400
- for (int64_t iLon = 0 ; iLon < nLons + 1 ; iLon++) {
401
- magQ_Corner (iLon, nLats, iAlt) = (magQ_Corner (iLon, nLats - 2 , iAlt) - magQ_Corner (nLons-1 , nLats - 1 , iAlt)) / 2
402
- + magQ_Corner (iLon, nLats - 1 , iAlt);
403
- }
404
- }
405
397
406
398
// Now we have (p,q) coords corners, convert to lon/lat/alt and we r off to the races
407
399
std::pair <arma_cube, arma_cube> rtheta;
@@ -590,16 +582,14 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet)
590
582
// When the exponential spacing (or something else) is fixed, this needs updating.
591
583
precision_t dlat;
592
584
dlat = baseLats (1 ) - baseLats (0 );
593
- arma_vec baseLats_down (nLats + 1 );
594
585
595
586
// put one cell halfway btwn each base latitude, leave 1st and last cell for now...
596
587
for (int64_t iLat = 1 ; iLat < nLats; iLat ++){
597
588
baseLats_down (iLat) = baseLats (iLat-1 ) + (dlat * 0.5 );
598
589
}
599
590
// Put in 1st and last cell. Done this way so it's easier to put in supercell or something else
600
591
baseLats_down (0 ) = baseLats (0 ) - dlat * 0.5 ;
601
- // baseLats_down(0) = baseLats(nLats-1) + dlat * 0.5;
602
-
592
+ baseLats_down (nLats) = baseLats (nLats-1 ) + dlat * 0.5 ;
603
593
604
594
report.print (3 , " baselats done!" );
605
595
@@ -611,7 +601,7 @@ bool Grid::init_dipole_grid(Quadtree quadtree_ion, Planets planet)
611
601
fill_field_lines (baseLats_down, min_apex_re, Gamma, planet, true );
612
602
613
603
report.print (4 , " Field-aligned Edges" );
614
- dipole_alt_edges (planet);
604
+ dipole_alt_edges (planet, min_alt_re );
615
605
616
606
report.print (3 , " Done generating symmetric latitude & altitude spacing in dipole." );
617
607
0 commit comments